Remove trailing whitespace.
Check if a language exists before switching to it.