Basic Client and some server refactoring