Code clean-up and javadoc.