bit og cleanup and improved debugging output