Fix for segfault 11 on OSX

Probably not a good idea to access memory after it's been freed