Fixed some major problems with read/write functions on shared memory.