Fix for segfault 11 on OSX

This was causing Segmentation Fault 11 on OSX. Plus it's just probably not a good idea to access memory after it's been freed ;)