Improve cast fixes.
diff --git a/lib/zip.h b/lib/zip.h
index 04a391d..4ca9a77 100644
--- a/lib/zip.h
+++ b/lib/zip.h
@@ -148,7 +148,7 @@
 
 /* compression methods */
 
-#define ZIP_CM_DEFAULT	   65535  /* better of deflate or store */
+#define ZIP_CM_DEFAULT	      -1  /* better of deflate or store */
 #define ZIP_CM_STORE	       0  /* stored (uncompressed) */
 #define ZIP_CM_SHRINK	       1  /* shrunk */
 #define ZIP_CM_REDUCE_1	       2  /* reduced with factor 1 */
diff --git a/lib/zip_dirent.c b/lib/zip_dirent.c
index 40674c6..a429163 100644
--- a/lib/zip_dirent.c
+++ b/lib/zip_dirent.c
@@ -399,7 +399,7 @@
     zde->extra_fields = NULL;
     zde->comment = NULL;
 
-    size += (zip_uint32_t)filename_len+ef_len+comment_len;
+    size += (zip_uint32_t)filename_len+(zip_uint32_t)ef_len+(zip_uint32_t)comment_len;
 
     if (leftp && (*leftp < size)) {
 	zip_error_set(error, ZIP_ER_INCONS, 0);
@@ -739,7 +739,9 @@
     }
 
     _zip_put_16(&p, _zip_string_length(de->filename));
-    _zip_put_16(&p, (zip_uint16_t)(_zip_ef_size(de->extra_fields, flags) + _zip_ef_size(ef, ZIP_EF_BOTH)));
+    /* TODO: check for overflow */
+    zip_uint32_t ef_total_size = (zip_uint32_t)_zip_ef_size(de->extra_fields, flags) + (zip_uint32_t)_zip_ef_size(ef, ZIP_EF_BOTH);
+    _zip_put_16(&p, (zip_uint16_t)ef_total_size);
     
     if ((flags & ZIP_FL_LOCAL) == 0) {
 	_zip_put_16(&p, _zip_string_length(de->comment));
diff --git a/lib/zip_file_set_external_attributes.c b/lib/zip_file_set_external_attributes.c
index d8f580e..601335a 100644
--- a/lib/zip_file_set_external_attributes.c
+++ b/lib/zip_file_set_external_attributes.c
@@ -74,8 +74,7 @@
 	    e->changes = NULL;
 	}
 	else {
-	    e->changes->version_madeby = (zip_uint16_t)((unchanged_opsys << 8) | (e->changes->version_madeby & 0xff))
-;
+	    e->changes->version_madeby = (zip_uint16_t)((unchanged_opsys << 8) | (e->changes->version_madeby & 0xff));
 	    e->changes->ext_attrib = unchanged_attributes;
 	}
     }
diff --git a/lib/zip_source_stat.c b/lib/zip_source_stat.c
index c946993..34cb05f 100644
--- a/lib/zip_source_stat.c
+++ b/lib/zip_source_stat.c
@@ -59,9 +59,5 @@
 	return -1;
     }
 
-    if ((st->valid & ZIP_STAT_COMP_METHOD) && ZIP_CM_IS_DEFAULT(st->comp_method)) {
-	st->valid &= ~ZIP_STAT_COMP_METHOD;
-    }
-
     return 0;
 }
diff --git a/lib/zip_source_window.c b/lib/zip_source_window.c
index ef9c099..a8801c7 100644
--- a/lib/zip_source_window.c
+++ b/lib/zip_source_window.c
@@ -77,7 +77,7 @@
     zip_stat_init(&ctx->stat);
     zip_error_init(&ctx->error);
     ctx->supports = (zip_source_supports(src) & zip_source_make_command_bitmap(ZIP_SOURCE_OPEN, ZIP_SOURCE_READ, ZIP_SOURCE_CLOSE, ZIP_SOURCE_STAT, ZIP_SOURCE_ERROR, ZIP_SOURCE_FREE, ZIP_SOURCE_SEEK, ZIP_SOURCE_TELL, -1)) | (zip_source_make_command_bitmap(ZIP_SOURCE_TELL, -1));
-    ctx->needs_seek = (zip_int16_t)(ctx->supports & zip_source_make_command_bitmap(ZIP_SOURCE_SEEK, -1));
+    ctx->needs_seek = (ctx->supports & zip_source_make_command_bitmap(ZIP_SOURCE_SEEK, -1)) ? 1 : 0;
     
     if (st) {
         if (_zip_stat_merge(&ctx->stat, st, error) < 0) {
diff --git a/lib/zipint.h b/lib/zipint.h
index 46ec3cb..90f9d04 100644
--- a/lib/zipint.h
+++ b/lib/zipint.h
@@ -150,7 +150,7 @@
 #define BUFSIZE		8192
 #define EFZIP64SIZE 28
 
-#define ZIP_CM_REPLACED_DEFAULT 65534
+#define ZIP_CM_REPLACED_DEFAULT	(-2)
 
 #define ZIP_CM_IS_DEFAULT(x)	((x) == ZIP_CM_DEFAULT || (x) == ZIP_CM_REPLACED_DEFAULT)