Issue 68, 67: add additional exception handling to patching code