Cleanup and Fix JSON/JSONP support

This started as a cleanup exercise and led to trying to resolve issues discovered that relate to #12, #18, #19, and #22.