Allowed dup calls
Added memory allocator for safemem

Needed so concurrent safemem allocations from different processes will
not interfere with each other.