Use remove_if to erase parts of a vector. Avoids O(n^2) worst cases.