split client and server; server split to sub-modules; refactoring