some documentation and removal of debug code