search.php: ported temptable code to lib2; added some missing drop-tables and sql-free-results; updates #238