Miscellaneous clean-ups

This PR contains a mixed bag of clean-ups that came initially from running the compiler with `reportUnknownTypes` set to `WARNING`. It also adds a few `@define`s that should help enable finer-grained custom builds in the future.

I can split this into multiple PRs if needed.