Code cleanup

Cool refactors everywhere, but according to metric_fu we still have a bunch more code smells =/