fix memory accesses