memory leak fixes

fixes requested in https://github.com/slava77/cmssw/issues/22