fix segmentation crashes.