Package restructure

The package has been moved around to give better structure. Individual
components have been put into separate files.