Fix the exclude-region clipping logic for the edge-trim case.
Add some extra debugging output when DEBUG is defined.