Fixes segfault on erasing