Debugging; now compiles

I'm probably done working on this for the night, so I debugged my
changes and fixed them. It's mostly just adding relevant include
statements so that functions are defined by the time they are needed.