Added javadoc, fixed #1 (NullPointerException bug)