cleanup. doLogging as additional parameter to optimize bulk query.