fixed data structures, added json, made the whole even more flexible