Fix for issue #40
Fix for issue #40, and refactored.
Fix a few for HttpConnection.cs