Fix two small bugs with mem: clear ID objects that disappear, fix resolution of id objects