Refactor closures into operator() which takes pointer to smem.