diff --git a/ChangeLog b/ChangeLog
index 147e1a2b1dc672dd815fd58ef937e2a8f4e557c4..21650847092b9cf1ce7e9e262038b100d438ca79 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2017-01-??  Uwe Schulzweida
+
+        * using CGRIBEX library version 1.7.6
+	* Version 1.8.0 released
+
+2016-11-24  Uwe Schulzweida
+
+	* Version 1.8.0rc5 released
+
 2016-11-04  Uwe Schulzweida
 
 	* Version 1.8.0rc4 released
diff --git a/configure b/configure
index eb2ea8246391faa006ae1970f805ac02ee7b58cb..b73e50e8b98457676afdfcf62c304bf0897e85cd 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68 for cdi 1.8.0rc4.
+# Generated by GNU Autoconf 2.68 for cdi 1.8.0rc5.
 #
 # Report bugs to <http://mpimet.mpg.de/cdi>.
 #
@@ -570,8 +570,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='cdi'
 PACKAGE_TARNAME='cdi'
-PACKAGE_VERSION='1.8.0rc4'
-PACKAGE_STRING='cdi 1.8.0rc4'
+PACKAGE_VERSION='1.8.0rc5'
+PACKAGE_STRING='cdi 1.8.0rc5'
 PACKAGE_BUGREPORT='http://mpimet.mpg.de/cdi'
 PACKAGE_URL=''
 
