diff --git a/add/data/xql/getLinkTarget.xql b/add/data/xql/getLinkTarget.xql
index ea63046a333ff7346a52c4cb591515aea0a83137..1615138645dbd96746a07ba5a4fccf84ab719f8c 100644
--- a/add/data/xql/getLinkTarget.xql
+++ b/add/data/xql/getLinkTarget.xql
@@ -37,7 +37,7 @@ declare variable $uri := request:get-parameter('uri', '');
 (:~
  : Returns a view for an edirom object
  :)
-declare function local:getView($type as xs:string, $docUri as xs:string, $doc as node()+) as map(*)? {
+declare function local:getView($type as xs:string, $docUri as xs:string, $doc as document-node()?) as map(*)? {
     let $baseMap := map {
         'type': substring-after($type, '_'),
         'uri':if ($type = ('mei_textView', 'desc_xmlView')) then
@@ -124,7 +124,7 @@ declare function local:getView($type as xs:string, $docUri as xs:string, $doc as
 (:~
  : Returns the views for an edirom object
  :)
-declare function local:getViews($type as xs:string, $docUri as xs:string, $doc as node()+) as map(*)* {
+declare function local:getViews($type as xs:string, $docUri as xs:string, $doc as document-node()?) as map(*)* {
     
     let $views := (
         (:'desc_summaryView',:)
@@ -154,23 +154,32 @@ declare function local:getViews($type as xs:string, $docUri as xs:string, $doc a
 (:~
  : Returns the window title for an edirom-object
  :)
-declare function local:getWindowTitle($doc as node()+, $type as xs:string) as xs:string {
+declare function local:getWindowTitle($doc as document-node()?, $type as xs:string) as xs:string {
     
     (: Work :)
-    if (exists($doc//mei:mei) and exists($doc//(mei:workDesc|mei:workList)/mei:work) and not(exists($doc//mei:perfMedium))) then
-        (eutil:getLocalizedTitle(($doc//mei:work)[1]/mei:titleStmt[1], $lang))
-    else if (exists($doc/root()/mei:work)) then
-        (eutil:getLocalizedTitle($doc/root()/mei:work, $lang))
+    if ($type = 'work') then
+        
+        let $workTitleContainer := (
+            (: MEI 3 and older :)
+            ($doc//mei:work)[1]/mei:titleStmt,
+            (: MEI 4 and newer :)
+            ($doc//mei:work)[1]
+        )[1]
+    
+        return
+            eutil:getLocalizedTitle($workTitleContainer, $lang)
     
     (: Recording :)
-    else if (exists($doc//mei:mei) and exists($doc//mei:recording)) then
+    else if ($type = 'recording') then
         (eutil:getLocalizedTitle($doc//mei:fileDesc/mei:titleStmt[1], $lang))
     
-    (: Source / Score :)
+    (: Source / Score  MEI 4 and newer :)
     else if ($type = 'source' and exists($doc//mei:manifestation/mei:titleStmt)) then
         (string-join((eutil:getLocalizedTitle(($doc//mei:manifestation)[1]/mei:titleStmt[1], $lang),
         ($doc//mei:manifestation)[1]//mei:identifier[lower-case(@type) = 'shelfmark'][1]), ' | ')
         => normalize-space())
+     
+     (: Source / Score  MEI 3 and older :)
     else if ($type = 'source' and exists($doc//mei:source/mei:titleStmt)) then
         (string-join((eutil:getLocalizedTitle(($doc//mei:source)[1]/mei:titleStmt[1], $lang),
         ($doc//mei:source)[1]//mei:identifier[lower-case(@type) = 'shelfmark'][1]), ' | ')
@@ -179,17 +188,29 @@ declare function local:getWindowTitle($doc as node()+, $type as xs:string) as xs
     (: MEI fallback if no title is found :)
     else if (exists($doc//mei:mei) and exists(($doc//mei:titleStmt)[1])) then
         (eutil:getLocalizedTitle(($doc//mei:titleStmt)[1], $lang))
-    
+
     (: Text :)
-    else if (exists($doc/tei:TEI)) then
+    else if ($type = 'text') then
         (eutil:getLocalizedTitle($doc//tei:fileDesc/tei:titleStmt[1], $lang))
     
     (: HTML :)
-    else if ($type = 'html') then
-        ($doc//head/data(title))
+    else if ($type = 'html' and not(functx:all-whitespace($doc//*:head/*:title))) then
+        $doc//*:head/*:title => normalize-space()
+    
+    else if($type = 'unknown') then
+    
+        let $eventualTitleContainers := ($doc//mei:titleStmt, $doc//tei:titleStmt)
+        let $eventualTitles := (
+            for $et in $eventualTitleContainers return
+                eutil:getLocalizedTitle($et, $lang),
+            for $t in $doc//*:title return
+                $t => normalize-space()
+        )
+        
+        return $eventualTitles[1]
     
     else
-        (string('unknown'))
+        ('[No title found!]')
 };
 
 (: QUERY BODY ============================================================== :)