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

Adds more exception handling while patching modules to handle various issues that can arise. I think this will fix #68, #67