Threaded DQM migration. Plus memory leak fixes

Signed-off-by: Antanas Norkus <antanas.norkus@cern.ch>
Merge pull request #5985 from anorkus/threaded_dqm_migration2

Threaded DQM migration. Plus memory leak fixes