dealoc and bugs

I corrected some bugs and build the dealoc function