Added necessary comments. Reorganized calculation away from lazy instantiation for continuity.