Connection manager added

+ code reorganization