organization and cleanup

modularized a bunch of functions in the Client class to better
faciliate upgrades and move variable definitions into seperate files