Add pid parameter to writeScratch
debug.h compile++
drop useless cast
wrap json.h in extern C
Merge pull request #13 from codius/misc-fixes

Misc fixes