WIP: deal with corruption when iterating seg from memory