Fix #726 and introduce much simpler rules for qualified types