Fix mode-change bugs (Issue #2)