more cleanup and rearranging