major code cleanup