Fixed types and references preventing successful use of the scripts

There seem to be basic typos and missing items and are referred to further down.
Everything worked well once resolved.