Alot of cleanup + minor imr.