Code refactor

incorporating object oriented programming. work in progress.
Merge branch 'master' into gh-pages