Fix segmentation fault in simulator