Fix incorrect include/exclude_modes handling

Fixes #1003