Fixed most math errors.