Reorganization to modules, adding haddock documentation.