Change compiler to Clang and create fat binary on release builds.
Add somewhat rudimentary support for writing to memory.
Cosmetic cleanups and some fixes.