a number of bug fixes and improvements