code cleanup before rewrite