Fix a bug in subjectof/targetof association handling that was causing
incorrect results.