Improve this script to be more portable.