Potentially problem there: after `erase` iterator is invalidated. Use the result of `erase`:
```
it = mPackages.erase(it);
it++;// not sure, that is needed
```