Converted to use a .dscript system and added more functions