Refactoring main : splitting into client and server classes