DB: Fixing memory leak and code optimization

4 jobs for mem_leak in 17 minutes and 8 seconds (queued for 1 second)
latest