Fixed a small bug and added javadoc.