Added JSON flattening