Hi,
attached patch does implement some ideas I had to improve the speed of the search. the patch seems to work, but still have some rough edges. I didn't make measurements yet. I provide the code here, so everybody could have a look at it.
Feedback and measurements are welcome!
v1