Added javadoc and reformatted.