Move the code around

Also reformat the code. Will make the code a bit nicer.