Implement reopening of existing DB

This entails writing out separate indexes.