Add some safety when reading json objects.
Minor reformatting.
Removes unused variable.