Refactor vacuum code