Added parsing of headers and fixed recv() bug