Refactor space index and per-user index.