Refactored error handling in some JSON functions; added an error parameter.

Moved some memory allocation of strings to the stack.

Removed some unused functions.
Merge pull request #68 from keithj/devel

Refactor to improve error handling and code clarity