Back ported the terminal filter code.