cleanup and checks