Misc small fixes and improvements