Code improvements

Incorporating feedback received while reviewing the first iteration.
API improvements and code simplification.
Marking connection as invalid
Removing old collect call implementation
More collect call fixes
Fixing compilation

When merging the code from upstream a variable declaration was removed.
Retrying SSL_accept and SSL_connect if error.
Simplifying printing of Key from ConnectionInfo
Merge pull request #1275 from cduclos/call-collect-agent

Call collect, core modifications