refactor build tools, minor edits to fix types