Add bool conversion to fix potential bug.

Binary operations promote to int, which means that the comparisons here
are not guaranteed to do what the code is meant to do. Explicitly
converting the result of the bit-wise and means that the comparison is
guaranteed to work.
Merge branch 'release_31' into development

Add bool conversion to fix potential bug.
Fix TEvent handling so it doesn't crash anymore.
Merge branch 'release_31' into development

Fix TEvent handling so it doesn't crash anymore.
Add a feature for debug builds to prompt to attach a debugger.