Added exception handling and some knobs to the sed