Make the end parentheses match more explicit, debug when enabled with a ...

...better error message

- Make the end parentheses match look for a end parentheses on its own (with optional newline).
- Only put debug messages when in debugging mode
- Give a better (more descriptive) error message when we fail