fixes. & refactoring nvm.hpp