a bunch of cleanup and added some debug txt