A lot of cleanup and improvements