Added quite a lot of Javadoc.