Refactoring the monad stacks and loading block indexes from leveldb on startup