Bug fixes for JSON parsing