code cleanup, stage 1