diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp
index b609134..5bbc767 100644
--- a/src/widgets/itemviews/qheaderview.cpp
+++ b/src/widgets/itemviews/qheaderview.cpp
@@ -592,6 +592,7 @@ int QHeaderView::sectionSizeHint(int logicalIndex) const
 
 int QHeaderView::visualIndexAt(int position) const
 {
+    qDebug() << __FUNCTION__ << "position="  << position;
     Q_D(const QHeaderView);
     int vposition = position;
     d->executePostedLayout();
@@ -610,11 +611,14 @@ int QHeaderView::visualIndexAt(int position) const
     if (visual < 0)
         return -1;
 
+
     while (d->isVisualIndexHidden(visual)){
+        qDebug() << __FUNCTION__ << "looping" << visual;
         ++visual;
         if (visual >= count)
             return -1;
     }
+    qDebug() << __FUNCTION__ << "returns" << visual;
     return visual;
 }
 
@@ -627,8 +631,12 @@ int QHeaderView::visualIndexAt(int position) const
 int QHeaderView::logicalIndexAt(int position) const
 {
     const int visual = visualIndexAt(position);
-    if (visual > -1)
-        return logicalIndex(visual);
+    qDebug() << __FUNCTION__ << "position=" << position <<  "visual=" << visual;
+    if (visual > -1) {
+        int r = logicalIndex(visual);
+        qDebug() << __FUNCTION__ << "ret " << r << "logIndices" << d_func()->logicalIndices;
+        return r;
+    }
     return -1;
 }
 
@@ -3513,6 +3521,7 @@ int QHeaderViewPrivate::headerSectionPosition(int visual) const
 
 int QHeaderViewPrivate::headerVisualIndexAt(int position) const
 {
+    qDebug() << __FUNCTION__ << "position="<< position;
     if (sectionStartposRecalc)
         recalcSectionStartPos();
     int startidx = 0;
@@ -3524,8 +3533,10 @@ int QHeaderViewPrivate::headerVisualIndexAt(int position) const
         } else {
             if (sectionItems.at(middle).calculatedEndPos() <= position)
                 startidx = middle + 1;
-            else // we found it.
+            else { // we found it.
+                qDebug() << __FUNCTION__ << "returns middle="<<middle;
                 return middle;
+            }
         }
     }
     return -1;
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp
index 2c5f4b7..c72f832 100644
--- a/src/widgets/itemviews/qtreeview.cpp
+++ b/src/widgets/itemviews/qtreeview.cpp
@@ -1362,14 +1362,18 @@ void QTreeViewPrivate::paintAlternatingRowColors(QPainter *painter, QStyleOption
 
 bool QTreeViewPrivate::expandOrCollapseItemAtPos(const QPoint &pos)
 {
+    qDebug() << __FUNCTION__ << pos;
     Q_Q(QTreeView);
     // we want to handle mousePress in EditingState (persistent editors)
     if ((state != QAbstractItemView::NoState
                 && state != QAbstractItemView::EditingState)
-                || !viewport->rect().contains(pos))
+                || !viewport->rect().contains(pos)) {
+        qDebug() << __FUNCTION__ <<"r true 1";
         return true;
+    }
 
     int i = itemDecorationAt(pos);
+    qDebug() << __FUNCTION__ <<"itemDecorationAt" << i << pos;
     if ((i != -1) && itemsExpandable && hasVisibleChildren(viewItems.at(i).index)) {
         if (viewItems.at(i).expanded)
             collapse(i, true);
@@ -1379,8 +1383,10 @@ bool QTreeViewPrivate::expandOrCollapseItemAtPos(const QPoint &pos)
             q->updateGeometries();
             viewport->update();
         }
+        qDebug() << __FUNCTION__ <<"r true 2";
         return true;
     }
+    qDebug() << __FUNCTION__ <<"fallthru false";
     return false;
 }
 
@@ -3060,6 +3066,7 @@ void QTreeViewPrivate::initialize()
 
 void QTreeViewPrivate::expand(int item, bool emitSignal)
 {
+    qDebug() << __FUNCTION__ << "item=" << item << emitSignal;
     Q_Q(QTreeView);
 
     if (item == -1 || viewItems.at(item).expanded)
@@ -3730,14 +3737,21 @@ void QTreeViewPrivate::updateScrollBars()
 
 int QTreeViewPrivate::itemDecorationAt(const QPoint &pos) const
 {
-    executePostedLayout();
+    executePostedLayout();    
     int x = pos.x();
     int column = header->logicalIndexAt(x);
-    if (!isTreePosition(column))
-        return -1; // no logical index at x
+    qDebug() << __FUNCTION__ << pos << "x=" << x << "column=" << column;
+
+    if (!isTreePosition(column)) {
+        qDebug() << __FUNCTION__ << "no logical index at x"
+                 << "(logicalIndexForTree=" <<logicalIndexForTree() << ')';        
+        return -1;
+    }
 
     int viewItemIndex = itemAtCoordinate(pos.y());
-    QRect returning = itemDecorationRect(modelIndex(viewItemIndex));
+    const QModelIndex idx = modelIndex(viewItemIndex);
+    qDebug() << __FUNCTION__ << "viewItemIndex=" << viewItemIndex << idx << idx.data();
+    QRect returning = itemDecorationRect(idx);
     if (!returning.contains(pos))
         return -1;
 
@@ -3747,6 +3761,7 @@ int QTreeViewPrivate::itemDecorationAt(const QPoint &pos) const
 QRect QTreeViewPrivate::itemDecorationRect(const QModelIndex &index) const
 {
     Q_Q(const QTreeView);
+    qDebug() << __FUNCTION__ << index << index.data().toString();
     if (!rootDecoration && index.parent() == root)
         return QRect(); // no decoration at root
 
@@ -3768,7 +3783,9 @@ QRect QTreeViewPrivate::itemDecorationRect(const QModelIndex &index) const
     QStyleOption opt;
     opt.initFrom(q);
     opt.rect = rect;
-    return q->style()->subElementRect(QStyle::SE_TreeViewDisclosureItem, &opt, q);
+    QRect r = q->style()->subElementRect(QStyle::SE_TreeViewDisclosureItem, &opt, q);
+    qDebug() << __FUNCTION__ << index << "returns" << r;
+    return r;
 }
 
 QList<QPair<int, int> > QTreeViewPrivate::columnRanges(const QModelIndex &topIndex,
