more optimizations.
prettify and initial cleanup.
merged branches