small code refactor
fixed major bug in ssl connections, where pending connection could get stuck