fixed up rust patch and make the build scripts a little more intelligent