Added patching error handling