Added mem.c and worki thread wrapper
demo changes