Improved documentation and debug output.