Added a great deal of javadoc and cleaned up some
unused methods etc.