Adds better handling for missing keys and wrong JSON types
Updates output comments to match actual output
Adds the correct key and source for incorrect JSON type errors
Cleans up code