Fix a memory leak
Fix a segmentation error