Cleanup & improved JSON API