Nicer JSON and signature fixes

Small fixes for both the trailing garbage after JSON and the new signatures.

In my (biased) opinion, these are nicer fixes than the ones in PR #29.