Cleaning up the code some more, and moving stuff about a bit