fixed free() pointer error that was throwing segfaults on newer systems