clean up and some debugging