Better connectionlogic and logging