Merged relevant improvements from bootstrap-rap.sh.