Added sharing of memories, and some tests