bug fixes for JSON parsing code