Various fixes and improvements,