Updates and improvements to script.