Organises most of the code.