#8, #5, #3, #10 mainly http refactoring

Extensive refactoring for HTTP support, also added restored
compatibility with Python 2.6