Fix json generation
Tidies up routes and actions for JSON generation