Some fixes to the process of reading and writing data.