Modified loads of things. Rewrote writeMessage so it should actually work now. Also added ability to log messages to file.