updated debugging funcs

this includes some of your recent changes (I had to merge them?)

this will compress the debugging file output, and modify the names slightly to make more sense.
I also moved debugging functions to separate debug.py file.