Build & runtime fixes

I had to do some changes to make protected regions work with current Xtend (tested with Xtend 2.6.0 and 2.7.1). These are in the first commit.

Also, the protected regions always caused the generated file to be empty. This was caused by two separate issues, which are fixed in the next two commits.