Added lots of javadoc and fixed a few small items along the way.