Some initial cleanup stuff and very rudimentary resilience added to search