fix seg faults and echo