Refactoring vmem.py