Add most of the code required for this script to work.