@@ -1460,7 +1460,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures cdi 1.8.0rc4 to adapt to many kinds of systems.
+\`configure' configures cdi 1.8.0rc5 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1530,7 +1530,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of cdi 1.8.0rc4:";;
+     short | recursive ) echo "Configuration of cdi 1.8.0rc5:";;
    esac
   cat <<\_ACEOF
 
@@ -1723,7 +1723,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-cdi configure 1.8.0rc4
+cdi configure 1.8.0rc5
 generated by GNU Autoconf 2.68
 
 Copyright (C) 2010 Free Software Foundation, Inc.
@@ -2568,7 +2568,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by cdi $as_me 1.8.0rc4, which was
+It was created by cdi $as_me 1.8.0rc5, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   $ $0 $@
@@ -3520,7 +3520,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='cdi'
- VERSION='1.8.0rc4'
+ VERSION='1.8.0rc5'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -23389,7 +23389,7 @@ Usage: $0 [OPTIONS]
 Report bugs to <bug-libtool@gnu.org>."
 
 lt_cl_version="\
-cdi config.lt 1.8.0rc4
+cdi config.lt 1.8.0rc5
 configured by $0, generated by GNU Autoconf 2.68.
 
 Copyright (C) 2011 Free Software Foundation, Inc.
@@ -30522,7 +30522,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by cdi $as_me 1.8.0rc4, which was
+This file was extended by cdi $as_me 1.8.0rc5, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -30588,7 +30588,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-cdi config.status 1.8.0rc4
+cdi config.status 1.8.0rc5
 configured by $0, generated by GNU Autoconf 2.68,
   with options \\"\$ac_cs_config\\"
 
diff --git a/configure.ac b/configure.ac
index 6c575ac04af93c601ba635650c1f9ecd4d8cddd4..6e9951662482c9f527fdb613954ab5630fdf82f5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,7 @@
 #  autoconf 2.68
 #  libtool  2.4.2
 
-AC_INIT([cdi], [1.8.0rc4], [http://mpimet.mpg.de/cdi])
+AC_INIT([cdi], [1.8.0rc5], [http://mpimet.mpg.de/cdi])
 
 AC_DEFINE_UNQUOTED(CDI, ["$PACKAGE_VERSION"], [CDI version])
 
diff --git a/src/Makefile.in b/src/Makefile.in
index 234a5d46f45d3ac46d56f25594a163057b0e4ff5..be115a80ebafb926b136c7920686d5963e4ee8e5 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -941,8 +941,8 @@ distclean-generic:
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
 	@echo "it deletes files that may require special tools to rebuild."
-@ENABLE_CDI_LIB_FALSE@install-exec-local:
 @ENABLE_CDI_LIB_FALSE@uninstall-local:
+@ENABLE_CDI_LIB_FALSE@install-exec-local:
 clean: clean-am
 
 clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
diff --git a/src/cgribex.h b/src/cgribex.h
index 0f0f7134167ba0612d927ab4ceb286dae77edfd0..4b40906d40475589a664c9ff4da07072b55a70f2 100644
--- a/src/cgribex.h
+++ b/src/cgribex.h
@@ -226,7 +226,7 @@ void  gribPrintBDS(int nrec, long recpos, long recsize, unsigned char *gribbuffe
 void  gribCheck1(int nrec, long recpos, long recsize, unsigned char *gribbuffer);
 void  gribRepair1(int nrec, long recsize, unsigned char *gribbuffer);
 
-int   gribGetZip(long recsize, unsigned char *gribbuffer, long *urecsize);
+int   gribGetZip(size_t recsize, unsigned char *gribbuffer, size_t *urecsize);
 
 int   gribBzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufsize);
 int   gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufsize);
@@ -238,10 +238,10 @@ void  gribClose(int fileID);
 int   gribRead(int fileID, unsigned char *buffer, size_t *buffersize);
 int   gribWrite(int fileID, unsigned char *buffer, size_t buffersize);
 off_t gribGetPos(int fileID);
-int   gribGetSize(int fileID);
+size_t gribGetSize(int fileID);
 int   gribCheckSeek(int fileID, long *offset, int *version);
 int   gribFileSeek(int fileID, long *offset);
-int   gribReadSize(int fileID);
+size_t gribReadSize(int fileID);
 int   gribVersion(unsigned char *buffer, size_t buffersize);
 
 int   grib_info_for_grads(off_t recpos, long recsize, unsigned char *gribbuffer, int *intnum, float *fltnum, off_t *bignum);
diff --git a/src/cgribexlib.c b/src/cgribexlib.c
index 3e9c76036cb25d5bb8fdbe4038799ee2a8a05733..fba6850c0105f17fe8ceb0ddcff6064abfc99483 100644
--- a/src/cgribexlib.c
+++ b/src/cgribexlib.c
@@ -1,7 +1,7 @@
 
-/* Automatically generated by m214003 at 2016-06-03, do not edit */
+/* Automatically generated by m214003 at 2016-11-05, do not edit */
 
-/* CGRIBEXLIB_VERSION="1.7.5" */
+/* CGRIBEXLIB_VERSION="1.7.6" */
 
 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5) || defined (__clang__)
 #pragma GCC diagnostic push
@@ -3957,8 +3957,10 @@ read3ByteMSBFirst(void *fileptr)
   return (int)((b1 << 16) + (b2 << 8) + b3);
 }
 
-int gribReadSize(int fileID)
+
+size_t gribReadSize(int fileID)
 {
+  size_t rgribsize = 0;
   void *fileptr = filePtr(fileID);
   off_t pos = fileGetPos(fileID); 
 
@@ -4009,6 +4011,7 @@ int gribReadSize(int fileID)
       if ( CGRIBEX_Debug ) Message("bdssize     = %d", bdssize);
 
       gribsize = issize + pdssize + gdssize + bmssize + bdssize + essize;
+      rgribsize = (size_t) gribsize;
     }
   else if ( gribversion == 1 )
     {
@@ -4044,51 +4047,50 @@ int gribReadSize(int fileID)
 	  bdssize = correct_bdslen(bdssize, gribsize, issize+pdssize+gdssize+bmssize);
 	  if ( CGRIBEX_Debug ) Message("bdssize     = %d", bdssize);
 
-	  gribsize = issize+pdssize+gdssize+bmssize+bdssize+essize;
+	  gribsize = issize + pdssize + gdssize + bmssize + bdssize + essize;
 	}
+      rgribsize = (size_t) gribsize;
     }
   else if ( gribversion == 2 )
     {
-      int i;
       /* we set gribsize the following way because it doesn't matter then
 	 whether int is 4 or 8 bytes long - we don't have to care if the size
 	 really fits: if it does not, the record can not be read at all */
-      gribsize = 0;
-      for ( i = 0; i < 8; i++ ) gribsize = (gribsize << 8) | filePtrGetc(fileptr);
+      rgribsize = 0;
+      for ( int i = 0; i < 8; i++ ) rgribsize = (rgribsize << 8) | filePtrGetc(fileptr);
     }
   else
     {
-      gribsize = 0;
+      rgribsize = 0;
       Warning("GRIB version %d unsupported!", gribversion);
     }
 
-  if ( filePtrEOF(fileptr) ) gribsize = 0;
+  if ( filePtrEOF(fileptr) ) rgribsize = 0;
 
-  if ( CGRIBEX_Debug )
-    Message("gribsize    = %d", gribsize);
+  if ( CGRIBEX_Debug ) Message("gribsize = %zu", rgribsize);
 
   fileSetPos(fileID, pos, SEEK_SET);
 
-  return gribsize;
+  return rgribsize;
 }
 
 
-int gribGetSize(int fileID)
+size_t gribGetSize(int fileID)
 {
   long offset;
   int ierr = gribFileSeek(fileID, &offset); /* position file pointer after GRIB */
   if ( ierr > 0 )
     {
       Warning("GRIB record not found!");
-      return (0);
+      return 0;
     }
 
   if      ( ierr == -1 ) return 0;
   else if ( ierr ==  1 ) return 0;
 
-  int recSize = gribReadSize(fileID);
+  size_t recSize = gribReadSize(fileID);
 
-  if ( CGRIBEX_Debug ) Message("recsize = %d", recSize);
+  if ( CGRIBEX_Debug ) Message("recsize = %zu", recSize);
 
   fileSetPos(fileID, (off_t) -4, SEEK_CUR);
 
@@ -4109,7 +4111,7 @@ int gribRead(int fileID, unsigned char *buffer, size_t *buffersize)
   if      ( ierr == -1 ) { *buffersize = 0; return -1; }
   else if ( ierr ==  1 ) { *buffersize = 0; return -2; }
 
-  size_t recSize  = (size_t)gribReadSize(fileID);
+  size_t recSize  = gribReadSize(fileID);
   size_t readSize = recSize;
 
   if ( readSize > *buffersize )
@@ -6049,34 +6051,25 @@ void gribRepair1(int nrec, long recsize, unsigned char *gribbuffer)
 #  include "config.h"
 #endif
 
-#if  defined (HAVE_LIBSZ) || defined (HAVE_LIBAEC)
+#if  defined (HAVE_LIBSZ)
 #if defined(__cplusplus)
 extern "C" {
 #endif
-#if defined (HAVE_LIBAEC)
-#  include <libaec.h>
-#else
-#  include <szlib.h>
-#endif
+#include <szlib.h>
 #if defined (__cplusplus)
 }
 #endif
 
-#if defined (HAVE_LIBAEC)
-#  define AEC_FLAGS           (AEC_DATA_MSB | AEC_DATA_PREPROCESS)
-#else
-#  define OPTIONS_MASK        (SZ_RAW_OPTION_MASK | SZ_MSB_OPTION_MASK | SZ_NN_OPTION_MASK)
-#endif
+#define OPTIONS_MASK        (SZ_RAW_OPTION_MASK | SZ_MSB_OPTION_MASK | SZ_NN_OPTION_MASK)
 
-#  define PIXELS_PER_BLOCK    (8)
-#  define PIXELS_PER_SCANLINE (PIXELS_PER_BLOCK*128)
+#define PIXELS_PER_BLOCK    (8)
+#define PIXELS_PER_SCANLINE (PIXELS_PER_BLOCK*128)
 
-#  define MIN_COMPRESS        (0.95)
-#  define MIN_SIZE            (256)
+#define MIN_COMPRESS        (0.95)
+#define MIN_SIZE            (256)
 #endif
 
 #define  Z_SZIP  128
-#define  Z_AEC   130
 
 
 #define SetLen3(var, offset, value) ((var[offset+0] = 0xFF & (value >> 16)), \
@@ -6088,120 +6081,93 @@ extern "C" {
 				     (var[offset+3] = 0xFF & (value      )))
 
 
-int gribGetZip(long recsize, unsigned char *gribbuffer, long *urecsize)
+int gribGetZip(size_t recsize, unsigned char *gribbuffer, size_t *urecsize)
 {
-  /* urecsize : uncompressed record size  */
   int compress = 0;
-  int nerr;
-  /* int  bds_len, bds_nbits, lspherc, lcomplex; */
-  int bds_flag, lcompress;
-  long gribsize = 0;
   unsigned char *pds = NULL, *gds = NULL, *bms = NULL, *bds = NULL;
 
-  int gribversion = gribVersion(gribbuffer, (size_t)recsize);
+  int gribversion = gribVersion(gribbuffer, recsize);
 
-  if ( gribversion == 2 ) return (compress);
+  if ( gribversion == 2 ) return compress;
 
   long gribrecsize;
-  nerr = grib1Sections(gribbuffer, recsize, &pds, &gds, &bms, &bds, &gribrecsize);
+  int nerr = grib1Sections(gribbuffer, (long)recsize, &pds, &gds, &bms, &bds, &gribrecsize);
   if ( nerr < 0 )
     {
       fprintf(stdout, "GRIB message error\n");
-      return (compress);
+      return compress;
     }
 
   if ( nerr > 0 )
     {
       fprintf(stdout, "GRIB data corrupted!\n");
-      return (compress);
+      return compress;
     }
 
   /* bds_len   = BDS_Len; */
   /* bds_nbits = BDS_NumBits; */
-  bds_flag  = BDS_Flag;
+  int bds_flag  = BDS_Flag;
   /* lspherc   =  bds_flag >> 7; */
   /* lcomplex  = (bds_flag >> 6)&1; */
-  lcompress = (bds_flag >> 4)&1;
+  int lcompress = (bds_flag >> 4)&1;
 
-  *urecsize = 0;
+  size_t gribsize = 0;
   if ( lcompress )
     {
       compress = BDS_Z;
-      if ( compress == Z_SZIP || compress == Z_AEC )
-	{
-	  gribsize = gribrec_len(bds[14], bds[15], bds[16]);
-	}
+      if ( compress == Z_SZIP ) gribsize = (size_t) gribrec_len(bds[14], bds[15], bds[16]);
     }
 
   *urecsize = gribsize;
 
-  return (compress);
+  return compress;
 }
 
 
 int  gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufsize)
 {
-  int nerr;
-  int gribLen;
-  int rec_len;
-  int llarge = FALSE;
-#if ! (defined (HAVE_LIBSZ) || defined (HAVE_LIBAEC))
+#if ! defined(HAVE_LIBSZ)
   static int libszwarn = 1;
 #endif
   unsigned char *pds = NULL, *gds = NULL, *bms = NULL, *bds = NULL;
 
-  gribLen = gribrec_len(dbuf[4], dbuf[5], dbuf[6]);
-  if ( gribLen > JP23SET ) llarge = TRUE;
+  int gribLen = gribrec_len(dbuf[4], dbuf[5], dbuf[6]);
+  int llarge = (gribLen > JP23SET);
 
-  rec_len = gribLen;
+  int rec_len = gribLen;
 
   long gribrecsize;
-  nerr = grib1Sections(dbuf, dbufsize, &pds, &gds, &bms, &bds, &gribrecsize);
+  int nerr = grib1Sections(dbuf, dbufsize, &pds, &gds, &bms, &bds, &gribrecsize);
   if ( nerr < 0 )
     {
       fprintf(stdout, "GRIB message error\n");
-      return (rec_len);
+      return rec_len;
     }
 
   if ( nerr > 0 )
     {
       fprintf(stdout, "GRIB data corrupted!\n");
-      return (rec_len);
+      return rec_len;
     }
 
-#if  defined (HAVE_LIBSZ) || defined (HAVE_LIBAEC)
-
+#if  defined(HAVE_LIBSZ)
   {
-    long i;
-    int bdsLen;
     int gribLenOld = 0;
-    int status;
-    size_t datstart, datsize;
-#if defined (HAVE_LIBAEC)
-    struct aec_stream strm;
-#else
-    SZ_com_t sz_param;          /* szip parameter block */
-#endif
-    unsigned char *dest, *source;
-    size_t destLen, sourceLen;
-    int bits_per_sample;
-    int bds_len, bds_nbits, bds_flag, lspherc, lcomplex,/* lcompress,*/ bds_ubits;
     int bds_head = 11;
     int bds_ext = 0;
-    int bds_zoffset, bds_zstart;
     unsigned char *pbuf = NULL;
 
-    bds_zstart  = 14;
-    bds_zoffset = 12;
+    int bds_zstart  = 14;
+    int bds_zoffset = 12;
     if ( llarge ) bds_zoffset += 2;
 
-    bds_len   = BDS_Len;
+    int bds_len   = BDS_Len;
     bds_len   = correct_bdslen(bds_len, gribLen, bds-dbuf);
-    bds_nbits = BDS_NumBits;
-    bds_flag  = BDS_Flag;
-    bds_ubits = bds_flag & 15;
-    lspherc   =  bds_flag >> 7;
-    lcomplex  = (bds_flag >> 6)&1;
+    int bds_nbits = BDS_NumBits;
+    int bds_flag  = BDS_Flag;
+    int bds_ubits = bds_flag & 15;
+    int lspherc   =  bds_flag >> 7;
+    int lcomplex  = (bds_flag >> 6)&1;
     /* lcompress = (bds_flag >> 4)&1; */
     
     if ( bds_nbits != 8 && bds_nbits != 16 && bds_nbits != 24 && bds_nbits != 32 )
@@ -6212,36 +6178,23 @@ int  gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufs
 	    linfo = 0;
 	    fprintf(stderr, "GRIB szip only supports 8, 16, 24 and 32 bit data!\n");
 	  }
-	return (rec_len);
+	return rec_len;
       }
 
-#if defined (HAVE_LIBSZ)
-    if ( bds_nbits == 24 )
-      bits_per_sample    = 8;
-    else
-#endif
-      bits_per_sample    = bds_nbits;
+    int bits_per_sample = (bds_nbits == 24) ? 8 : bds_nbits;
 
-#if defined (HAVE_LIBAEC)
-    strm.bits_per_sample = bits_per_sample;
-    strm.block_size      = PIXELS_PER_BLOCK;
-    strm.rsi             = PIXELS_PER_SCANLINE / PIXELS_PER_BLOCK;
-    strm.flags           = AEC_FLAGS;
-    if ( bds_nbits == 24 ) strm.flags |= AEC_DATA_3BYTE; 
-#else
+    SZ_com_t sz_param;          /* szip parameter block */
     sz_param.options_mask        = OPTIONS_MASK;
     sz_param.bits_per_pixel      = bits_per_sample;
     sz_param.pixels_per_block    = PIXELS_PER_BLOCK;
     sz_param.pixels_per_scanline = PIXELS_PER_SCANLINE;
-#endif
 
     if ( lspherc )
       {
 	if ( lcomplex  )
 	  {
-	    int jup, ioff;
-	    jup  = bds[15];
-	    ioff = (jup+1)*(jup+2);
+	    int jup  = bds[15];
+	    int ioff = (jup+1)*(jup+2);
 	    bds_ext = 4 + 3 + 4*ioff;
 	  }
 	else
@@ -6250,27 +6203,25 @@ int  gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufs
 	  }
       }
 
-    datstart = bds_head + bds_ext;
+    size_t datstart = bds_head + bds_ext;
 
-    datsize = ((((bds_len - datstart)*8-bds_ubits)/bds_nbits)*bds_nbits)/8;
+    size_t datsize = ((((bds_len - datstart)*8-bds_ubits)/bds_nbits)*bds_nbits)/8;
 
-    if ( datsize < MIN_SIZE ) return (rec_len);
+    if ( datsize < MIN_SIZE ) return rec_len;
     /*
     fprintf(stderr, "%d %d %d %d\n", bds_len, datstart, bds_len - datstart, datsize);
     */
-    sourceLen = datsize;
-    destLen   = sbufsize;
+    size_t sourceLen = datsize;
+    size_t destLen   = sbufsize;
     
-    source = bds + datstart;
-    dest = sbuf;
+    unsigned char *source = bds + datstart;
+    unsigned char *dest = sbuf;
 
-#if defined (HAVE_LIBSZ)
     if ( bds_nbits == 24 )
       {
-	long nelem;
-	nelem = sourceLen/3;
+	long nelem = sourceLen/3;
 	pbuf = (unsigned char*) Malloc(sourceLen);
-	for ( i = 0; i < nelem; i++ )
+	for ( long i = 0; i < nelem; i++ )
 	  {
 	    pbuf[        i] = source[3*i  ];
 	    pbuf[  nelem+i] = source[3*i+1];
@@ -6278,24 +6229,8 @@ int  gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufs
 	  }
 	source = pbuf;
       }
-#endif
-
-#if defined (HAVE_LIBAEC)
-    strm.next_in = source;
-    strm.avail_in = sourceLen;
-    strm.next_out = dest;
-    strm.avail_out = destLen;
-
-    status = aec_buffer_encode(&strm);
-    if ( status != AEC_OK )
-      {
-       	if ( status != AEC_DATA_ERROR )
-	  Warning("AEC ERROR: %d code %3d level %3d", status, PDS_Parameter, PDS_Level2);
-      }
 
-    destLen = strm.total_out;
-#else
-    status = SZ_BufftoBuffCompress(dest, &destLen, source, sourceLen, &sz_param);
+    int status = SZ_BufftoBuffCompress(dest, &destLen, source, sourceLen, &sz_param);
     if ( status != SZ_OK )
       {
 	if ( status == SZ_NO_ENCODER_ERROR )
@@ -6309,7 +6244,6 @@ int  gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufs
 	else
 	  Warning("SZ ERROR: %d code %3d level %3d", status, PDS_Parameter, PDS_Level2);
       }
-#endif
     
     if ( pbuf ) Free(pbuf);
     /*
@@ -6327,7 +6261,7 @@ int  gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufs
 	gribLenOld = gribLen;
 
 	if ( bds_ext )
-	  for ( i = bds_ext-1; i >= 0; --i )
+	  for ( long i = bds_ext-1; i >= 0; --i )
 	    bds[bds_zoffset+bds_head+i] = bds[bds_head+i];
 
 	/*
@@ -6359,15 +6293,12 @@ int  gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufs
 	    SetLen3(bds, bds_zstart+6, destLen);
 	  }
 
-	bdsLen = datstart + bds_zoffset + destLen;
+	int bdsLen = datstart + bds_zoffset + destLen;
 
 	bds[11] = 0;
 	bds[12] = 0;
-#if defined (HAVE_LIBAEC)
-	BDS_Z   = Z_AEC;
-#else
+
 	BDS_Z   = Z_SZIP;
-#endif
 
 	BDS_Flag += 16;
 	if ( (bdsLen%2) == 1 )
@@ -6387,7 +6318,6 @@ int  gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufs
 
 	if ( llarge )
 	  {
-	    long itemp;
 	    long bdslen = gribLen - 4;
 
 	    /*
@@ -6400,7 +6330,7 @@ int  gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufs
 	    */
 	    while ( gribLen%120 ) dbuf[gribLen++] = 0;
 
-	    itemp = gribLen / (-120);
+	    long itemp = gribLen / (-120);
 	    itemp = JP23SET - itemp + 1;
 
 	    SetLen3(dbuf, 4, itemp);
@@ -6432,7 +6362,7 @@ int  gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufs
 
   if ( libszwarn )
     {
-      Warning("Compression disabled, szlib or libaec not available!");
+      Warning("Compression disabled, szlib not available!");
       libszwarn = 0;
     }
 #endif
@@ -6444,23 +6374,20 @@ int  gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufs
 
   rec_len = gribLen;
 
-  return (rec_len);
+  return rec_len;
 }
 
 
 int  gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufsize)
 {
-#if ! (defined (HAVE_LIBSZ) || defined (HAVE_LIBAEC))
+#if ! defined(HAVE_LIBSZ)
   static int libszwarn = 1;
 #endif
   unsigned char *pds = NULL, *gds = NULL, *bms = NULL, *bds = NULL;
   size_t gribLen = 0;
-  unsigned char *dest, *source;
   size_t destLen, sourceLen;
-  int /* bds_len, */ bds_nbits, bds_flag, lspherc, lcomplex /*, lcompress*/;
   enum { bds_head = 11 };
   int bds_ext = 0;
-  int bds_zoffset, bds_zstart;
   int llarge = FALSE;
 
   UNUSED(dbufsize);
@@ -6470,37 +6397,36 @@ int  gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
   if ( nerr < 0 )
     {
       fprintf(stdout, "GRIB message error\n");
-      return (0);
+      return 0;
     }
 
   if ( nerr > 0 )
     {
       fprintf(stdout, "GRIB data corrupted!\n");
-      return (0);
+      return 0;
     }
 
-  bds_zstart = 14;
+  int bds_zstart = 14;
 
   int recLen = gribrec_len(bds[bds_zstart], bds[bds_zstart+1], bds[bds_zstart+2]);
   if ( recLen > JP23SET ) llarge = TRUE;
 
-  bds_zoffset = 12;
+  int bds_zoffset = 12;
   if ( llarge ) bds_zoffset += 2;
 
   /* bds_len   = BDS_Len; */
-  bds_nbits = BDS_NumBits;
-  bds_flag  = BDS_Flag;
-  lspherc   =  bds_flag >> 7;
-  lcomplex  = (bds_flag >> 6)&1;
+  int bds_nbits = BDS_NumBits;
+  int bds_flag  = BDS_Flag;
+  int lspherc   =  bds_flag >> 7;
+  int lcomplex  = (bds_flag >> 6)&1;
   /* lcompress = (bds_flag >> 4)&1; */
 
   if ( lspherc )
     {
       if ( lcomplex  )
 	{
-	  int jup, ioff;
-	  jup  = bds[bds_zoffset+15];
-	  ioff = (jup+1)*(jup+2);
+	  int jup  = bds[bds_zoffset+15];
+	  int ioff = (jup+1)*(jup+2);
 	  bds_ext = 4 + 3 + 4*ioff;
 	}
       else
@@ -6511,7 +6437,7 @@ int  gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
 
   size_t datstart = bds_head + (size_t)bds_ext;
 
-  source = bds + datstart + bds_zoffset;
+  unsigned char *source = bds + datstart + bds_zoffset;
   if ( llarge )
     sourceLen = ((size_t) ((bds[21]<<24)+(bds[22]<<16)+(bds[23]<<8)+bds[24]));
   else
@@ -6521,16 +6447,16 @@ int  gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
   if ( nerr < 0 )
     {
       fprintf(stdout, "GRIB message error\n");
-      return (0);
+      return 0;
     }
 
   if ( nerr > 0 )
     {
       fprintf(stdout, "GRIB data corrupted!\n");
-      return (0);
+      return 0;
     }
 
-  dest = bds + datstart;
+  unsigned char *dest = bds + datstart;
   if ( llarge )
     destLen = ((size_t) ((bds[17]<<24)+(bds[18]<<16)+(bds[19]<<8)+bds[20]));
   else
@@ -6540,63 +6466,28 @@ int  gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
 
   size_t bdsLen = datstart + destLen;
 
-#if  defined (HAVE_LIBSZ) || defined (HAVE_LIBAEC)
+#if  defined(HAVE_LIBSZ)
   {
-    int status;
-    long i;
-    size_t tmpLen;
-    int bds_ubits;
-    int bits_per_sample;
-#if defined (HAVE_LIBAEC)
-    struct aec_stream strm;
-#else
-    SZ_com_t sz_param;          /* szip parameter block */
-#endif
-
-#if defined (HAVE_LIBSZ)
-    if ( bds_nbits == 24 )
-      bits_per_sample    = 8;
-    else
-#endif
-      bits_per_sample    = bds_nbits;
+    int bits_per_sample = (bds_nbits == 24) ? 8 : bds_nbits;
 
-#if defined (HAVE_LIBAEC)
-    strm.bits_per_sample         = bits_per_sample;
-    strm.block_size              = PIXELS_PER_BLOCK;
-    strm.rsi                     = PIXELS_PER_SCANLINE / PIXELS_PER_BLOCK;
-    strm.flags                   = AEC_FLAGS;
-    if ( bds_nbits == 24 ) strm.flags |= AEC_DATA_3BYTE; 
-#else
+    SZ_com_t sz_param;          /* szip parameter block */
     sz_param.options_mask        = OPTIONS_MASK;
     sz_param.bits_per_pixel      = bits_per_sample;
     sz_param.pixels_per_block    = PIXELS_PER_BLOCK;
     sz_param.pixels_per_scanline = PIXELS_PER_SCANLINE;
-#endif
 
     if ( bds_ext )
-      for ( i = 0; i < bds_ext; ++i )
+      for ( long i = 0; i < bds_ext; ++i )
 	bds[bds_head+i] = bds[bds_zoffset+bds_head+i];
 
-    /*
-    fprintf(stderr, "gribUnzip: sourceLen %ld; destLen %ld\n", (long)sourceLen, (long)destLen);
+    /*    fprintf(stderr, "gribUnzip: sourceLen %ld; destLen %ld\n", (long)sourceLen, (long)destLen);
     fprintf(stderr, "gribUnzip: sourceOff %d; destOff %d\n", bds[12], bds[11]);
     fprintf(stderr, "gribUnzip: reclen %d; bdslen %d\n", recLen, bdsLen);
     */
 
-    tmpLen = destLen;
-#if defined (HAVE_LIBAEC)
-    strm.next_in   = source;
-    strm.avail_in  = sourceLen;
-    strm.next_out  = dest;
-    strm.avail_out = tmpLen;
-
-    status = aec_buffer_decode(&strm);
-    if ( status != AEC_OK )
-      Warning("AEC ERROR: %d code %3d level %3d", status, PDS_Parameter, PDS_Level2);
+    size_t tmpLen = destLen;
 
-    tmpLen = strm.total_out;
-#else
-    status = SZ_BufftoBuffDecompress(dest, &tmpLen, source, sourceLen, &sz_param);
+    int status = SZ_BufftoBuffDecompress(dest, &tmpLen, source, sourceLen, &sz_param);
     if ( status != SZ_OK )
       {
 	if ( status == SZ_NO_ENCODER_ERROR )
@@ -6610,7 +6501,6 @@ int  gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
 	else
 	  Warning("SZ ERROR: %d code %3d level %3d", status, PDS_Parameter, PDS_Level2);
       }
-#endif
     /*
     fprintf(stderr, "gribUnzip: sl = %ld  dl = %ld   tl = %ld\n",
 	    (long)sourceLen, (long)destLen,(long) tmpLen);
@@ -6619,14 +6509,11 @@ int  gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
       Warning("unzip size differ: code %3d level %3d  ibuflen %ld ubuflen %ld",
 	      PDS_Parameter, PDS_Level2, (long) destLen, (long) tmpLen);
 
-#if defined (HAVE_LIBSZ)
     if ( bds_nbits == 24 )
       {
-	long nelem;
-	unsigned char *pbuf;
-	nelem = tmpLen/3;
-	pbuf = (unsigned char*) Malloc(tmpLen);
-	for ( i = 0; i < nelem; i++ )
+	long nelem = tmpLen/3;
+	unsigned char *pbuf = (unsigned char*) Malloc(tmpLen);
+	for ( long i = 0; i < nelem; i++ )
 	  {
 	    pbuf[3*i  ] = dest[        i];
 	    pbuf[3*i+1] = dest[  nelem+i];
@@ -6635,9 +6522,8 @@ int  gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
 	memcpy(dest, pbuf, tmpLen);
 	Free(pbuf);
       }
-#endif
 
-    bds_ubits = BDS_Flag & 15;
+    int bds_ubits = BDS_Flag & 15;
     BDS_Flag -= bds_ubits;
 
     if ( (bdsLen%2) == 1 )
@@ -6705,7 +6591,7 @@ int  gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
   
   if ( libszwarn )
     {
-      Warning("Decompression disabled, szlib or libaec not available!");
+      Warning("Decompression disabled, szlib not available!");
       libszwarn = 0;
     }
 #endif
@@ -11222,7 +11108,7 @@ void encodeES(GRIBPACK *lGrib, long *gribLen, long bdsstart)
 
       if ( z > JP23SET*120 )
 	{
-	  fprintf(stderr, "Abort: GRIB record too large (max = %d)!\n", JP23SET*120);
+	  fprintf(stderr, "Abort: GRIB1 record too large (size = %ld; max = %d)!\n", z, JP23SET*120);
 	  exit(1);
 	}
 
@@ -13823,7 +13709,7 @@ void encode_dummy(void)
   (void) encode_array_unrolled_double(0, 0, 0, NULL, NULL, 0, 0, NULL);
   (void) encode_array_unrolled_float(0, 0, 0, NULL, NULL, 0, 0, NULL);
 }
-static const char grb_libvers[] = "1.7.5" " of ""Jun  3 2016"" ""14:44:00";
+static const char grb_libvers[] = "1.7.6" " of ""Nov  5 2016"" ""11:59:02";
 const char *
 cgribexLibraryVersion(void)
 {
diff --git a/src/grb_read.c b/src/grb_read.c
index 418dbb161507e6f87f78be47b52868c308356010..2c1bc98070949ba31215e6c062c29ab4ed5f23dd 100644
--- a/src/grb_read.c
+++ b/src/grb_read.c
@@ -65,12 +65,12 @@ int grbUnzipRecord(void *gribbuffer, size_t *gribsize)
 {
   int zip = 0;
   int izip;
-  long unzipsize;
+  size_t unzipsize;
 
   size_t igribsize = *gribsize;
   size_t ogribsize = *gribsize;
 
-  if ( (izip = gribGetZip((long)igribsize, (unsigned char *)gribbuffer, &unzipsize)) > 0 )
+  if ( (izip = gribGetZip(igribsize, (unsigned char *)gribbuffer, &unzipsize)) > 0 )
     {
       zip = izip;
       if ( izip == 128 ) /* szip */
@@ -78,9 +78,9 @@ int grbUnzipRecord(void *gribbuffer, size_t *gribsize)
 	  unsigned char *itmpbuffer = NULL;
 	  size_t itmpbuffersize = 0;
 
-	  if ( unzipsize < (long) igribsize )
+	  if ( unzipsize < igribsize )
 	    {
-	      fprintf(stderr, "Decompressed size smaller than compressed size (in %ld; out %ld)!\n", (long)igribsize, unzipsize);
+	      fprintf(stderr, "Decompressed size smaller than compressed size (in %zu; out %zu)!\n", igribsize, unzipsize);
 	      return 0;
 	    }
 
@@ -94,7 +94,7 @@ int grbUnzipRecord(void *gribbuffer, size_t *gribsize)
 
 	  unzipsize += 100; /* need 0 to 1 bytes for rounding of bds */
 
-	  ogribsize = (size_t)gribUnzip((unsigned char *)gribbuffer, unzipsize, itmpbuffer, (long)igribsize);
+	  ogribsize = (size_t)gribUnzip((unsigned char *)gribbuffer, (long)unzipsize, itmpbuffer, (long)igribsize);
 
 	  Free(itmpbuffer);
 
diff --git a/src/grb_write.c b/src/grb_write.c
index a76b9b8b6397b1644560f4ff3fc1270bb7bfcf6f..647763558859d2471fa4ae1e10c2b86db8bcf432 100644
--- a/src/grb_write.c
+++ b/src/grb_write.c
@@ -118,8 +118,8 @@ void grbCopyRecord(stream_t * streamptr2, stream_t * streamptr1)
 
   if ( filetype == CDI_FILETYPE_GRB )
     {
-      long unzipsize;
-      int izip = gribGetZip((long)recsize, gribbuffer, &unzipsize);
+      size_t unzipsize;
+      int izip = gribGetZip(recsize, gribbuffer, &unzipsize);
 
       if ( izip == 0 && streamptr2->comptype == CDI_COMPRESS_SZIP )
           nbytes = grbSzip(filetype, gribbuffer, nbytes);
diff --git a/src/stream_cdf_o.c b/src/stream_cdf_o.c
index 4d565f1bd9b18b7114511a15fa9d79af988de49d..cf2f6ba35304862129e4cf2e08e56caa3803fd50 100644
--- a/src/stream_cdf_o.c
+++ b/src/stream_cdf_o.c
@@ -433,35 +433,38 @@ void cdfDefFC(stream_t *streamptr, int gridID, int gridindex)
 
 static const struct cdfDefGridAxisInqs {
   int (*axisSize)(int gridID);
+  int (*axisDimname)(int cdiID, int key, int size, char *mesg);
   int (*axisName)(int cdiID, int key, int size, char *mesg);
-  void (*axisStdname)(int cdiID, char *dimstdname);
   int (*axisLongname)(int cdiID, int key, int size, char *mesg);
-  void (*axisUnits)(int cdiID, char *dimunits);
+  int (*axisUnits)(int cdiID, int key, int size, char *mesg);
+  void (*axisStdname)(int cdiID, char *dimstdname);
   double (*axisVal)(int gridID, int index);
   const double *(*axisValsPtr)(int gridID);
   const double *(*axisBoundsPtr)(int gridID);
 } gridInqsX = {
   .axisSize = gridInqXsize,
+  .axisDimname = cdiGridInqKeyStr,
   .axisName = cdiGridInqKeyStr,
-  .axisStdname = gridInqXstdname,
   .axisLongname = cdiGridInqKeyStr,
-  .axisUnits = gridInqXunits,
+  .axisUnits = cdiGridInqKeyStr,
+  .axisStdname = gridInqXstdname,
   .axisVal = gridInqXval,
   .axisValsPtr = gridInqXvalsPtr,
   .axisBoundsPtr = gridInqXboundsPtr,
 }, gridInqsY = {
   .axisSize = gridInqYsize,
+  .axisDimname = cdiGridInqKeyStr,
   .axisName = cdiGridInqKeyStr,
-  .axisStdname = gridInqYstdname,
   .axisLongname = cdiGridInqKeyStr,
-  .axisUnits = gridInqYunits,
+  .axisUnits = cdiGridInqKeyStr,
+  .axisStdname = gridInqYstdname,
   .axisVal = gridInqYval,
   .axisValsPtr = gridInqYvalsPtr,
   .axisBoundsPtr = gridInqYboundsPtr,
 }, gridInqsZ = {
-  .axisStdname = zaxisInqStdname,
   .axisLongname = cdiZaxisInqKeyStr,
-  .axisUnits = zaxisInqUnits,
+  .axisUnits = cdiZaxisInqKeyStr,
+  .axisStdname = zaxisInqStdname,
 };
 
 static
@@ -477,12 +480,13 @@ void cdfPutGridStdAtts(int fileID, int ncvarid, int gridID, int dimtype, const s
   char longname[CDI_MAX_NAME]; longname[0] = 0;
   int keyname = (dimtype == 'Z') ? CDI_KEY_LONGNAME : (dimtype == 'X') ? CDI_KEY_XLONGNAME : CDI_KEY_YLONGNAME;
   inqs->axisLongname(gridID, keyname, CDI_MAX_NAME, longname);
-  if ( (len = strlen(longname)) )
+  if ( longname[0] && (len = strlen(longname)) )
     cdf_put_att_text(fileID, ncvarid, "long_name", len, longname);
 
-  char units[CDI_MAX_NAME];
-  inqs->axisUnits(gridID, units);
-  if ( (len = strlen(units)) )
+  char units[CDI_MAX_NAME]; units[0] = 0;
+  keyname = (dimtype == 'Z') ? CDI_KEY_UNITS : (dimtype == 'X') ? CDI_KEY_XUNITS : CDI_KEY_YUNITS;
+  inqs->axisUnits(gridID, keyname, CDI_MAX_NAME, units);
+  if ( units[0] && (len = strlen(units)) )
     cdf_put_att_text(fileID, ncvarid, "units", len, units);
 }
 
@@ -656,6 +660,10 @@ cdfDefAxisCommon(stream_t *streamptr, int gridID, int gridindex, int ndims,
 
   ncgrid_t *ncgrid = streamptr->ncgrid;
 
+  const double *pvals = gridAxisInq->axisValsPtr(gridID);
+  char dimname[CDI_MAX_NAME+3]; dimname[0] = 0;
+  if ( ndims && pvals == NULL ) cdiGridInqKeyStr(gridID, dimKey, CDI_MAX_NAME, dimname);
+
   for ( int index = 0; index < gridindex; ++index )
     {
       int gridID0 = ncgrid[index].gridID;
@@ -668,16 +676,16 @@ cdfDefAxisCommon(stream_t *streamptr, int gridID, int gridindex, int ndims,
            gridtype0 == GRID_GENERIC )
         {
           size_t dimlen0 = (size_t)gridAxisInq->axisSize(gridID0);
-          if ( dimlen == dimlen0 )
+          char dimname0[CDI_MAX_NAME]; dimname0[0] = 0;
+          if ( dimname[0] ) cdiGridInqKeyStr(gridID0, dimKey, CDI_MAX_NAME, dimname0);
+          bool lname = dimname0[0] ? strcmp(dimname, dimname0) == 0 : true;
+          if ( dimlen == dimlen0 && lname )
             {
               double (*inqVal)(int gridID, int index) = gridAxisInq->axisVal;
               if ( IS_EQUAL(inqVal(gridID0, 0), inqVal(gridID, 0)) &&
                    IS_EQUAL(inqVal(gridID0, (int)dimlen-1), inqVal(gridID, (int)dimlen-1)) )
                 {
-                  if ( dimKey == CDI_KEY_XDIMNAME )
-                    dimID = ncgrid[index].xdimID;
-                  else
-                    dimID = ncgrid[index].ydimID;
+                  dimID = (dimKey == CDI_KEY_XDIMNAME) ? ncgrid[index].xdimID : ncgrid[index].ydimID;
                   break;
                 }
             }
@@ -686,8 +694,6 @@ cdfDefAxisCommon(stream_t *streamptr, int gridID, int gridindex, int ndims,
 
   if ( dimID == CDI_UNDEFID )
     {
-      const double *pvals = gridAxisInq->axisValsPtr(gridID);
-
       char axisname[CDI_MAX_NAME]; axisname[0] = 0;
       int keyname = (axisLetter == 'X') ? CDI_KEY_XNAME : CDI_KEY_YNAME;
       gridAxisInq->axisName(gridID, keyname, CDI_MAX_NAME, axisname);
@@ -704,11 +710,6 @@ cdfDefAxisCommon(stream_t *streamptr, int gridID, int gridindex, int ndims,
 
       if ( ndims )
         {
-          char dimname[CDI_MAX_NAME+3]; dimname[0] = 0;
-
-          if ( pvals == NULL )
-            cdiGridInqKeyStr(gridID, dimKey, CDI_MAX_NAME, dimname);
-
           if ( dimname[0] == 0 ) strcpy(dimname, extendedAxisname);
           dimID = checkDimName(fileID, dimlen, dimname);
 
diff --git a/src/stream_cgribex.c b/src/stream_cgribex.c
index 02dcb07d776bf496274fbe2444ffdf9c089c277d..1433ed583a81b57374961315dc53a4cbb4c04e69 100644
--- a/src/stream_cgribex.c
+++ b/src/stream_cgribex.c
@@ -327,7 +327,7 @@ void cgribexGetGrid(stream_t *streamptr, int *isec2, int *isec4, grid_t *grid, i
 
 static
 void cgribexAddRecord(stream_t * streamptr, int param, int *isec1, int *isec2, double *fsec2, double *fsec3,
-		      int *isec4, long recsize, off_t position, int datatype, int comptype, int lmv, int iret)
+		      int *isec4, size_t recsize, off_t position, int datatype, int comptype, int lmv, int iret)
 {
   int varID;
   int levelID = 0;
@@ -345,7 +345,7 @@ void cgribexAddRecord(stream_t * streamptr, int param, int *isec1, int *isec2, d
 
   /* fprintf(stderr, "param %d %d %d %d\n", param, level1, level2, ISEC1_LevelType); */
 
-  record->size      = (size_t)recsize;
+  record->size      = recsize;
   record->position  = position;
   record->param     = param;
   record->ilevel    = level1;
@@ -579,7 +579,7 @@ int cgribexScanTimestep1(stream_t * streamptr)
   unsigned nrecords, recID;
   int nrecs_scanned = 0;
   int datatype;
-  long recsize = 0;
+  size_t recsize = 0;
   bool warn_time = true;
   bool warn_numavg = true;
   int taxisID = -1;
@@ -587,7 +587,7 @@ int cgribexScanTimestep1(stream_t * streamptr)
   bool fcast = false;
   int vlistID;
   int comptype;
-  long unzipsize;
+  size_t unzipsize;
   char paramstr[32];
   int nskip = cdiSkipRecords;
 
@@ -631,13 +631,13 @@ int cgribexScanTimestep1(stream_t * streamptr)
 	  streamptr->ntsteps = 1;
 	  break;
 	}
-      if ( (size_t)recsize > buffersize )
+      if ( recsize > buffersize )
 	{
-	  buffersize = (size_t)recsize;
+	  buffersize = recsize;
 	  gribbuffer = Realloc(gribbuffer, buffersize);
 	}
 
-      readsize = (size_t)recsize;
+      readsize = recsize;
       rstatus = gribRead(fileID, (unsigned char *)gribbuffer, &readsize);
       if ( rstatus ) break;
 
@@ -646,9 +646,9 @@ int cgribexScanTimestep1(stream_t * streamptr)
 	{
 	  comptype = CDI_COMPRESS_SZIP;
 	  unzipsize += 100; /* need 0 to 1 bytes for rounding of bds */
-	  if ( buffersize < (size_t)unzipsize )
+	  if ( buffersize < unzipsize )
 	    {
-	      buffersize = (size_t)unzipsize;
+	      buffersize = unzipsize;
 	      gribbuffer = Realloc(gribbuffer, buffersize);
 	    }
 	}
@@ -776,7 +776,7 @@ int cgribexScanTimestep1(stream_t * streamptr)
     streamptr->tsteps[0].recIDs[recID] = (int)recID;
 
   streamptr->record->buffer     = gribbuffer;
-  streamptr->record->buffersize = (size_t)buffersize;
+  streamptr->record->buffersize = buffersize;
 
   cgribexScanTsFixNtsteps(streamptr, recpos);
   cgribexScanTsConstAdjust(streamptr, taxis);
@@ -797,10 +797,10 @@ int cgribexScanTimestep2(stream_t * streamptr)
   int varID, gridID;
   size_t readsize;
   int nrecs, recID;
-  long recsize = 0;
+  size_t recsize = 0;
   bool warn_numavg = true;
   int tsteptype;
-  long unzipsize;
+  size_t unzipsize;
   char paramstr[32];
 
   streamptr->curTsID = 1;
@@ -854,22 +854,22 @@ int cgribexScanTimestep2(stream_t * streamptr)
 	  streamptr->ntsteps = 2;
 	  break;
 	}
-      if ( (size_t)recsize > buffersize )
+      if ( recsize > buffersize )
 	{
-	  buffersize = (size_t)recsize;
+	  buffersize = recsize;
 	  gribbuffer = Realloc(gribbuffer, buffersize);
 	}
 
-      readsize = (size_t)recsize;
+      readsize = recsize;
       rstatus = gribRead(fileID, (unsigned char *)gribbuffer, &readsize);
       if ( rstatus ) break;
 
       if ( gribGetZip(recsize, (unsigned char *)gribbuffer, &unzipsize) > 0 )
 	{
 	  unzipsize += 100; /* need 0 to 1 bytes for rounding of bds */
-	  if ( buffersize < (size_t)unzipsize )
+	  if ( buffersize < unzipsize )
 	    {
-	      buffersize = (size_t)unzipsize;
+	      buffersize = unzipsize;
 	      gribbuffer = Realloc(gribbuffer, buffersize);
 	    }
 	}
@@ -974,7 +974,7 @@ int cgribexScanTimestep2(stream_t * streamptr)
       if ( CDI_Debug )
 	Message("Read record %2d (id=%s lev1=%d lev2=%d) %8d %6d", nrecs_scanned, paramstr, level1, level2, vdate, vtime);
 
-      streamptr->tsteps[tsID].records[recID].size = (size_t)recsize;
+      streamptr->tsteps[tsID].records[recID].size = recsize;
 
       if ( cgribexVarCompare(compVar, streamptr->tsteps[tsID].records[recID], 0) != 0 )
 	{
@@ -1034,7 +1034,7 @@ int cgribexScanTimestep(stream_t * streamptr)
   int rstatus = 0;
   double fsec2[512], fsec3[2], *fsec4 = NULL;
   int lmv = 0, iret = 0;
-  long recsize = 0;
+  size_t recsize = 0;
   off_t recpos = 0;
   void *gribbuffer;
   size_t buffersize = 0;
@@ -1048,7 +1048,7 @@ int cgribexScanTimestep(stream_t * streamptr)
   int taxisID = -1;
   int rindex, nrecs = 0;
   int nrecs_scanned;
-  long unzipsize;
+  size_t unzipsize;
   char paramstr[32];
 
   /*
@@ -1100,15 +1100,15 @@ int cgribexScanTimestep(stream_t * streamptr)
 	      streamptr->ntsteps = streamptr->rtsteps + 1;
 	      break;
 	    }
-	  if ( recsize > 0 && (size_t)recsize > buffersize )
+	  if ( recsize > 0 && recsize > buffersize )
 	    {
-	      buffersize = (size_t)recsize;
+	      buffersize = recsize;
 	      gribbuffer = Realloc(gribbuffer, buffersize);
 	    }
 
 	  if ( rindex >= nrecs ) break;
 
-	  readsize = (size_t)recsize;
+	  readsize = recsize;
 	  rstatus = gribRead(fileID, (unsigned char *)gribbuffer, &readsize);
 	  if ( rstatus )
 	    {
@@ -1120,9 +1120,9 @@ int cgribexScanTimestep(stream_t * streamptr)
 	  if ( gribGetZip(recsize, (unsigned char *)gribbuffer, &unzipsize) > 0 )
 	    {
 	      unzipsize += 100; /* need 0 to 1 bytes for rounding of bds */
-	      if ( buffersize < (size_t)unzipsize )
+	      if ( buffersize < unzipsize )
 		{
-		  buffersize = (size_t)unzipsize;
+		  buffersize = unzipsize;
 		  gribbuffer = Realloc(gribbuffer, buffersize);
 		}
 	    }
@@ -1242,7 +1242,7 @@ int cgribexScanTimestep(stream_t * streamptr)
 	    }
 
 	  streamptr->tsteps[tsID].records[recID].position = recpos;
-	  streamptr->tsteps[tsID].records[recID].size = (size_t)recsize;
+	  streamptr->tsteps[tsID].records[recID].size = recsize;
 
 	  rindex++;
 	}
diff --git a/src/stream_gribapi.c b/src/stream_gribapi.c
index 0494854ea3f24a9022236665926e9e151f5d2731..c5e69b5f271d3943f0ba8560092f8b0048f770ff 100644
--- a/src/stream_gribapi.c
+++ b/src/stream_gribapi.c
@@ -692,7 +692,7 @@ void ensureBufferSize(size_t requiredSize, size_t *curSize, void **buffer)
 }
 
 static
-grib_handle *gribapiGetDiskRepresentation(size_t recsize, size_t *buffersize, void **gribbuffer, int *outDatatype, int *outCompressionType, long *outUnzipsize)
+grib_handle *gribapiGetDiskRepresentation(size_t recsize, size_t *buffersize, void **gribbuffer, int *outDatatype, int *outCompressionType, size_t *outUnzipsize)
 {
   bool lieee = false;
 
@@ -712,10 +712,10 @@ grib_handle *gribapiGetDiskRepresentation(size_t recsize, size_t *buffersize, vo
     }
   else
     {
-      if( gribGetZip((long)recsize, *gribbuffer, outUnzipsize) > 0 )
+      if( gribGetZip(recsize, *gribbuffer, outUnzipsize) > 0 )
         {
           *outCompressionType = CDI_COMPRESS_SZIP;
-          ensureBufferSize((size_t)*outUnzipsize + 100, buffersize, gribbuffer);
+          ensureBufferSize(*outUnzipsize + 100, buffersize, gribbuffer);
         }
       else
         {
@@ -804,8 +804,8 @@ int gribapiScanTimestep1(stream_t * streamptr)
   while ( TRUE )
     {
       int level1 = 0, level2 = 0;
-      size_t recsize = (size_t)gribGetSize(fileID);
-      recpos  = fileGetPos(fileID);
+      size_t recsize = gribGetSize(fileID);
+      recpos = fileGetPos(fileID);
 
       if ( recsize == 0 )
         {
@@ -819,7 +819,7 @@ int gribapiScanTimestep1(stream_t * streamptr)
       if ( rstatus ) break;
 
       int datatype, comptype = 0;
-      long unzipsize;
+      size_t unzipsize;
       gh = gribapiGetDiskRepresentation(recsize, &buffersize, &gribbuffer, &datatype, &comptype, &unzipsize);
 
       nrecs_scanned++;
@@ -1027,8 +1027,8 @@ int gribapiScanTimestep2(stream_t * streamptr)
     {
       if ( rindex > nrecords ) break;
 
-      size_t recsize = (size_t)gribGetSize(fileID);
-      recpos  = fileGetPos(fileID);
+      size_t recsize = gribGetSize(fileID);
+      recpos = fileGetPos(fileID);
       if ( recsize == 0 )
 	{
 	  streamptr->ntsteps = 2;
@@ -1040,9 +1040,9 @@ int gribapiScanTimestep2(stream_t * streamptr)
       rstatus = gribRead(fileID, gribbuffer, &readsize);
       if ( rstatus ) break;
 
-      long unzipsize;
-      if ( gribGetZip((long)recsize, gribbuffer, &unzipsize) > 0 )
-        ensureBufferSize((size_t)unzipsize + 100, &buffersize, &gribbuffer);
+      size_t unzipsize;
+      if ( gribGetZip(recsize, gribbuffer, &unzipsize) > 0 )
+        ensureBufferSize(unzipsize + 100, &buffersize, &gribbuffer);
 
       nrecs_scanned++;
       gh = grib_handle_new_from_message(NULL, gribbuffer, recsize);
@@ -1248,8 +1248,8 @@ int gribapiScanTimestep(stream_t * streamptr)
 	{
 	  if ( rindex > nrecs ) break;
 
-	  size_t recsize = (size_t)gribGetSize(fileID);
-	  recpos  = fileGetPos(fileID);
+	  size_t recsize = gribGetSize(fileID);
+	  recpos = fileGetPos(fileID);
 	  if ( recsize == 0 )
 	    {
 	      streamptr->ntsteps = streamptr->rtsteps + 1;
@@ -1268,9 +1268,9 @@ int gribapiScanTimestep(stream_t * streamptr)
 	      break;
 	    }
 
-          long unzipsize;
-	  if ( gribGetZip((long)recsize, gribbuffer, &unzipsize) > 0 )
-            ensureBufferSize((size_t)unzipsize + 100, &buffersize, &gribbuffer);
+          size_t unzipsize;
+	  if ( gribGetZip(recsize, gribbuffer, &unzipsize) > 0 )
+            ensureBufferSize(unzipsize + 100, &buffersize, &gribbuffer);
 
           nrecs_scanned++;
 	  gh = grib_handle_new_from_message(NULL, gribbuffer, recsize);