major code cleaning