Fix substr to do the right thing!