build cleanup  and refactoring