Another attempt at cleaned up sed command to fix issues reported on MacOSX by @jxchong