Fix #1158 (aka Incorrect results when searching for gadgets)