Add debug logging mode
Improved exception handling
Javadoc, visibility, and cleanup