Moved JSON parsing to another module.
Cleaned up and consolidated functions.