Refactoring and clean up

Pun intended
Refactoring

Moving toward common function definitions across master and node
Initial commit on client code