Initial working version of the script.