Fix bad length argument to substr calls. Apparently I'm the first one to