various fixes and improvements