Cleanup. Refactoring finished for now, mostly.