start to modularize
partial conversion
Merge branch 'master' into development
Modularized the script into a series of libraries.