some fixes on chunk parsing