Fixed memory access issues