The details here were moved to a JointState method to make this code more readable.