Reverted TCP changes. Added relevant tests. Improved setting of HTTP mode.

All 109 tests pass.