Started arranging code in a slightly more ordered fashion, with suitable #pragmas for locating sections.