added content-length to header and other minor fixes.