Added getLog method, and optimized the queries in getWork