Added JSON encoding middleware and fixed queue template bug