typo fixes plus a switch to use re.sub