Fixed $main->error reset handling