Added session handling to message.c