reorganized things a bit. fixed a problem where trailing newlines were being altered by the filter.