Bug fixes and json formatting