Refactoring in progress. Activation calculation completed. Calculate error terms. Completely untested.