error codes are now enums because they show up in the debugger. Lots of documentation clean up for errors
diff --git a/README.md b/README.md
index f8605e4..fd22141 100644
--- a/README.md
+++ b/README.md
@@ -33,7 +33,7 @@
 ## Building
 There is a simple makefile for the UNIX style command line binary that compiles everything to run the tests.
 
-The actual non-test source files are these seven:
+The actual non-test source files are these eight:
 * inc/UsefulBuf.h
 * inc/qcbor.h
 * src/UsefulBuf.c
diff --git a/inc/qcbor.h b/inc/qcbor.h
index 176d6b7..4c32bca 100644
--- a/inc/qcbor.h
+++ b/inc/qcbor.h
@@ -528,90 +528,101 @@
 #define QCBOR_MAX_CUSTOM_TAGS    16
 
 
+typedef enum {
+   /** The encode or decode completely correctly. */
+   QCBOR_SUCCESS = 0,
 
+   /** The buffer provided for the encoded output when doing encoding was
+       too small and the encoded output will not fit. Also, when the buffer
+       given to QCBORDecode_SetMemPool() is too small. */
+   QCBOR_ERR_BUFFER_TOO_SMALL,
 
-/** The encode or decode completely correctly. */
-#define QCBOR_SUCCESS                     0
+   /** During encoding or decoding, the array or map nesting was deeper than
+    this implementation can handle. Note that in the interest of code size
+    and memory use, this implementation has a hard limit on array nesting. The
+    limit is defined as the constant QCBOR_MAX_ARRAY_NESTING. */
+   QCBOR_ERR_ARRAY_NESTING_TOO_DEEP,
 
-/** The buffer provided for the encoded output when doing encoding was
- too small and the encoded output will not fit. */
-#define QCBOR_ERR_BUFFER_TOO_SMALL        1
+   /** During decoding or encoding, the array or map had too many items in it.
+       This limit QCBOR_MAX_ITEMS_IN_ARRAY, typically 65,535. */
+   QCBOR_ERR_ARRAY_TOO_LONG,
 
-/**  During encoding or decoding, the array or map nesting was deeper than this
- implementation can handle. Note that in the interest of code size and
- memory use, this implementation has a hard limit on array nesting. The
- limit is defined as the constant QCBOR_MAX_ARRAY_NESTING. */
-#define QCBOR_ERR_ARRAY_NESTING_TOO_DEEP  2
+   /** During encoding, more arrays or maps were closed than opened. This is a
+       coding error on the part of the caller of the encoder. */
+   QCBOR_ERR_TOO_MANY_CLOSES,
 
-/**  During decoding the array or map had too many items in it. This limit is quite
- high at 65,535. */
-#define QCBOR_ERR_ARRAY_TOO_LONG          3
+   /** During decoding, some CBOR construct was encountered that this decoder
+        doesn't support, primarily this is the reserved additional info values,
+        28 through 30. */
+   QCBOR_ERR_UNSUPPORTED,
 
-/**  During encoding, more arrays or maps were closed than opened. This is a
- coding error on the part of the caller of the encoder. */
-#define QCBOR_ERR_TOO_MANY_CLOSES         4
+   /** During decoding, hit the end of the given data to decode. For example,
+       a byte string of 100 bytes was expected, but the end of the input was
+       hit before finding those 100 bytes.  Corrupted CBOR input will often
+       result in this error. */
+   QCBOR_ERR_HIT_END,
 
-/**  During decoding, some CBOR construct was encountered that this decoder
- doesn't support. */
-#define QCBOR_ERR_UNSUPPORTED             5
+   /** During encoding, the length of the input buffer was too large. This might
+       happen on a 64-bit machine when a buffer larger than UINT32_MAX is passed.
+     */
+   QCBOR_ERR_BUFFER_TOO_LARGE,
 
-/**  During decoding, hit the end of the given data to decode. For example,
- a byte string of 100 bytes was expected, but the end of the input
- was hit before finding those 100 bytes.  Corrupted CBOR
- input will often result in this error. */
-#define QCBOR_ERR_HIT_END                 6
+   /** During decoding, an integer smaller than INT64_MIN was received (CBOR
+       can represent integers smaller than INT64_MIN, but C cannot). */
+   QCBOR_ERR_INT_OVERFLOW,
 
-/** The length of the input buffer was too large. This might happen
- on a 64-bit machine when a buffer larger than INT32_MAX is passed */
-#define QCBOR_ERR_BUFFER_TOO_LARGE        7
+   /** During decoding, the label for a map entry is bad. What causes this
+       error depends on the decoding mode. */
+   QCBOR_ERR_MAP_LABEL_TYPE,
 
-/** The simple value added for encoding (e.g. passed to QCBOR_AddSimple) was not valid */
-#define QCBOR_ERR_INVALID_SIMPLE          8
+   /** During encoding or decoding, the number of array or map opens was not
+       matched by the number of closes. */
+   QCBOR_ERR_ARRAY_OR_MAP_STILL_OPEN,
 
-/** During parsing, the integer received was larger than can be handled. This is
- most likely a large negative number as CBOR can represent large negative integers
- that C cannot */
-#define QCBOR_ERR_INT_OVERFLOW            9
+   /** During encoding, the simple value is not between CBOR_SIMPLEV_FALSE
+       and CBOR_SIMPLEV_UNDEF. */
+   QCBOR_ERR_BAD_SIMPLE,
 
-/** During parsing, the label for a map entry is bad. An array is used as a map label,
- in mode to accept strings only as labels and it is not a string... */
-#define QCBOR_ERR_MAP_LABEL_TYPE          10
+   /** During decoding, a date greater than +- 292 billion years from Jan 1
+       1970 encountered during parsing. */
+   QCBOR_ERR_DATE_OVERFLOW,
 
-/** The number of array or map opens was not matched by the number of closes */
-#define QCBOR_ERR_ARRAY_OR_MAP_STILL_OPEN 11
+   /** During decoding, the CBOR is not valid, primarily a simple type is encoded in
+      a prohibited way. */
+   QCBOR_ERR_INVALID_CBOR,
 
-/** The simple value is not between CBOR_SIMPLEV_FALSE and CBOR_SIMPLEV_UNDEF */
-#define QCBOR_ERR_BAD_SIMPLE              12 // todo combine with 8?
+   /** Optional tagging that doesn't make sense (an int is tagged as a
+       date string) or can't be handled. */
+   QCBOR_ERR_BAD_OPT_TAG,
 
-/** Date greater than +- 292 billion years from Jan 1 1970 encountered during parsing */
-#define QCBOR_ERR_DATE_OVERFLOW           13
+   /** Returned by QCBORDecode_Finish() if all the inputs bytes have not
+       been consumed. */
+   QCBOR_ERR_EXTRA_BYTES,
 
-/** The CBOR is not valid (a simple type is encoded wrong)  */
-#define QCBOR_ERR_INVALID_CBOR            14
+   /** During encoding, QCBOREncode_Close() call with a different type than
+       is currently open. */
+   QCBOR_ERR_CLOSE_MISMATCH,
 
-/** Optional tagging that doesn't make sense (an int is tagged as a date string) or can't be handled. */
-#define QCBOR_ERR_BAD_OPT_TAG             15
+   /** Unable to decode an indefinite length string because no string
+       allocator was configured. */
+   QCBOR_ERR_NO_STRING_ALLOCATOR,
 
-/** Returned by QCBORDecode_Finish() if all the inputs bytes have not been consumed */
-#define QCBOR_ERR_EXTRA_BYTES             16
+   /** One of the chunks in an indefinite length string is not of the type of
+       the string. */
+   QCBOR_ERR_INDEFINITE_STRING_CHUNK,
 
-/** Closing something different than is open */
-#define QCBOR_ERR_CLOSE_MISMATCH          17
+   /** Error allocating space for a string, usually for an indefinite length
+       string. */
+   QCBOR_ERR_STRING_ALLOCATE,
 
-/** Unable to decode an indefinitely length string because no string allocator was configured */
-#define QCBOR_ERR_NO_STRING_ALLOCATOR     18
+   /** During decoding, a break occurred outside an indefinite length item. */
+   QCBOR_ERR_BAD_BREAK,
 
-/** One of the segments in an indefinite length string is of the wrong type */
-#define QCBOR_ERR_INDEFINITE_STRING_SEG   19
-
-/** Error allocating space for a string, usually for an indefinite length string */
-#define QCBOR_ERR_STRING_ALLOC            20
-
-/** The a break occurred outside an indefinite length item */
-#define QCBOR_ERR_BAD_BREAK               21
-
-/** Too many tags in the caller-configured tag list, or not enough space in QCBORTagListOut */
-#define QCBOR_ERR_TOO_MANY_TAGS           22
+   /** During decoding, too many tags in the caller-configured tag list, or not
+       enough space in QCBORTagListOut. */
+   QCBOR_ERR_TOO_MANY_TAGS
+   
+} QCBORError;
 
 
 /** See QCBORDecode_Init() */
