Refactor main package