Done some clean-up for the majority of the code except main.c.