Tidy up and refactor the package structure