Major improvements in search logic