TRAP_MEMORY bug fix