refactor and clean up build