Finished JSON stuff, added some more generic utility functions.