add persistentundo, courtesy of http://amix.dk/blog/post/19548