Simplify and fix logic of umodes filtering. Closes GH-719.