fixed memory leaks, removed redundant (obsolete) function 'debug_some_data'