multiple changes

only pass table to callbacks if there are results
lock mutex for less time in Database::Connect
fix passing result to callback