misc. debug, cleanup, refactoring