Refactor code & add more support for http1.1