Some cleanup and some debugging code for various ills