Issue #1578: Handle repeated search terms
Closes #1578, closes #1581