Refactor code to eliminate computation time (incl. notes on various formulas)