Do not use db directly in jobs lib and other cleanups.