Major changes to substr generator