Clean up cross-platform compatibility.

- Move compatibility macros to a new header file.
- Sort system include files in alphabetical order.
- Clean up signal handling (thanks to Adam).
Remove virtual keyword from a ton of methods which don't need it.
Add override keyword to a ton of methods which do need it.