get rid of insane cleanup logic in an inappropriate place