Fix potential crash in joint creation