Fixing memory leaks, finishing DLL