minor bug fixes and improvements