make sure we have a valid sessionId before assembling the payload
added a note about thread-safety