improve messagecontext lifetime management