Fix incorrect handling of chunks if max chunk size exceed