Overhauled to allow function output into other scripts