tweaks and fixes to sed substitutions