Javadocs added, code reformatted