Cruft code removed, formula explanation added