more cleanup and checks