fix memory corruption in arrays destructor