Added logging and javadoc