Updated javadoc and added some comments to clarify the algorithm as well
as a couple of fields and their purpose.