Severe code cleanup