Move compatibility mode to top of file

Ensure compatibility mode is set before line continuations are used.
Correct scope of function