Better 'get_best' query.
Clean up database stuff.