HUGE PHP cleanup