Cast relationship objects to fix compiler error