Major cleanup and reorganization