Another fix on optimize rotation

How it was previously was ok, it works as long as the bones don't have gaps.