More re-factoring, using JSON instead of strings.