Various minor fixes and improvements