Added in-line documentation throughout.