Fixups mainly so terminal mode works.