FilterMode -> enum class Mode, various minor refactoring