fixed some logic bugs with the body parsing, added some comments