Fixes some matching logic