Also brings in much needed CLI changes from upstream and backporting our custom changes on top of those changes. Fixes #1880