Turn off segment before setting data
Added simple implementation of numtoseg()