costFunctionReg created. pep8-ification.