removed unused functions and fixed destructors