Fix bugs in local memory.