Moar cleanup.
More refactoring and cleanup.