tiny bug fixes and improvements

tiny bug fixes and improvements