Fixed input. Added Javadocs.