Refactor build and packaging