Added some memory management code in coarse.c