got rid of the global variables (I knew it had to do something with extra parameters, right dh_cls ?)
few memory leaks fix, but not all of them yet
few bugfixes