Miscellaneous fixes and improvements