Fixed segmentation fault bug.