Reorganizing code to prepare addition of haddock documentation