Fix massive segmentation fault