fix bugs indicating whether label/data was allocated; improve some decoding tests
diff --git a/README.md b/README.md
index 9937e6c..e636ad9 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@
 
 **Focused on C / native data representation** – Simpler code because there is no support for encoding/decoding to/from JSON, pretty printing, diagnostic notation... Only encoding from native C representations and decoding to native C representations is supported.
 
-**Small simple memory model** – Malloc is not used. The encode context is 128 bytes, decode context is 168 bytes and the description of decoded data item is 56 bytes. Stack use is very light and there is no recursion. The caller supplies the memory to hold the encoded CBOR and encode/decode contexts so caller has full control of memory usage and it is good for embedded implementations that have to run in small fixed memory. 
+**Small simple memory model** – Malloc is not needed. The encode context is 136 bytes, decode context is 104 bytes and the description of decoded data item is 56 bytes. Stack use is very light and there is no recursion. The caller supplies the memory to hold the encoded CBOR and encode/decode contexts so caller has full control of memory usage and it is good for embedded implementations that have to run in small fixed memory. 
 
 **Supports nearly all of RFC 7049** – Only minor, corner-case parts of RFC 7049 are not directly supported (canonicalization, decimal fractions, big floats). Decoding
 indefinite length strings but requires a string allocator (see documentation). Encoding indefinite length strings is not supported, but
