Improved header/body parsing