Abort on patch failure

Let's make sure that the patches actually apply properly before continuing.

Threw in some other minor fixes too.