Fix bug when removing equal instances of the same class from a vector