Corrected all the errors I found by inspection

Program is still not tested, however, I believe I've fixed a lot of
issues in it. It builds on CodeLite, but I have not attempted to compile
on the ECE machines. There's still quite a lot to be done.