some refactoring; undomode is persistent now