Don't use deleted pointers. Fix the segfault. Thanks to RedFox on IRC for input on both this and the previous commit.