Create packages and refactor code