Search: various code cleanup