@@ -1610,7 +1621,7 @@
  
  */
 
-int QCBOREncode_Finish(QCBOREncodeContext *pCtx, UsefulBufC *pEncodedCBOR);
+QCBORError QCBOREncode_Finish(QCBOREncodeContext *pCtx, UsefulBufC *pEncodedCBOR);
 
 /**
  Get the encoded CBOR and error status.
@@ -1639,7 +1650,7 @@
  
  */
 
-int QCBOREncode_FinishGetSize(QCBOREncodeContext *pCtx, size_t *uEncodedLen);
+QCBORError QCBOREncode_FinishGetSize(QCBOREncodeContext *pCtx, size_t *uEncodedLen);
 
 
 
@@ -1723,7 +1734,7 @@
  holding the encoded CBOR does not need to remain valid.
  
  */
-int QCBORDecode_SetMemPool(QCBORDecodeContext *pCtx, UsefulBuf MemPool, bool bAllStrings);
+QCBORError QCBORDecode_SetMemPool(QCBORDecodeContext *pCtx, UsefulBuf MemPool, bool bAllStrings);
 
 
 /**
@@ -1786,7 +1797,18 @@
  @param[in]  pCtx          The decoder context.
  @param[out] pDecodedItem  Holds the CBOR item just decoded.
  
- @return 0 or error.
+ @return 0 or error. All errors except QCBOR_ERR_TOO_MANY_TAGS
+ and QCBOR_ERR_STRING_ALLOCATE indicate that the CBOR input
+ could not be decoded. In most cases
+ this is because the CBOR is invalid. In a few cases
+ (QCBOR_ERR_ARRAY_NESTING_TOO_DEEP, QCBOR_ERR_INT_OVERFLOW,
+ QCBOR_ERR_DATE_OVERFLOW) it is because the CBOR is beyond
+ the limits of what this implementation can handle.
+ QCBOR_ERR_NO_STRING_ALLOCATOR indicates CBOR that cannot
+ be handled unless a string allocator is configured.
+ QCBOR_ERR_MAP_LABEL_TYPE is in a way a limitation of
+ this implementation, but can be avoided by decoding
+ in QCBOR_DECODE_MODE_MAP_AS_ARRAY mode.
  
  pDecodedItem is filled in with the value parsed. Generally, the
  folloinwg data is returned in the structure.
@@ -1889,7 +1911,7 @@
  
  */
 
