added thingId and fixed memory leak