Fixed some bugs in search