Solved the segmentation faults

Some of the errors were missed before. Solved that problem too.