diff --git a/cmd_line_main.c b/cmd_line_main.c
index f46799d..ee1180a 100644
--- a/cmd_line_main.c
+++ b/cmd_line_main.c
@@ -42,9 +42,12 @@
 {
     (void)argc; // Suppress unused warning
     (void)argv; // Suppress unused warning
-    
+
+    // Type and size of return from sizeof() varies. These will never be large so cast is safe
+    // TODO: use fputs_wrapper to output these
     printf("sizeof(QCBOREncodeContext) %d\n", (uint32_t)sizeof(QCBOREncodeContext));
     printf("sizeof(QCBORDecodeContext) %d\n", (uint32_t)sizeof(QCBORDecodeContext));
+    printf("sizeof(QCBORDecodeNesting) %d\n", (uint32_t)sizeof(QCBORDecodeNesting));
     printf("sizeof(QCBORItem) %d\n", (uint32_t)sizeof(QCBORItem));
     printf("sizeof(QCBORStringAllocator) %d\n\n", (uint32_t)sizeof(QCBORStringAllocator));
 
diff --git a/inc/qcbor.h b/inc/qcbor.h
index ef020ad..d839db3 100644
--- a/inc/qcbor.h
+++ b/inc/qcbor.h
@@ -153,8 +153,9 @@
  and the DecodeNesting_xxx functions form an "object" that does the work
  for arrays and maps.
  
- 64-bit machine: 27 + 1 + 96 = 32+96 = 128 bytes
- 32-bit machine: 15 + 1 + 96 = 114 bytes
+ Size approximation (varies with CPU/compiler):
+   64-bit machine: 4 * 10 + 8 + 4 padding =  56
+   32-bit machine: 4 * 10 + 4 = 44
  */
 typedef struct __QCBORDecodeNesting  {
   // PRIVATE DATA STRUCTURE
@@ -172,20 +173,21 @@
  The decode context. This data structure plus the public QCBORDecode_xxx
  functions form an "object" that does CBOR decoding.
 
- 64-bit machine: 32 + 1 + (7 bytes padding) + 128 = 168 bytes
- 32-bit machine: 16 + 1 + (3 bytes padding) + 114 = 134 bytes
+ Size approximation (varies with CPU/compiler):
+   64-bit machine: 32 + 1 + 1 + 6 bytes padding + 56 + 8 = 104 bytes
+   32-bit machine: 16 + 1 + 1 + 2 bytes padding + 44 + 4 = 68 bytes
  */
 struct _QCBORDecodeContext {
    // PRIVATE DATA STRUCTURE   
    UsefulInputBuf InBuf;
    
    uint8_t        uDecodeMode;
-   uint8_t        bStringAllocateAll; // TODO: fully implement this
+   uint8_t        bStringAllocateAll;
    
    QCBORDecodeNesting nesting;
    
    // This is NULL or points to a QCBORStringAllocator. It is void
-   // here because _QCBORDecodeContext is defined early n the
+   // here because _QCBORDecodeContext is defined early in the
    // private part of this file and QCBORStringAllocat is defined
    // later in the public part of this file.
    void *pStringAllocator;
diff --git a/src/qcbor_decode.c b/src/qcbor_decode.c
index 9a789d7..831843c 100644
--- a/src/qcbor_decode.c
+++ b/src/qcbor_decode.c
@@ -441,7 +441,7 @@
 /*
  Decode text and byte strings. Call the string allocator if asked to.
  */
-inline static int DecodeBytes(QCBORStringAllocator *pAlloc, int nMajorType, uint64_t uStrLen, UsefulInputBuf *pUInBuf, QCBORItem *pDecodedItem)
+inline static int DecodeBytes(const QCBORStringAllocator *pAlloc, int nMajorType, uint64_t uStrLen, UsefulInputBuf *pUInBuf, QCBORItem *pDecodedItem)
 {
    int nReturn = QCBOR_SUCCESS;
    
@@ -575,7 +575,7 @@
  Errors detected here include: an array that is too long to decode, hit end of buffer unexpectedly,
     a few forms of invalid encoded CBOR
  */
-static int GetNext_Item(UsefulInputBuf *pUInBuf, QCBORItem *pDecodedItem, QCBORStringAllocator *pAlloc)
+static int GetNext_Item(UsefulInputBuf *pUInBuf, QCBORItem *pDecodedItem, const QCBORStringAllocator *pAlloc)
 {
    int nReturn;
    
@@ -592,9 +592,7 @@
    if(nReturn)
       goto Done;
    
-   pDecodedItem->uTagBits   = 0;
-   pDecodedItem->uTag       = 0;
-   pDecodedItem->uDataAlloc = 0;
+   memset(pDecodedItem, 0, sizeof(QCBORItem));
    
    // At this point the major type and the value are valid. We've got the type and the number that
    // starts every CBOR data item.
@@ -860,6 +858,8 @@
       if(nReturn)
          goto Done;
       
+      pDecodedItem->uLabelAlloc = LabelItem.uDataAlloc;
+
       if(LabelItem.uDataType == QCBOR_TYPE_TEXT_STRING) {
          // strings are always good labels
          pDecodedItem->label.string = LabelItem.val.string;
diff --git a/test/qcbor_decode_tests.c b/test/qcbor_decode_tests.c
index bf48aa7..0bc2525 100644
--- a/test/qcbor_decode_tests.c
+++ b/test/qcbor_decode_tests.c
@@ -726,14 +726,16 @@
    return(nReturn);
 }
 
-
+/*
+ Decode and thoroughly check a moderately complex
+ set of maps
+ */
 static int ParseMapTest1()
 {
    QCBORDecodeContext DCtx;
    QCBORItem Item;
    int nCBORError;
    
-   
    QCBORDecode_Init(&DCtx, (UsefulBufC){pValidMapEncoded, sizeof(pValidMapEncoded)}, QCBOR_DECODE_MODE_NORMAL);
    
    if((nCBORError = QCBORDecode_GetNext(&DCtx, &Item)))
@@ -742,14 +744,14 @@
       Item.val.uCount != 3)
       return -1;
    
-   
- 
    if((nCBORError = QCBORDecode_GetNext(&DCtx, &Item)))
       return nCBORError;
    if(Item.uLabelType != QCBOR_TYPE_TEXT_STRING ||
       Item.label.string.len != 13 ||
       Item.uDataType != QCBOR_TYPE_INT64 ||
       Item.val.int64 != 42 ||
+      Item.uDataAlloc ||
+      Item.uLabelAlloc ||
       memcmp(Item.label.string.ptr, "first integer", 13))
       return -1;
    
@@ -757,6 +759,8 @@
       return nCBORError;
    if(Item.uLabelType != QCBOR_TYPE_TEXT_STRING ||
       Item.label.string.len != 23 ||
+      Item.uDataAlloc ||
+      Item.uLabelAlloc ||
       memcmp(Item.label.string.ptr, "an array of two strings", 23) ||
       Item.uDataType != QCBOR_TYPE_ARRAY ||
       Item.val.uCount != 2)
@@ -766,6 +770,8 @@
       return nCBORError;
    if(Item.uDataType != QCBOR_TYPE_TEXT_STRING ||
       Item.val.string.len != 7 ||
+      Item.uDataAlloc ||
+      Item.uLabelAlloc ||
       memcmp(Item.val.string.ptr, "string1", 7))
       return -1;
    
@@ -773,6 +779,8 @@
       return nCBORError;
    if(Item.uDataType != QCBOR_TYPE_TEXT_STRING ||
       Item.val.string.len != 7 ||
+      Item.uDataAlloc ||
+      Item.uLabelAlloc ||
       memcmp(Item.val.string.ptr, "string2", 7))
       return -1;
    
@@ -780,6 +788,8 @@
       return nCBORError;
    if(Item.uLabelType != QCBOR_TYPE_TEXT_STRING ||
       Item.label.string.len != 12 ||
+      Item.uDataAlloc ||
+      Item.uLabelAlloc ||
       memcmp(Item.label.string.ptr, "map in a map", 12) ||
       Item.uDataType != QCBOR_TYPE_MAP ||
       Item.val.uCount != 4)
@@ -792,6 +802,8 @@
       memcmp(Item.label.string.ptr, "bytes 1", 7)||
       Item.uDataType != QCBOR_TYPE_BYTE_STRING ||
       Item.val.string.len != 4 ||
+      Item.uDataAlloc ||
+      Item.uLabelAlloc ||
       memcmp(Item.val.string.ptr, "xxxx", 4))
       return -1;
    
@@ -802,6 +814,8 @@
       memcmp(Item.label.string.ptr, "bytes 2", 7) ||
       Item.uDataType != QCBOR_TYPE_BYTE_STRING ||
       Item.val.string.len != 4 ||
+      Item.uDataAlloc ||
+      Item.uLabelAlloc ||
       memcmp(Item.val.string.ptr, "yyyy", 4))
       return -1;
    
@@ -809,6 +823,8 @@
       return nCBORError;
    if(Item.uLabelType != QCBOR_TYPE_TEXT_STRING ||
       Item.label.string.len != 11 ||
+      Item.uDataAlloc ||
+      Item.uLabelAlloc ||
       memcmp(Item.label.string.ptr, "another int", 11) ||
       Item.uDataType != QCBOR_TYPE_INT64 ||
       Item.val.int64 != 98)
@@ -821,6 +837,8 @@
       memcmp(Item.label.string.ptr, "text 2", 6)||
       Item.uDataType != QCBOR_TYPE_TEXT_STRING ||
       Item.val.string.len != 30 ||
+      Item.uDataAlloc ||
+      Item.uLabelAlloc ||
       memcmp(Item.val.string.ptr, "lies, damn lies and statistics", 30))
       return -1;
    
@@ -830,7 +848,16 @@
 
 
 /*
- This test parses pValidMapEncoded and checks for extra bytes along the way
+ Fully or partially decode pValidMapEncoded. When
+ partially decoding check for the right error code.
+ How much partial decoding depends on nLevel.
+ 
+ The partial decodes test error conditions of
+ incomplete encoded input.
+ 
+ This could be combined with the above test
+ and made prettier and maybe a little more
+ thorough.
  */
 static int ExtraBytesTest(int nLevel)
 {
@@ -847,7 +874,7 @@
          return 0;
       }
    }
-   
+
    
    if((nCBORError = QCBORDecode_GetNext(&DCtx, &Item)))
       return nCBORError;
@@ -1010,7 +1037,7 @@
       memcmp(Item.val.string.ptr, "lies, damn lies and statistics", 30))
       return -1;
    
