Clean debug code, add comments