cleaning up, template fixes and improvements