Improved search functionality and removed some search bugs