Started arranging code in a slightly more ordered fashion, with suitable #pragmas for locating sections.
Turned on a whole bunch of compiler warnings, corrected resulting issues.
Rearranged slightly and divided into sections.