Added overload of remove that allows for shared arrays.