Merge "Add check for null token when updating state" into tm-dev