BASE-322 #comment add 'writtenChunks' dictionary to address the case when readStack becomes inconsistent