DDF-953 fixed null pointers and resource leak