fix crash in terminal mode (see bug #4)