adding auto-replace.sh and minor fixes