HUGE code cleanup