Clean up logging and add javadocs.