a few minor  bug fixes and improvements