Misc cleanups and improvements