Small reorganisation of code to make things more logical.