Reformatted code to make sense. Was all crazy. Fixed some
additional #ifs and a #define.
WARNING: Untested. Uncompiled.