Fixes for GerritConnection

This change fixes some issues. Also includes refactoring code and new interface.
Almost them affects only internal of GerritConnection. Remaining affects no any features or fix potential issues.