Initial commit of Stage 1 calculation.
Added stage 2 code.