Fixes bugs in search.py