Several segmentation faults improved