Fixed some SEGFAULTs