Fixed #6 and replaced usage of maps for sets when building the result of matches.