Major cleanup and restructuring