Cleaned up code and fixed backend to produce nicer looking JSON.