Backport fixes and improvements