Misc updates

Some miscellaneous bug fixes from downstream.