Fixes, cherrypicks and improvements

See commits for details.