combine fitfn with errfn to reduce overhead

Thanks @wasade!