cleaning up pipeline, fixing flattening for IndexMap