Some code reorganisation