* Avoid repeated queries in getLogs. * Rewrite query for speed and simplicity. * Make default limit 500