Fixes

Lots of fixes for NVRAM patching. 
These will probably come in useful for other types of patching too.
Also a Makefile fix that should be applied to the master branch here as it's needed for OSX builds.