Cleanup debug code, return a counter object