Fix overlapping writes problem