Fix Segmentation Fault and typo.