Added some more comments and javadoc to make class clearer.