fixed memory leaks in presence.c