Some code reorganisation
more code reorganising