More changes to the main calculation routine.