Refactored much of the cesModel code.