Cleaned up model code. Corrected calculations.