VT switching: code refactoring & stability fixes