Misc. fixes and improvements