more cleanup before optimizing