cleanup namespace, add support for errors when saving JSON