Fix buffer clearing and dumping when switching modes