Fixed seg faults for callback functions