Incapsulate connection and transport in client
Some refactoring
More refactor