Added Javadocs and fixed a minor bug.