bug fix for EnterMapFromMapX()
diff --git a/inc/qcbor/qcbor_spiffy_decode.h b/inc/qcbor/qcbor_spiffy_decode.h
index df0067b..0ea6a71 100644
--- a/inc/qcbor/qcbor_spiffy_decode.h
+++ b/inc/qcbor/qcbor_spiffy_decode.h
@@ -729,7 +729,7 @@
  The items in the map that was entered do not have to have been
  consumed for this to succeed.
 
- This sets thepre-order traversal cursor to the item after
+ This sets the pre-order traversal cursor to the item after
  the map that was exited.
 */
 static void QCBORDecode_ExitMap(QCBORDecodeContext *pCtx);
@@ -762,6 +762,8 @@
  nesting, this is of little consequence, but may be of consequence for
  large deeply nested CBOR structures on slow CPUs.
 
+ The position of the pre-order traversal cursor is not changed.
+
  See @ref Decode-Errors for discussion on how error handling works.
 
  See also QCBORDecode_GetItemsInMap() for error discussion.
@@ -804,6 +806,8 @@
  QCBORDecode_EnterMapinMapN(), QCBORDecode_EnterArrayInMapN() and such
  to descend into and process maps and arrays.
 
+ The position of the pre-order traversal cursor is not changed.
+
  See @ref Decode-Errors for discussion on how error handling works.
 
  The following errors are set:
@@ -1505,7 +1509,7 @@
 
  When the wrapped CBOR is entered with this function, the pre-order
  traversal and such are bounded to the wrapped
- CBOR. QCBORDecode_ExitBstrWrapped() must be called resume processing
+ CBOR. QCBORDecode_ExitBstrWrapped() must be called to resume processing
  CBOR outside the wrapped CBOR.
 
  If @c pBstr is not @c NULL the pointer and length of the wrapped
@@ -1518,7 +1522,6 @@
 
  See also QCBORDecode_ExitBstrWrapped(), QCBORDecode_EnterMap() and
  QCBORDecode_EnterArray().
-
  */
 void QCBORDecode_EnterBstrWrapped(QCBORDecodeContext *pCtx,
                                   uint8_t             uTagRequirement,
@@ -1545,7 +1548,7 @@
  The items in the wrapped CBOR that was entered do not have to have been
  consumed for this to succeed.
 
- The this sets thepre-order traversal cursor to the item after
+ The this sets the pre-order traversal cursor to the item after
  the byte string that was exited.
 */
 void QCBORDecode_ExitBstrWrapped(QCBORDecodeContext *pCtx);
diff --git a/src/qcbor_decode.c b/src/qcbor_decode.c
index afc3651..efa8433 100644
--- a/src/qcbor_decode.c
+++ b/src/qcbor_decode.c
@@ -432,6 +432,13 @@
 
 
 static inline void
+DecodeNesting_ResetMapOrArrayCount(QCBORDecodeNesting *pNesting)
+{
+   pNesting->pCurrentBounded->u.ma.uCountCursor = pNesting->pCurrentBounded->u.ma.uCountTotal;
+}
+
+
+static inline void
 DecodeNesting_Init(QCBORDecodeNesting *pNesting)
 {
    /* Assumes that *pNesting has been zero'd before this call. */
@@ -445,7 +452,7 @@
 {
    *pSave = *pNesting;
    pNesting->pCurrent = pNesting->pCurrentBounded;
-   pNesting->pCurrent->u.ma.uCountCursor = pNesting->pCurrent->u.ma.uCountTotal;
+   DecodeNesting_ResetMapOrArrayCount(pNesting);
 }
 
 
@@ -2964,13 +2971,25 @@
 }
 
 
+/**
+ * @brief Search for a map/array by label and enter it
+ *
+ * @param[in] pMe  The decode context.
+ * @param[in] pSearch The map/array to search for.
+ *
+ * @c pSearch is expected to contain one item of type map or array
+ * with the label specified. The current bounded map will be searched for
+ * this and if found  will be entered.
+ *
+ * If the label is not found, or the item found is not a map or array,
+ * the error state is set.
+ */
 static void SearchAndEnter(QCBORDecodeContext *pMe, QCBORItem pSearch[])
 {
    // The first item in pSearch is the one that is to be
    // entered. It should be the only one filled in. Any other
    // will be ignored unless it causes an error.
    if(pMe->uLastError != QCBOR_SUCCESS) {
-      // Already in error state; do nothing.
       return;
    }
 
@@ -2985,23 +3004,28 @@
       return;
    }
 
-   /* Need to get the current pre-order nesting level and cursor to be
-      at the map/array about to be entered.
-
-    Also need the current map nesting level and start cursor to
-    be at the right place.
-
-    The UsefulInBuf offset could be anywhere, so no assumption is
-    made about it.
-
-    No assumption is made about the pre-order nesting level either.
-
-    However the bounded mode nesting level is assumed to be one above
-    the map level that is being entered.
+   /*
+    * QCBORDecode_EnterBoundedMapOrArray() used here, requires the
+    * next item for the pre-order traversal cursor to be the map/array
+    * found by MapSearch(). The next few lines of code force the
+    * cursor to that.
+    *
+    * There is no need to retain the old cursor because
+    * QCBORDecode_EnterBoundedMapOrArray() will set it to the
+    * beginning of the map/array being entered.
+    *
+    * The cursor is forced by: 1) setting the input buffer position to
+    * the item offset found by MapSearch(), 2) setting the map/array
+    * counter to the total in the map/array, 3) setting the nesting
+    * level. Setting the map/array counter to the total is not
+    * strictly correct, but this is OK because this cursor only needs
+    * to be used to get one item and MapSearch() has already found it
+    * confirming it exists.
     */
-   /* Seek to the data item that is the map or array */
    UsefulInputBuf_Seek(&(pMe->InBuf), uOffset);
 
+   DecodeNesting_ResetMapOrArrayCount(&(pMe->nesting));
+
    DecodeNesting_SetCurrentToBoundedLevel(&(pMe->nesting));
 
    QCBORDecode_EnterBoundedMapOrArray(pMe, pSearch->uDataType, NULL);
diff --git a/test/qcbor_decode_tests.c b/test/qcbor_decode_tests.c
index 70fd3b1..eee4941 100644
--- a/test/qcbor_decode_tests.c
+++ b/test/qcbor_decode_tests.c
@@ -4647,7 +4647,7 @@
       "another int": 98,
       "text 2": "lies, damn lies and statistics"
    }
-  }
+ }
  */
 
 int32_t SpiffyDecodeBasicMap(UsefulBufC input)