some cleanup and improvements