Updating some comments in the main algorithm.
Minor tidying.
More comments.
Another small leak fix.