-   if(QCBORDecode_Finish(&DCtx) == QCBOR_ERR_EXTRA_BYTES) {
+   if(QCBORDecode_Finish(&DCtx)) {
       return -1;
    }
    
@@ -1022,7 +1049,8 @@
 
 int ParseMapTest()
 {
-   int n = ParseMapTest1();  // TODO: review this test carefully
+   // Parse a moderatly complex map structure very thoroughl
+   int n = ParseMapTest1();
    
    if(!n) {
       for(int i = 0; i < 10; i++) {
diff --git a/test/qcbor_decode_tests.h b/test/qcbor_decode_tests.h
index c2bcad5..2fca418 100644
--- a/test/qcbor_decode_tests.h
+++ b/test/qcbor_decode_tests.h
@@ -157,19 +157,46 @@
  */
 int NestedMapTest(void);
 
+
+/*
+ Parse maps with indefinite lengths
+ */
 int NestedMapTestIndefLen(void);
 
 
+/*
+ Parse some maps and arrays with indefinite lengths.
+ Includes some error cases.
+ */
 int IndefiniteLengthArrayMapTest(void);
 
+
+/*
+ Parse indefinite length strings. Uses
+ MemPool. Includes error cases.
+ */
 int IndefiniteLengthStringTest(void);
 
+
+/*
+ Test deep nesting of indefinite length
+ maps and arrays including too deep.
+ */
 int IndefiniteLengthNestTest(void);
 
+
+/*
+ Test parsing strings were all strings, not
+ just indefinite length strings, are
+ allocated. Includes error test cases.
+ */
 int AllocAllStringsTest(void);
 
-int MemPoolTest(void);
 
+/*
+ Direct test of MemPool string allocator
+ */
+int MemPoolTest(void);
 
 
 #endif /* defined(__QCBOR__qcbort_decode_tests__) */