Misc fixes and improvements