Error function lookup bug fix, removed unused variables.