Code Refactor

Refactored Script file to make use of arrays and objects to optimize
code.  Restored functionality.
Merge branch 'master' into gh-pages