Refactor build script to use env.path only where needed