Moved scratch search code into lib/