Part of the fix for Issue #39. Chopped out most of the work done by sed, now  only has to pass through two filters