Added msg_context to clamp_length