-int QCBORDecode_GetNext(QCBORDecodeContext *pCtx, QCBORItem *pDecodedItem);
+QCBORError QCBORDecode_GetNext(QCBORDecodeContext *pCtx, QCBORItem *pDecodedItem);
 
 
 /**
@@ -1920,7 +1942,7 @@
  
  */
 
-int QCBORDecode_GetNextWithTags(QCBORDecodeContext *pCtx, QCBORItem *pDecodedItem, QCBORTagListOut *pTagList);
+QCBORError QCBORDecode_GetNextWithTags(QCBORDecodeContext *pCtx, QCBORItem *pDecodedItem, QCBORTagListOut *pTagList);
 
 
 /**
@@ -1969,7 +1991,7 @@
 
  */
 
-int QCBORDecode_Finish(QCBORDecodeContext *pCtx);
+QCBORError QCBORDecode_Finish(QCBORDecodeContext *pCtx);
 
 
 
diff --git a/src/qcbor_decode.c b/src/qcbor_decode.c
index 78ecf9f..e9f50d4 100644
--- a/src/qcbor_decode.c
+++ b/src/qcbor_decode.c
@@ -96,7 +96,7 @@
 }
 
 // Process a break. This will either ascend the nesting or error out
-inline static int DecodeNesting_BreakAscend(QCBORDecodeNesting *pNesting)
+inline static QCBORError DecodeNesting_BreakAscend(QCBORDecodeNesting *pNesting)
 {
    // breaks must always occur when there is nesting
    if(!DecodeNesting_IsNested(pNesting)) {
@@ -140,9 +140,9 @@
 }
 
 // Called on every map/array
-inline static int DecodeNesting_Descend(QCBORDecodeNesting *pNesting, QCBORItem *pItem)
+inline static QCBORError DecodeNesting_Descend(QCBORDecodeNesting *pNesting, QCBORItem *pItem)
 {
-   int nReturn = QCBOR_SUCCESS;
+   QCBORError nReturn = QCBOR_SUCCESS;
    
    if(pItem->val.uCount == 0) {
       // Nothing to do for empty definite lenth arrays. They are just are
@@ -274,7 +274,7 @@
  This and the above functions could probably be optimized and made
  clearer and neater. 
  */
-static int TagMapper_Lookup(const QCBORTagListIn *pCallerConfiguredTagMap, uint64_t uTag, uint8_t *puTagBitIndex)
+static QCBORError TagMapper_Lookup(const QCBORTagListIn *pCallerConfiguredTagMap, uint64_t uTag, uint8_t *puTagBitIndex)
 {
    int nTagBitIndex = TagMapper_LookupBuiltIn(uTag);
    if(nTagBitIndex >= 0) {
@@ -346,10 +346,10 @@
    puAdditionalInfo -- Pass this along to know what kind of float or if length is indefinite
  
  */
-inline static int DecodeTypeAndNumber(UsefulInputBuf *pUInBuf, int *pnMajorType, uint64_t *puNumber, uint8_t *puAdditionalInfo)
+inline static QCBORError DecodeTypeAndNumber(UsefulInputBuf *pUInBuf, int *pnMajorType, uint64_t *puNumber, uint8_t *puAdditionalInfo)
 {
    // Stack usage: int/ptr 5 -- 40
-   int nReturn;
+   QCBORError nReturn;
    
    // Get the initial byte that every CBOR data item has
    const uint8_t InitialByte = UsefulInputBuf_GetByte(pUInBuf);
@@ -424,10 +424,10 @@
  See http://www.unix.org/whitepapers/64bit.html for reasons int isn't
  used here in any way including in the interface
  */
-inline static int DecodeInteger(int nMajorType, uint64_t uNumber, QCBORItem *pDecodedItem)
+inline static QCBORError DecodeInteger(int nMajorType, uint64_t uNumber, QCBORItem *pDecodedItem)
 {
    // Stack usage: int/ptr 1 -- 8
-   int nReturn = QCBOR_SUCCESS;
+   QCBORError nReturn = QCBOR_SUCCESS;
    
    if(nMajorType == CBOR_MAJOR_TYPE_POSITIVE_INT) {
       if (uNumber <= INT64_MAX) {
@@ -487,10 +487,10 @@
  Decode true, false, floats, break...
  */
 
-inline static int DecodeSimple(uint8_t uAdditionalInfo, uint64_t uNumber, QCBORItem *pDecodedItem)
+inline static QCBORError DecodeSimple(uint8_t uAdditionalInfo, uint64_t uNumber, QCBORItem *pDecodedItem)
 {
    // Stack usage: 0
-   int nReturn = QCBOR_SUCCESS;
+   QCBORError nReturn = QCBOR_SUCCESS;
    
    // uAdditionalInfo is 5 bits from the initial byte
    // compile time checks above make sure uAdditionalInfo values line up with uDataType values
@@ -548,10 +548,10 @@
 /*
  Decode text and byte strings. Call the string allocator if asked to.
  */
-inline static int DecodeBytes(const QCBORStringAllocator *pAlloc, int nMajorType, uint64_t uStrLen, UsefulInputBuf *pUInBuf, QCBORItem *pDecodedItem)
+inline static QCBORError DecodeBytes(const QCBORStringAllocator *pAlloc, int nMajorType, uint64_t uStrLen, UsefulInputBuf *pUInBuf, QCBORItem *pDecodedItem)
 {
    // Stack usage: UsefulBuf 2, int/ptr 1  40
-   int nReturn = QCBOR_SUCCESS;
+   QCBORError nReturn = QCBOR_SUCCESS;
    
    UsefulBufC Bytes = UsefulInputBuf_GetUsefulBuf(pUInBuf, uStrLen);
    if(UsefulBuf_IsNULLC(Bytes)) {
@@ -564,7 +564,7 @@
       // We are asked to use string allocator to make a copy
       UsefulBuf NewMem = pAlloc->fAllocate(pAlloc->pAllocaterContext, NULL, uStrLen);
       if(UsefulBuf_IsNULL(NewMem)) {
-         nReturn = QCBOR_ERR_STRING_ALLOC;
+         nReturn = QCBOR_ERR_STRING_ALLOCATE;
          goto Done;
       }
       pDecodedItem->val.string = UsefulBuf_Copy(NewMem, Bytes);
@@ -582,7 +582,7 @@
 /*
  Mostly just assign the right data type for the date string.
  */
-inline static int DecodeDateString(QCBORItem *pDecodedItem)
+inline static QCBORError DecodeDateString(QCBORItem *pDecodedItem)
 {
    // Stack Use: UsefulBuf 1 16
    if(pDecodedItem->uDataType != QCBOR_TYPE_TEXT_STRING) {
@@ -599,7 +599,7 @@
 /*
  Mostly just assign the right data type for the bignum.
  */
-inline static int DecodeBigNum(QCBORItem *pDecodedItem)
+inline static QCBORError DecodeBigNum(QCBORItem *pDecodedItem)
 {
    // Stack Use: UsefulBuf 1  -- 16
    if(pDecodedItem->uDataType != QCBOR_TYPE_BYTE_STRING) {
@@ -618,7 +618,7 @@
 static int DecodeDateEpoch(QCBORItem *pDecodedItem)
 {
    // Stack usage: 1
-   int nReturn = QCBOR_SUCCESS;
+   QCBORError nReturn = QCBOR_SUCCESS;
    
    pDecodedItem->val.epochDate.fSecondsFraction = 0;
    
@@ -677,10 +677,10 @@
  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, const QCBORStringAllocator *pAlloc)
+static QCBORError GetNext_Item(UsefulInputBuf *pUInBuf, QCBORItem *pDecodedItem, const QCBORStringAllocator *pAlloc)
 {
    // Stack usage: int/ptr 3 -- 24
-   int nReturn;
+   QCBORError nReturn;
    
    // Get the major type and the number. Number could be length of more bytes or the value depending on the major type
    // nAdditionalInfo is an encoding of the length of the uNumber and is needed to decode floats and doubles
@@ -757,10 +757,10 @@
  
  Code Reviewers: THIS FUNCTION DOES A LITTLE POINTER MATH
  */
-static inline int GetNext_FullItem(QCBORDecodeContext *me, QCBORItem *pDecodedItem)
+static inline QCBORError GetNext_FullItem(QCBORDecodeContext *me, QCBORItem *pDecodedItem)
 {
    // Stack usage; int/ptr 2 UsefulBuf 2 QCBORItem  -- 96
-   int nReturn;
+   QCBORError nReturn;
    QCBORStringAllocator *pAlloc = (QCBORStringAllocator *)me->pStringAllocator;
    UsefulBufC FullString = NULLUsefulBufC;
    
@@ -814,7 +814,7 @@
       // Match data type of chunk to type at beginning.
       // Also catches error of other non-string types that don't belong.
       if(StringChunkItem.uDataType != uStringType) {
-         nReturn = QCBOR_ERR_INDEFINITE_STRING_SEG;
+         nReturn = QCBOR_ERR_INDEFINITE_STRING_CHUNK;
          break;
       }
       
@@ -824,7 +824,7 @@
                                               FullString.len + StringChunkItem.val.string.len);
       if(UsefulBuf_IsNULL(NewMem)) {
          // Allocation of memory for the string failed
-         nReturn = QCBOR_ERR_STRING_ALLOC;
+         nReturn = QCBOR_ERR_STRING_ALLOCATE;
          break;
       }
       
@@ -846,10 +846,10 @@
  Returns an error if there was something wrong with the optional item or it couldn't
  be handled.
  */
-static int GetNext_TaggedItem(QCBORDecodeContext *me, QCBORItem *pDecodedItem, QCBORTagListOut *pTags)
+static QCBORError GetNext_TaggedItem(QCBORDecodeContext *me, QCBORItem *pDecodedItem, QCBORTagListOut *pTags)
 {
    // Stack usage: int/ptr: 3 -- 24
-   int       nReturn;
+   QCBORError nReturn;
    uint64_t  uTagBits = 0;
    if(pTags) {
       pTags->uNumUsed = 0;
@@ -919,7 +919,7 @@
       default:
          // Encountering some mixed up CBOR like something that
          // is tagged as both a string and integer date.
-         nReturn = QCBOR_ERR_BAD_OPT_TAG ;
+         nReturn = QCBOR_ERR_BAD_OPT_TAG;
    }
    
 Done:
@@ -930,10 +930,10 @@
 /*
  This layer takes care of map entries. It combines the label and data items into one QCBORItem.
  */
-static inline int GetNext_MapEntry(QCBORDecodeContext *me, QCBORItem *pDecodedItem, QCBORTagListOut *pTags)
+static inline QCBORError GetNext_MapEntry(QCBORDecodeContext *me, QCBORItem *pDecodedItem, QCBORTagListOut *pTags)
 {
    // Stack use: int/ptr 1, QCBORItem  -- 56
-   int nReturn = GetNext_TaggedItem(me, pDecodedItem, pTags);
+   QCBORError nReturn = GetNext_TaggedItem(me, pDecodedItem, pTags);
    if(nReturn)
       goto Done;
    
@@ -976,7 +976,7 @@
          // label is not an int or a string. It is an arrray
          // or a float or such and this implementation doesn't handle that.
          // Also, tags on labels are ignored.
-         nReturn = QCBOR_ERR_MAP_LABEL_TYPE ;
+         nReturn = QCBOR_ERR_MAP_LABEL_TYPE;
          goto Done;
       }
    }
@@ -989,13 +989,13 @@
 /*
  Public function, see header qcbor.h file
  */
-int QCBORDecode_GetNextWithTags(QCBORDecodeContext *me, QCBORItem *pDecodedItem, QCBORTagListOut *pTags)
+QCBORError QCBORDecode_GetNextWithTags(QCBORDecodeContext *me, QCBORItem *pDecodedItem, QCBORTagListOut *pTags)
 {
    // Stack ptr/int: 2, QCBORItem : 64
 
    // The public entry point for fetching and parsing the next QCBORItem.
    // All the CBOR parsing work is here and in subordinate calls.
-   int nReturn;
+   QCBORError nReturn;
    
    nReturn = GetNext_MapEntry(me, pDecodedItem, pTags);
    if(nReturn) {
@@ -1071,7 +1071,7 @@
 }
 
 
-int QCBORDecode_GetNext(QCBORDecodeContext *me, QCBORItem *pDecodedItem)
+QCBORError QCBORDecode_GetNext(QCBORDecodeContext *me, QCBORItem *pDecodedItem)
 {
    return QCBORDecode_GetNextWithTags(me, pDecodedItem, NULL);
 }
@@ -1134,7 +1134,7 @@
 /*
  Public function, see header qcbor.h file
  */
-int QCBORDecode_Finish(QCBORDecodeContext *me)
+QCBORError QCBORDecode_Finish(QCBORDecodeContext *me)
 {
    int nReturn = QCBOR_SUCCESS;
    
@@ -1242,10 +1242,10 @@
 }
 
 
-int QCBORDecode_SetMemPool(QCBORDecodeContext *me, UsefulBuf Pool, bool bAllStrings)
+QCBORError QCBORDecode_SetMemPool(QCBORDecodeContext *me, UsefulBuf Pool, bool bAllStrings)
 {
    if(Pool.len < sizeof(MemPool)+1) {
-      return 1;
+      return QCBOR_ERR_BUFFER_TOO_SMALL;
    }
    
    MemPool *pMP = (MemPool *)Pool.ptr;
@@ -1262,8 +1262,6 @@
    me->pStringAllocator = pMP;
    me->bStringAllocateAll = bAllStrings;
    
-   return 0;
+   return QCBOR_SUCCESS;
 }
 
-
-
diff --git a/src/qcbor_encode.c b/src/qcbor_encode.c
index 45dfb47..1ad89ba 100644
--- a/src/qcbor_encode.c
+++ b/src/qcbor_encode.c
@@ -84,9 +84,9 @@
    pNesting->pCurrentNesting->uMajorType = CBOR_MAJOR_TYPE_ARRAY;
 }
 
-inline static int Nesting_Increase(QCBORTrackNesting *pNesting, uint8_t uMajorType, uint32_t uPos)
+inline static QCBORError Nesting_Increase(QCBORTrackNesting *pNesting, uint8_t uMajorType, uint32_t uPos)
 {
-   int nReturn = QCBOR_SUCCESS;
+   QCBORError nReturn = QCBOR_SUCCESS;
    
    if(pNesting->pCurrentNesting == &pNesting->pArrays[QCBOR_MAX_ARRAY_NESTING]) {
       // trying to open one too many
@@ -105,7 +105,7 @@
    pNesting->pCurrentNesting--;
 }
 
-inline static int Nesting_Increment(QCBORTrackNesting *pNesting, uint16_t uAmount)
+inline static QCBORError Nesting_Increment(QCBORTrackNesting *pNesting, uint16_t uAmount)
 {
    if(uAmount >= QCBOR_MAX_ITEMS_IN_ARRAY - pNesting->pCurrentNesting->uCount) {
       return QCBOR_ERR_ARRAY_TOO_LONG;
@@ -554,7 +554,7 @@
 /*
  Public functions to finish and get the encoded result. See header qcbor.h
  */
-int QCBOREncode_Finish(QCBOREncodeContext *me, UsefulBufC *pEncodedCBOR)
+QCBORError QCBOREncode_Finish(QCBOREncodeContext *me, UsefulBufC *pEncodedCBOR)
 {
    if(me->uError)
       goto Done;
@@ -582,11 +582,11 @@
 }
 
 
-int QCBOREncode_FinishGetSize(QCBOREncodeContext *me, size_t *puEncodedLen)
+QCBORError QCBOREncode_FinishGetSize(QCBOREncodeContext *me, size_t *puEncodedLen)
 {
    UsefulBufC Enc;
    
-   int nReturn = QCBOREncode_Finish(me, &Enc);
+   QCBORError nReturn = QCBOREncode_Finish(me, &Enc);
    
    if(nReturn == QCBOR_SUCCESS) {
       *puEncodedLen = Enc.len;
diff --git a/test/qcbor_decode_tests.c b/test/qcbor_decode_tests.c
index 217a599..86c62bb 100644
--- a/test/qcbor_decode_tests.c
+++ b/test/qcbor_decode_tests.c
@@ -2276,7 +2276,7 @@
       return -9;
    }
    
-   if(QCBORDecode_GetNext(&DC, &Item) != QCBOR_ERR_INDEFINITE_STRING_SEG) {
+   if(QCBORDecode_GetNext(&DC, &Item) != QCBOR_ERR_INDEFINITE_STRING_CHUNK) {
       return -10;
    }
 
@@ -2294,7 +2294,7 @@
       return -13;
    }
    
-   if(QCBORDecode_GetNext(&DC, &Item) != QCBOR_ERR_INDEFINITE_STRING_SEG) {
+   if(QCBORDecode_GetNext(&DC, &Item) != QCBOR_ERR_INDEFINITE_STRING_CHUNK) {
       return -14;
    }
 
@@ -2351,7 +2351,7 @@
    if(Item.uDataType != QCBOR_TYPE_ARRAY) {
       return -23;
    }
-   if(QCBORDecode_GetNext(&DC, &Item) != QCBOR_ERR_STRING_ALLOC) {
+   if(QCBORDecode_GetNext(&DC, &Item) != QCBOR_ERR_STRING_ALLOCATE) {
       return -24;
    }
    
@@ -2492,7 +2492,7 @@
          }
       }
    }
-   if(nCBORError != QCBOR_ERR_STRING_ALLOC) {
+   if(nCBORError != QCBOR_ERR_STRING_ALLOCATE) {
       return -5;
    }