Fixed the incosistent write bugs!