For selecting an IME after toggle, use previous inputmethods also.

If that also not present, go to first input method for the current
language.
Limit the previous languages and inputmethods to size 5