Fix map calculaing by reading and writing.