Fix quote IDs exceeding the number of matches (fixes #39)