fixing seg faults and such