trap_memory implemented. Seems to be working