Merge pull request #209 from apache/cleanup_warnings

Cleanup warnings
diff --git a/common/include/MurmurHash3.h b/common/include/MurmurHash3.h
index c1cbeab..2ca72a6 100644
--- a/common/include/MurmurHash3.h
+++ b/common/include/MurmurHash3.h
@@ -76,7 +76,7 @@
 // Block read - if your platform needs to do endian-swapping or can only
 // handle aligned reads, do the conversion here
 
-FORCE_INLINE uint64_t getblock64 ( const uint64_t * p, int i )
+FORCE_INLINE uint64_t getblock64 ( const uint64_t * p, size_t i )
 {
   return p[i];
 }
@@ -95,7 +95,7 @@
   return k;
 }
 
-FORCE_INLINE void MurmurHash3_x64_128(const void* key, int lenBytes, uint64_t seed, HashState& out) {
+FORCE_INLINE void MurmurHash3_x64_128(const void* key, size_t lenBytes, uint64_t seed, HashState& out) {
   static const uint64_t c1 = BIG_CONSTANT(0x87c37b91114253d5);
   static const uint64_t c2 = BIG_CONSTANT(0x4cf5ad432745937f);
 
@@ -106,13 +106,13 @@
 
   // Number of full 128-bit blocks of 16 bytes.
   // Possible exclusion of a remainder of up to 15 bytes.
-  const int nblocks = lenBytes >> 4; // bytes / 16 
+  const size_t nblocks = lenBytes >> 4; // bytes / 16 
 
   // Process the 128-bit blocks (the body) into the hash
   const uint64_t* blocks = (const uint64_t*)(data);
-  for (int i = 0; i < nblocks; ++i) { // 16 bytes per block
-    uint64_t k1 = getblock64(blocks,i*2+0);
-    uint64_t k2 = getblock64(blocks,i*2+1);
+  for (size_t i = 0; i < nblocks; ++i) { // 16 bytes per block
+    uint64_t k1 = getblock64(blocks, i * 2 + 0);
+    uint64_t k2 = getblock64(blocks, i * 2 + 1);
 
     k1 *= c1; k1  = ROTL64(k1,31); k1 *= c2; out.h1 ^= k1;
     out.h1 = ROTL64(out.h1,27);
diff --git a/common/include/binomial_bounds.hpp b/common/include/binomial_bounds.hpp
index 0f0222a..c1243e5 100644
--- a/common/include/binomial_bounds.hpp
+++ b/common/include/binomial_bounds.hpp
@@ -381,7 +381,7 @@
   // The following computes an approximation to the lower bound of a Frequentist
   // confidence interval based on the tails of the Binomial distribution.
   static double compute_approx_binomial_lower_bound(unsigned long long num_samples, double theta, unsigned num_std_devs) {
-    if (theta == 1) return num_samples;
+    if (theta == 1) return static_cast<double>(num_samples);
     if (num_samples == 0) return 0;
     if (num_samples == 1) {
       const double delta = delta_of_num_std_devs[num_std_devs];
@@ -395,24 +395,24 @@
     }
     // at this point we know 2 <= num_samples <= 120
     if (theta > (1 - 1e-5)) { // empirically-determined threshold
-      return num_samples;
+      return static_cast<double>(num_samples);
     }
     if (theta < (num_samples / 360.0)) { // empirically-determined threshold
       // here we use the Gaussian approximation, but with a modified num_std_devs
-      const unsigned index = 3 * num_samples + (num_std_devs - 1);
+      const unsigned index = 3 * static_cast<unsigned>(num_samples) + (num_std_devs - 1);
       const double raw_lb = cont_classic_lb(num_samples, theta, lb_equiv_table[index]);
       return raw_lb - 0.5; // fake round down
     }
     // This is the most difficult range to approximate; we will compute an "exact" LB.
     // We know that est <= 360, so specialNStar() shouldn't be ridiculously slow.
     const double delta = delta_of_num_std_devs[num_std_devs];
-    return special_n_star(num_samples, theta, delta); // no need to round
+    return static_cast<double>(special_n_star(num_samples, theta, delta)); // no need to round
   }
 
   // The following computes an approximation to the upper bound of a Frequentist
   // confidence interval based on the tails of the Binomial distribution.
   static double compute_approx_binomial_upper_bound(unsigned long long num_samples, double theta, unsigned num_std_devs) {
-    if (theta == 1) return num_samples;
+    if (theta == 1) return static_cast<double>(num_samples);
     if (num_samples == 0) {
       const double delta = delta_of_num_std_devs[num_std_devs];
       const double raw_ub = std::log(delta) / std::log(1 - theta);
@@ -425,18 +425,18 @@
     }
     // at this point we know 2 <= num_samples <= 120
     if (theta > (1 - 1e-5)) { // empirically-determined threshold
-      return num_samples + 1;
+      return static_cast<double>(num_samples + 1);
     }
     if (theta < (num_samples / 360.0)) { // empirically-determined threshold
       // here we use the Gaussian approximation, but with a modified num_std_devs
-      const unsigned index = 3 * num_samples + (num_std_devs - 1);
+      const unsigned index = 3 * static_cast<unsigned>(num_samples) + (num_std_devs - 1);
       const double raw_ub = cont_classic_ub(num_samples, theta, ub_equiv_table[index]);
       return raw_ub + 0.5; // fake round up
     }
     // This is the most difficult range to approximate; we will compute an "exact" UB.
     // We know that est <= 360, so specialNPrimeF() shouldn't be ridiculously slow.
     const double delta = delta_of_num_std_devs[num_std_devs];
-    return special_n_prime_f(num_samples, theta, delta); // no need to round
+    return static_cast<double>(special_n_prime_f(num_samples, theta, delta)); // no need to round
   }
 
   static void check_theta(double theta) {
diff --git a/common/include/bounds_binomial_proportions.hpp b/common/include/bounds_binomial_proportions.hpp
index 06ab484..abfe8db 100644
--- a/common/include/bounds_binomial_proportions.hpp
+++ b/common/include/bounds_binomial_proportions.hpp
@@ -110,14 +110,14 @@
    * @return the lower bound of the approximate Clopper-Pearson confidence interval for the
    * unknown success probability.
    */
-  static inline double approximate_lower_bound_on_p(long n, long k, double num_std_devs) {
+  static inline double approximate_lower_bound_on_p(uint64_t n, uint64_t k, double num_std_devs) {
     check_inputs(n, k);
     if (n == 0) { return 0.0; } // the coin was never flipped, so we know nothing
     else if (k == 0) { return 0.0; }
     else if (k == 1) { return (exact_lower_bound_on_p_k_eq_1(n, delta_of_num_stdevs(num_std_devs))); }
     else if (k == n) { return (exact_lower_bound_on_p_k_eq_n(n, delta_of_num_stdevs(num_std_devs))); }
     else {
-      double x = abramowitz_stegun_formula_26p5p22((n - k) + 1, k, (-1.0 * num_std_devs));
+      double x = abramowitz_stegun_formula_26p5p22((n - k) + 1.0, static_cast<double>(k), (-1.0 * num_std_devs));
       return (1.0 - x); // which is p
     }
   }
@@ -145,18 +145,18 @@
    * @return the upper bound of the approximate Clopper-Pearson confidence interval for the
    * unknown success probability.
    */
-  static inline double approximate_upper_bound_on_p(long n, long k, double num_std_devs) {
+  static inline double approximate_upper_bound_on_p(uint64_t n, uint64_t k, double num_std_devs) {
     check_inputs(n, k);
     if (n == 0) { return 1.0; } // the coin was never flipped, so we know nothing
     else if (k == n) { return 1.0; }
     else if (k == (n - 1)) {
-      return (exactU_upper_bound_on_p_k_eq_minusone(n, delta_of_num_stdevs(num_std_devs)));
+      return (exact_upper_bound_on_p_k_eq_minusone(n, delta_of_num_stdevs(num_std_devs)));
     }
     else if (k == 0) {
       return (exact_upper_bound_on_p_k_eq_zero(n, delta_of_num_stdevs(num_std_devs)));
     }
     else {
-      double x = abramowitz_stegun_formula_26p5p22(n - k, k + 1, num_std_devs);
+      double x = abramowitz_stegun_formula_26p5p22(static_cast<double>(n - k), k + 1.0, num_std_devs);
       return (1.0 - x); // which is p
     }
   }
@@ -167,7 +167,7 @@
    * @param k is the number of successes. Must be non-negative, and cannot exceed n.
    * @return the estimate of the unknown binomial proportion.
    */
-  static inline double estimate_unknown_p(long n, long k) {
+  static inline double estimate_unknown_p(uint64_t n, uint64_t k) {
     check_inputs(n, k);
     if (n == 0) { return 0.5; } // the coin was never flipped, so we know nothing
     else { return ((double) k / (double) n); }
@@ -193,9 +193,7 @@
   }
 
 private:
-  static inline void check_inputs(long n, long k) {
-    if (n < 0) { throw std::invalid_argument("N must be non-negative"); }
-    if (k < 0) { throw std::invalid_argument("K must be non-negative"); }
+  static inline void check_inputs(uint64_t n, uint64_t k) {
     if (k > n) { throw std::invalid_argument("K cannot exceed N"); }
   }
 
@@ -251,8 +249,7 @@
   // and it is worth keeping it that way so that it will always be easy to verify
   // that the formula was typed in correctly.
 
-  static inline double abramowitz_stegun_formula_26p5p22(double a, double b,
-      double yp) {
+  static inline double abramowitz_stegun_formula_26p5p22(double a, double b, double yp) {
     const double b2m1 = (2.0 * b) - 1.0;
     const double a2m1 = (2.0 * a) - 1.0;
     const double lambda = ((yp * yp) - 3.0) / 6.0;
@@ -268,19 +265,19 @@
 
   // Formulas for some special cases.
 
-  static inline double exact_upper_bound_on_p_k_eq_zero(double n, double delta) {
+  static inline double exact_upper_bound_on_p_k_eq_zero(uint64_t n, double delta) {
     return (1.0 - pow(delta, (1.0 / n)));
   }
 
-  static inline double exact_lower_bound_on_p_k_eq_n(double n, double delta) {
+  static inline double exact_lower_bound_on_p_k_eq_n(uint64_t n, double delta) {
     return (pow(delta, (1.0 / n)));
   }
 
-  static inline double exact_lower_bound_on_p_k_eq_1(double n, double delta) {
+  static inline double exact_lower_bound_on_p_k_eq_1(uint64_t n, double delta) {
     return (1.0 - pow((1.0 - delta), (1.0 / n)));
   }
 
-  static inline double exactU_upper_bound_on_p_k_eq_minusone(double n, double delta) {
+  static inline double exact_upper_bound_on_p_k_eq_minusone(uint64_t n, double delta) {
     return (pow((1.0 - delta), (1.0 / n)));
   }
 
diff --git a/common/include/count_zeros.hpp b/common/include/count_zeros.hpp
index 0c9f6b4..cdd9940 100644
--- a/common/include/count_zeros.hpp
+++ b/common/include/count_zeros.hpp
@@ -94,7 +94,7 @@
 static inline uint8_t count_trailing_zeros_in_u32(uint32_t input) {
   for (int i = 0; i < 4; i++) {
     const int byte = input & 0xff;
-    if (byte != 0) return (i << 3) + byte_trailing_zeros_table[byte];
+    if (byte != 0) return static_cast<uint8_t>((i << 3) + byte_trailing_zeros_table[byte]);
     input >>= 8;
   }
   return 32;
@@ -103,7 +103,7 @@
 static inline uint8_t count_trailing_zeros_in_u64(uint64_t input) {
   for (int i = 0; i < 8; i++) {
     const int byte = input & 0xff;
-    if (byte != 0) return (i << 3) + byte_trailing_zeros_table[byte];
+    if (byte != 0) return static_cast<uint8_t>((i << 3) + byte_trailing_zeros_table[byte]);
     input >>= 8;
   }
   return 64;
diff --git a/common/include/serde.hpp b/common/include/serde.hpp
index 73e0901..9b3349b 100644
--- a/common/include/serde.hpp
+++ b/common/include/serde.hpp
@@ -51,7 +51,7 @@
     bool failure = false;
     try {
       os.write(reinterpret_cast<const char*>(items), sizeof(T) * num);
-    } catch (std::ostream::failure& e) {
+    } catch (std::ostream::failure&) {
       failure = true;
     }
     if (failure || !os.good()) {
@@ -62,7 +62,7 @@
     bool failure = false;
     try {
       is.read((char*)items, sizeof(T) * num);
-    } catch (std::istream::failure& e) {
+    } catch (std::istream::failure&) {
       failure = true;
     }
     if (failure || !is.good()) {
@@ -99,11 +99,11 @@
     bool failure = false;
     try {
       for (; i < num && os.good(); i++) {
-        uint32_t length = items[i].size();
+        uint32_t length = static_cast<uint32_t>(items[i].size());
         os.write((char*)&length, sizeof(length));
         os.write(items[i].c_str(), length);
       }
-    } catch (std::ostream::failure& e) {
+    } catch (std::ostream::failure&) {
       failure = true;
     }
     if (failure || !os.good()) {
@@ -121,12 +121,12 @@
         std::string str;
         str.reserve(length);
         for (uint32_t j = 0; j < length; j++) {
-          str.push_back(is.get());
+          str.push_back(static_cast<char>(is.get()));
         }
         if (!is.good()) { break; }
         new (&items[i]) std::string(std::move(str));
       }
-    } catch (std::istream::failure& e) {
+    } catch (std::istream::failure&) {
       failure = true;
     }
     if (failure || !is.good()) {
@@ -143,7 +143,7 @@
   size_t serialize(void* ptr, size_t capacity, const std::string* items, unsigned num) const {
     size_t bytes_written = 0;
     for (unsigned i = 0; i < num; ++i) {
-      const uint32_t length = items[i].size();
+      const uint32_t length = static_cast<uint32_t>(items[i].size());
       const size_t new_bytes = length + sizeof(length);
       check_memory_size(bytes_written + new_bytes, capacity);
       memcpy(ptr, &length, sizeof(length));
diff --git a/cpc/include/cpc_compressor.hpp b/cpc/include/cpc_compressor.hpp
index 73db797..a8f426f 100644
--- a/cpc/include/cpc_compressor.hpp
+++ b/cpc/include/cpc_compressor.hpp
@@ -48,44 +48,44 @@
 class cpc_compressor {
 public:
   void compress(const cpc_sketch_alloc<A>& source, compressed_state<A>& target) const;
-  void uncompress(const compressed_state<A>& source, uncompressed_state<A>& target, uint8_t lg_k, uint64_t num_coupons) const;
+  void uncompress(const compressed_state<A>& source, uncompressed_state<A>& target, uint8_t lg_k, uint32_t num_coupons) const;
 
   // methods below are public for testing
 
   // This returns the number of compressed words that were actually used. It is the caller's
   // responsibility to ensure that the compressed_words array is long enough to prevent over-run.
-  size_t low_level_compress_bytes(
+  uint32_t low_level_compress_bytes(
       const uint8_t* byte_array, // input
-      size_t num_bytes_to_encode,
+      uint32_t num_bytes_to_encode,
       const uint16_t* encoding_table,
       uint32_t* compressed_words  // output
   ) const;
 
   void low_level_uncompress_bytes(
       uint8_t* byte_array, // output
-      size_t num_bytes_to_decode,
+      uint32_t num_bytes_to_decode,
       const uint16_t* decoding_table,
       const uint32_t* compressed_words,
-      size_t num_compressed_words // input
+      uint32_t num_compressed_words // input
   ) const;
 
   // Here "pairs" refers to row-column pairs that specify
   // the positions of surprising values in the bit matrix.
 
   // returns the number of compressedWords actually used
-  size_t low_level_compress_pairs(
+  uint32_t low_level_compress_pairs(
       const uint32_t* pair_array, // input
-      size_t num_pairs_to_encode,
-      size_t num_base_bits,
+      uint32_t num_pairs_to_encode,
+      uint8_t num_base_bits,
       uint32_t* compressed_words // output
   ) const;
 
   void low_level_uncompress_pairs(
       uint32_t* pair_array, // output
-      size_t num_pairs_to_decode,
-      size_t num_base_bits,
+      uint32_t num_pairs_to_decode,
+      uint8_t num_base_bits,
       const uint32_t* compressed_words, // input
-      size_t num_compressed_words // input
+      uint32_t num_compressed_words // input
   ) const;
 
 private:
@@ -122,22 +122,22 @@
   void uncompress_pinned_flavor(const compressed_state<A>& source, uncompressed_state<A>& target, uint8_t lg_k, uint32_t num_coupons) const;
   void uncompress_sliding_flavor(const compressed_state<A>& source, uncompressed_state<A>& target, uint8_t lg_k, uint32_t num_coupons) const;
 
-  uint8_t* make_inverse_permutation(const uint8_t* permu, int length);
-  uint16_t* make_decoding_table(const uint16_t* encoding_table, int num_byte_values);
+  uint8_t* make_inverse_permutation(const uint8_t* permu, unsigned length);
+  uint16_t* make_decoding_table(const uint16_t* encoding_table, unsigned num_byte_values);
   void validate_decoding_table(const uint16_t* decoding_table, const uint16_t* encoding_table) const;
 
   void compress_surprising_values(const vector_u32<A>& pairs, uint8_t lg_k, compressed_state<A>& result) const;
   void compress_sliding_window(const uint8_t* window, uint8_t lg_k, uint32_t num_coupons, compressed_state<A>& target) const;
 
-  vector_u32<A> uncompress_surprising_values(const uint32_t* data, size_t data_words, size_t num_pairs, uint8_t lg_k, const A& allocator) const;
-  void uncompress_sliding_window(const uint32_t* data, size_t data_words, vector_u8<A>& window, uint8_t lg_k, uint32_t num_coupons) const;
+  vector_u32<A> uncompress_surprising_values(const uint32_t* data, uint32_t data_words, uint32_t num_pairs, uint8_t lg_k, const A& allocator) const;
+  void uncompress_sliding_window(const uint32_t* data, uint32_t data_words, vector_u8<A>& window, uint8_t lg_k, uint32_t num_coupons) const;
 
-  static size_t safe_length_for_compressed_pair_buf(uint64_t k, size_t num_pairs, size_t num_base_bits);
-  static size_t safe_length_for_compressed_window_buf(uint64_t k);
-  static uint8_t determine_pseudo_phase(uint8_t lg_k, uint64_t c);
+  static size_t safe_length_for_compressed_pair_buf(uint32_t k, uint32_t num_pairs, uint8_t num_base_bits);
+  static size_t safe_length_for_compressed_window_buf(uint32_t k);
+  static uint8_t determine_pseudo_phase(uint8_t lg_k, uint32_t c);
 
   static inline vector_u32<A> tricky_get_pairs_from_window(const uint8_t* window, uint32_t k, uint32_t num_pairs_to_get, uint32_t empty_space, const A& allocator);
-  static inline uint64_t golomb_choose_number_of_base_bits(uint64_t k, uint64_t count);
+  static inline uint8_t golomb_choose_number_of_base_bits(uint32_t k, uint64_t count);
 };
 
 } /* namespace datasketches */
diff --git a/cpc/include/cpc_compressor_impl.hpp b/cpc/include/cpc_compressor_impl.hpp
index e3398c8..c49bf0a 100644
--- a/cpc/include/cpc_compressor_impl.hpp
+++ b/cpc/include/cpc_compressor_impl.hpp
@@ -49,12 +49,12 @@
 }
 
 template<typename A>
-uint8_t* cpc_compressor<A>::make_inverse_permutation(const uint8_t* permu, int length) {
+uint8_t* cpc_compressor<A>::make_inverse_permutation(const uint8_t* permu, unsigned length) {
   uint8_t* inverse = new uint8_t[length]; // use new for global initialization
-  for (int i = 0; i < length; i++) {
-    inverse[permu[i]] = i;
+  for (unsigned i = 0; i < length; i++) {
+    inverse[permu[i]] = static_cast<uint8_t>(i);
   }
-  for (int i = 0; i < length; i++) {
+  for (unsigned i = 0; i < length; i++) {
     if (permu[inverse[i]] != i) throw std::logic_error("inverse permutation error");
   }
   return inverse;
@@ -64,17 +64,17 @@
    of length at most 12, this builds a size-4096 decoding table */
 // The second argument is typically 256, but can be other values such as 65.
 template<typename A>
-uint16_t* cpc_compressor<A>::make_decoding_table(const uint16_t* encoding_table, int num_byte_values) {
+uint16_t* cpc_compressor<A>::make_decoding_table(const uint16_t* encoding_table, unsigned num_byte_values) {
   uint16_t* decoding_table = new uint16_t[4096]; // use new for global initialization
-  for (int byte_value = 0; byte_value < num_byte_values; byte_value++) {
-    const int encoding_entry = encoding_table[byte_value];
-    const int code_value = encoding_entry & 0xfff;
-    const int code_length = encoding_entry >> 12;
-    const int decoding_entry = (code_length << 8) | byte_value;
-    const int garbage_length = 12 - code_length;
-    const int num_copies = 1 << garbage_length;
-    for (int garbage_bits = 0; garbage_bits < num_copies; garbage_bits++) {
-      const int extended_code_value = code_value | (garbage_bits << code_length);
+  for (unsigned byte_value = 0; byte_value < num_byte_values; byte_value++) {
+    const uint16_t encoding_entry = encoding_table[byte_value];
+    const uint16_t code_value = encoding_entry & 0xfff;
+    const uint8_t code_length = encoding_entry >> 12;
+    const uint16_t decoding_entry = static_cast<uint16_t>((code_length << 8) | byte_value);
+    const uint8_t garbage_length = 12 - code_length;
+    const uint32_t num_copies = 1 << garbage_length;
+    for (uint32_t garbage_bits = 0; garbage_bits < num_copies; garbage_bits++) {
+      const uint16_t extended_code_value = static_cast<uint16_t>(code_value | (garbage_bits << code_length));
       decoding_table[extended_code_value & 0xfff] = decoding_entry;
     }
   }
@@ -157,7 +157,7 @@
 }
 
 template<typename A>
-void cpc_compressor<A>::uncompress(const compressed_state<A>& source, uncompressed_state<A>& target, uint8_t lg_k, uint64_t num_coupons) const {
+void cpc_compressor<A>::uncompress(const compressed_state<A>& source, uncompressed_state<A>& target, uint8_t lg_k, uint32_t num_coupons) const {
   switch (cpc_sketch_alloc<A>::determine_flavor(lg_k, num_coupons)) {
     case cpc_sketch_alloc<A>::flavor::EMPTY:
       target.table = u32_table<A>(2, 6 + lg_k, source.table_data.get_allocator());
@@ -202,16 +202,17 @@
 void cpc_compressor<A>::compress_hybrid_flavor(const cpc_sketch_alloc<A>& source, compressed_state<A>& result) const {
   if (source.sliding_window.size() == 0) throw std::logic_error("no sliding window");
   if (source.window_offset != 0) throw std::logic_error("window_offset != 0");
-  const size_t k = 1 << source.get_lg_k();
+  const uint32_t k = 1 << source.get_lg_k();
   vector_u32<A> pairs_from_table = source.surprising_value_table.unwrapping_get_items();
-  if (pairs_from_table.size() > 0) u32_table<A>::introspective_insertion_sort(pairs_from_table.data(), 0, pairs_from_table.size());
-  const size_t num_pairs_from_window = source.get_num_coupons() - pairs_from_table.size(); // because the window offset is zero
+  const uint32_t num_pairs_from_table = static_cast<uint32_t>(pairs_from_table.size());
+  if (num_pairs_from_table > 0) u32_table<A>::introspective_insertion_sort(pairs_from_table.data(), 0, num_pairs_from_table);
+  const uint32_t num_pairs_from_window = source.get_num_coupons() - num_pairs_from_table; // because the window offset is zero
 
-  vector_u32<A> all_pairs = tricky_get_pairs_from_window(source.sliding_window.data(), k, num_pairs_from_window, pairs_from_table.size(), source.get_allocator());
+  vector_u32<A> all_pairs = tricky_get_pairs_from_window(source.sliding_window.data(), k, num_pairs_from_window, num_pairs_from_table, source.get_allocator());
 
   u32_table<A>::merge(
       pairs_from_table.data(), 0, pairs_from_table.size(),
-      all_pairs.data(), pairs_from_table.size(), num_pairs_from_window,
+      all_pairs.data(), num_pairs_from_table, num_pairs_from_window,
       all_pairs.data(), 0
   );  // note the overlapping subarray trick
 
@@ -228,15 +229,15 @@
   // In the hybrid flavor, some of these pairs actually
   // belong in the window, so we will separate them out,
   // moving the "true" pairs to the bottom of the array.
-  const size_t k = 1 << lg_k;
+  const uint32_t k = 1 << lg_k;
   target.window.resize(k, 0); // important: zero the memory
-  size_t next_true_pair = 0;
-  for (size_t i = 0; i < source.table_num_entries; i++) {
+  uint32_t next_true_pair = 0;
+  for (uint32_t i = 0; i < source.table_num_entries; i++) {
     const uint32_t row_col = pairs[i];
     if (row_col == UINT32_MAX) throw std::logic_error("empty marker is not expected");
     const uint8_t col = row_col & 63;
     if (col < 8) {
-      const size_t row = row_col >> 6;
+      const uint32_t row = row_col >> 6;
       target.window[row] |= 1 << col; // set the window bit
     } else {
       pairs[next_true_pair++] = row_col; // move true pair down
@@ -270,7 +271,7 @@
     uint8_t lg_k, uint32_t num_coupons) const {
   if (source.window_data.size() == 0) throw std::logic_error("window is expected");
   uncompress_sliding_window(source.window_data.data(), source.window_data_words, target.window, lg_k, num_coupons);
-  const size_t num_pairs = source.table_num_entries;
+  const uint32_t num_pairs = source.table_num_entries;
   if (num_pairs == 0) {
     target.table = u32_table<A>(2, 6 + lg_k, source.table_data.get_allocator());
   } else {
@@ -278,7 +279,7 @@
     vector_u32<A> pairs = uncompress_surprising_values(source.table_data.data(), source.table_data_words, num_pairs,
         lg_k, source.table_data.get_allocator());
     // undo the compressor's 8-column shift
-    for (size_t i = 0; i < num_pairs; i++) {
+    for (uint32_t i = 0; i < num_pairs; i++) {
       if ((pairs[i] & 63) >= 56) throw std::logic_error("(pairs[i] & 63) >= 56");
       pairs[i] += 8;
     }
@@ -302,7 +303,7 @@
 
     for (size_t i = 0; i < pairs.size(); i++) {
       const uint32_t row_col = pairs[i];
-      const size_t row = row_col >> 6;
+      const uint32_t row = row_col >> 6;
       uint8_t col = row_col & 63;
       // first rotate the columns into a canonical configuration: new = ((old - (offset+8)) + 64) mod 64
       col = (col + 56 - offset) & 63;
@@ -322,7 +323,7 @@
     uint8_t lg_k, uint32_t num_coupons) const {
   if (source.window_data.size() == 0) throw std::logic_error("window is expected");
   uncompress_sliding_window(source.window_data.data(), source.window_data_words, target.window, lg_k, num_coupons);
-  const size_t num_pairs = source.table_num_entries;
+  const uint32_t num_pairs = source.table_num_entries;
   if (num_pairs == 0) {
     target.table = u32_table<A>(2, 6 + lg_k, source.table_data.get_allocator());
   } else {
@@ -337,9 +338,9 @@
     uint8_t offset = cpc_sketch_alloc<A>::determine_correct_offset(lg_k, num_coupons);
     if (offset > 56) throw std::out_of_range("offset out of range");
 
-    for (size_t i = 0; i < num_pairs; i++) {
+    for (uint32_t i = 0; i < num_pairs; i++) {
       const uint32_t row_col = pairs[i];
-      const size_t row = row_col >> 6;
+      const uint32_t row = row_col >> 6;
       uint8_t col = row_col & 63;
       // first undo the permutation
       col = permutation[col];
@@ -354,25 +355,26 @@
 
 template<typename A>
 void cpc_compressor<A>::compress_surprising_values(const vector_u32<A>& pairs, uint8_t lg_k, compressed_state<A>& result) const {
-  const size_t k = 1 << lg_k;
-  const uint64_t num_base_bits = golomb_choose_number_of_base_bits(k + pairs.size(), pairs.size());
-  const uint64_t table_len = safe_length_for_compressed_pair_buf(k, pairs.size(), num_base_bits);
+  const uint32_t k = 1 << lg_k;
+  const uint32_t num_pairs = static_cast<uint32_t>(pairs.size());
+  const uint8_t num_base_bits = golomb_choose_number_of_base_bits(k + num_pairs, num_pairs);
+  const uint64_t table_len = safe_length_for_compressed_pair_buf(k, num_pairs, num_base_bits);
   result.table_data.resize(table_len);
 
-  size_t csv_length = low_level_compress_pairs(pairs.data(), pairs.size(), num_base_bits, result.table_data.data());
+  uint32_t csv_length = low_level_compress_pairs(pairs.data(), static_cast<uint32_t>(pairs.size()), num_base_bits, result.table_data.data());
 
   // At this point we could free the unused portion of the compression output buffer,
   // but it is not necessary if it is temporary
   // Note: realloc caused strange timing spikes for lgK = 11 and 12.
 
   result.table_data_words = csv_length;
-  result.table_num_entries = pairs.size();
+  result.table_num_entries = num_pairs;
 }
 
 template<typename A>
-vector_u32<A> cpc_compressor<A>::uncompress_surprising_values(const uint32_t* data, size_t data_words, size_t num_pairs,
+vector_u32<A> cpc_compressor<A>::uncompress_surprising_values(const uint32_t* data, uint32_t data_words, uint32_t num_pairs,
     uint8_t lg_k, const A& allocator) const {
-  const size_t k = 1 << lg_k;
+  const uint32_t k = 1 << lg_k;
   vector_u32<A> pairs(num_pairs, 0, allocator);
   const uint8_t num_base_bits = golomb_choose_number_of_base_bits(k + num_pairs, num_pairs);
   low_level_uncompress_pairs(pairs.data(), num_pairs, num_base_bits, data, data_words);
@@ -381,7 +383,7 @@
 
 template<typename A>
 void cpc_compressor<A>::compress_sliding_window(const uint8_t* window, uint8_t lg_k, uint32_t num_coupons, compressed_state<A>& target) const {
-  const size_t k = 1 << lg_k;
+  const uint32_t k = 1 << lg_k;
   const size_t window_buf_len = safe_length_for_compressed_window_buf(k);
   target.window_data.resize(window_buf_len);
   const uint8_t pseudo_phase = determine_pseudo_phase(lg_k, num_coupons);
@@ -391,20 +393,20 @@
   // but it is not necessary if it is temporary
   // Note: realloc caused strange timing spikes for lgK = 11 and 12.
 
-  target.window_data_words = data_words;
+  target.window_data_words = static_cast<uint32_t>(data_words);
 }
 
 template<typename A>
-void cpc_compressor<A>::uncompress_sliding_window(const uint32_t* data, size_t data_words, vector_u8<A>& window,
+void cpc_compressor<A>::uncompress_sliding_window(const uint32_t* data, uint32_t data_words, vector_u8<A>& window,
     uint8_t lg_k, uint32_t num_coupons) const {
-  const size_t k = 1 << lg_k;
+  const uint32_t k = 1 << lg_k;
   window.resize(k); // zeroing not needed here (unlike the Hybrid Flavor)
   const uint8_t pseudo_phase = determine_pseudo_phase(lg_k, num_coupons);
   low_level_uncompress_bytes(window.data(), k, decoding_tables_for_high_entropy_byte[pseudo_phase], data, data_words);
 }
 
 template<typename A>
-size_t cpc_compressor<A>::safe_length_for_compressed_pair_buf(uint64_t k, size_t num_pairs, size_t num_base_bits) {
+size_t cpc_compressor<A>::safe_length_for_compressed_pair_buf(uint32_t k, uint32_t num_pairs, uint8_t num_base_bits) {
   // Long ybits = k + numPairs; // simpler and safer UB
   // The following tighter UB on ybits is based on page 198
   // of the textbook "Managing Gigabytes" by Witten, Moffat, and Bell.
@@ -422,14 +424,14 @@
 // So the 12-bit lookahead is the tight constraint, but there are at least (2 + B) bits emitted,
 // so we would be safe with max (0, 10 - B) bits of padding at the end of the bitstream.
 template<typename A>
-size_t cpc_compressor<A>::safe_length_for_compressed_window_buf(uint64_t k) { // measured in 32-bit words
+size_t cpc_compressor<A>::safe_length_for_compressed_window_buf(uint32_t k) { // measured in 32-bit words
   const size_t bits = 12 * k + 11; // 11 bits of padding, due to 12-bit lookahead, with 1 bit certainly present.
   return divide_longs_rounding_up(bits, 32);
 }
 
 template<typename A>
-uint8_t cpc_compressor<A>::determine_pseudo_phase(uint8_t lg_k, uint64_t c) {
-  const size_t k = 1 << lg_k;
+uint8_t cpc_compressor<A>::determine_pseudo_phase(uint8_t lg_k, uint32_t c) {
+  const uint32_t k = 1 << lg_k;
   // This mid-range logic produces pseudo-phases. They are used to select encoding tables.
   // The thresholds were chosen by hand after looking at plots of measured compression.
   if (1000 * c < 2375 * k) {
@@ -450,7 +452,7 @@
   }
 }
 
-static inline void maybe_flush_bitbuf(uint64_t& bitbuf, uint8_t& bufbits, uint32_t* wordarr, size_t& wordindex) {
+static inline void maybe_flush_bitbuf(uint64_t& bitbuf, uint8_t& bufbits, uint32_t* wordarr, uint32_t& wordindex) {
   if (bufbits >= 32) {
     wordarr[wordindex++] = bitbuf & 0xffffffff;
     bitbuf = bitbuf >> 32;
@@ -458,7 +460,7 @@
   }
 }
 
-static inline void maybe_fill_bitbuf(uint64_t& bitbuf, uint8_t& bufbits, const uint32_t* wordarr, size_t& wordindex, uint8_t minbits) {
+static inline void maybe_fill_bitbuf(uint64_t& bitbuf, uint8_t& bufbits, const uint32_t* wordarr, uint32_t& wordindex, uint8_t minbits) {
   if (bufbits < minbits) {
     bitbuf |= static_cast<uint64_t>(wordarr[wordindex++]) << bufbits;
     bufbits += 32;
@@ -468,20 +470,20 @@
 // This returns the number of compressed words that were actually used.
 // It is the caller's responsibility to ensure that the compressed_words array is long enough.
 template<typename A>
-size_t cpc_compressor<A>::low_level_compress_bytes(
+uint32_t cpc_compressor<A>::low_level_compress_bytes(
     const uint8_t* byte_array, // input
-    size_t num_bytes_to_encode,
+    uint32_t num_bytes_to_encode,
     const uint16_t* encoding_table,
     uint32_t* compressed_words // output
 ) const {
   uint64_t bitbuf = 0; // bits are packed into this first, then are flushed to compressed_words
   uint8_t bufbits = 0; // number of bits currently in bitbuf; must be between 0 and 31
-  size_t next_word_index = 0;
+  uint32_t next_word_index = 0;
 
-  for (size_t byte_index = 0; byte_index < num_bytes_to_encode; byte_index++) {
-    const uint64_t code_info = encoding_table[byte_array[byte_index]];
+  for (uint32_t byte_index = 0; byte_index < num_bytes_to_encode; byte_index++) {
+    const uint16_t code_info = encoding_table[byte_array[byte_index]];
     const uint64_t code_val = code_info & 0xfff;
-    const int code_len = code_info >> 12;
+    const uint8_t code_len = code_info >> 12;
     bitbuf |= (code_val << bufbits);
     bufbits += code_len;
     maybe_flush_bitbuf(bitbuf, bufbits, compressed_words, next_word_index);
@@ -502,12 +504,12 @@
 template<typename A>
 void cpc_compressor<A>::low_level_uncompress_bytes(
     uint8_t* byte_array, // output
-    size_t num_bytes_to_decode,
+    uint32_t num_bytes_to_decode,
     const uint16_t* decoding_table,
     const uint32_t* compressed_words, // input
-    size_t num_compressed_words
+    uint32_t num_compressed_words
 ) const {
-  size_t word_index = 0;
+  uint32_t word_index = 0;
   uint64_t bitbuf = 0;
   uint8_t bufbits = 0;
 
@@ -515,7 +517,7 @@
   if (decoding_table == nullptr) throw std::logic_error("decoding_table == NULL");
   if (compressed_words == nullptr) throw std::logic_error("compressed_words == NULL");
 
-  for (size_t byte_index = 0; byte_index < num_bytes_to_decode; byte_index++) {
+  for (uint32_t byte_index = 0; byte_index < num_bytes_to_decode; byte_index++) {
     maybe_fill_bitbuf(bitbuf, bufbits, compressed_words, word_index, 12); // ensure 12 bits in bit buffer
 
     const size_t peek12 = bitbuf & 0xfff; // These 12 bits will include an entire Huffman codeword.
@@ -533,14 +535,14 @@
 
 static inline uint64_t read_unary(
     const uint32_t* compressed_words,
-    size_t& next_word_index,
+    uint32_t& next_word_index,
     uint64_t& bitbuf,
     uint8_t& bufbits
 );
 
 static inline void write_unary(
     uint32_t* compressed_words,
-    size_t& next_word_index_ptr,
+    uint32_t& next_word_index_ptr,
     uint64_t& bit_buf_ptr,
     uint8_t& buf_bits_ptr,
     uint64_t value
@@ -551,38 +553,38 @@
 
 // returns the number of compressed_words actually used
 template<typename A>
-size_t cpc_compressor<A>::low_level_compress_pairs(
+uint32_t cpc_compressor<A>::low_level_compress_pairs(
     const uint32_t* pair_array,  // input
-    size_t num_pairs_to_encode,
-    size_t num_base_bits,
+    uint32_t num_pairs_to_encode,
+    uint8_t num_base_bits,
     uint32_t* compressed_words // output
 ) const {
   uint64_t bitbuf = 0;
   uint8_t bufbits = 0;
-  size_t next_word_index = 0;
+  uint32_t next_word_index = 0;
   const uint64_t golomb_lo_mask = (1 << num_base_bits) - 1;
-  uint64_t predicted_row_index = 0;
-  uint16_t predicted_col_index = 0;
+  uint32_t predicted_row_index = 0;
+  uint8_t predicted_col_index = 0;
 
-  for (size_t pair_index = 0; pair_index < num_pairs_to_encode; pair_index++) {
+  for (uint32_t pair_index = 0; pair_index < num_pairs_to_encode; pair_index++) {
     const uint32_t row_col = pair_array[pair_index];
-    const uint64_t row_index = row_col >> 6;
-    const uint16_t col_index = row_col & 63;
+    const uint32_t row_index = row_col >> 6;
+    const uint8_t col_index = row_col & 63;
 
     if (row_index != predicted_row_index) predicted_col_index = 0;
 
     if (row_index < predicted_row_index) throw std::logic_error("row_index < predicted_row_index");
     if (col_index < predicted_col_index) throw std::logic_error("col_index < predicted_col_index");
 
-    const uint64_t y_delta = row_index - predicted_row_index;
-    const uint16_t x_delta = col_index - predicted_col_index;
+    const uint32_t y_delta = row_index - predicted_row_index;
+    const uint8_t x_delta = col_index - predicted_col_index;
 
     predicted_row_index = row_index;
     predicted_col_index = col_index + 1;
 
-    const uint64_t code_info = length_limited_unary_encoding_table65[x_delta];
+    const uint16_t code_info = length_limited_unary_encoding_table65[x_delta];
     const uint64_t code_val = code_info & 0xfff;
-    const uint8_t code_len = code_info >> 12;
+    const uint8_t code_len = static_cast<uint8_t>(code_info >> 12);
     bitbuf |= code_val << bufbits;
     bufbits += code_len;
     maybe_flush_bitbuf(bitbuf, bufbits, compressed_words, next_word_index);
@@ -614,29 +616,29 @@
 template<typename A>
 void cpc_compressor<A>::low_level_uncompress_pairs(
     uint32_t* pair_array, // output
-    size_t num_pairs_to_decode,
-    size_t num_base_bits,
+    uint32_t num_pairs_to_decode,
+    uint8_t num_base_bits,
     const uint32_t* compressed_words, // input
-    size_t num_compressed_words
+    uint32_t num_compressed_words
 ) const {
-  size_t word_index = 0;
+  uint32_t word_index = 0;
   uint64_t bitbuf = 0;
   uint8_t bufbits = 0;
   const uint64_t golomb_lo_mask = (1 << num_base_bits) - 1;
-  uint64_t predicted_row_index = 0;
-  uint16_t predicted_col_index = 0;
+  uint32_t predicted_row_index = 0;
+  uint8_t predicted_col_index = 0;
 
   // for each pair we need to read:
   // x_delta (12-bit length-limited unary)
   // y_delta_hi (unary)
   // y_delta_lo (basebits)
 
-  for (size_t pair_index = 0; pair_index < num_pairs_to_decode; pair_index++) {
+  for (uint32_t pair_index = 0; pair_index < num_pairs_to_decode; pair_index++) {
     maybe_fill_bitbuf(bitbuf, bufbits, compressed_words, word_index, 12); // ensure 12 bits in bit buffer
     const size_t peek12 = bitbuf & 0xfff;
     const uint16_t lookup = length_limited_unary_decoding_table65[peek12];
-    const int code_word_length = lookup >> 8;
-    const int16_t x_delta = lookup & 0xff;
+    const uint8_t code_word_length = lookup >> 8;
+    const int8_t x_delta = lookup & 0xff;
     bitbuf >>= code_word_length;
     bufbits -= code_word_length;
 
@@ -650,8 +652,8 @@
 
     // Now that we have x_delta and y_delta, we can compute the pair's row and column
     if (y_delta > 0) predicted_col_index = 0;
-    const uint64_t row_index = predicted_row_index + y_delta;
-    const uint16_t col_index = predicted_col_index + x_delta;
+    const uint32_t row_index = static_cast<uint32_t>(predicted_row_index + y_delta);
+    const uint8_t col_index = predicted_col_index + x_delta;
     const uint32_t row_col = (row_index << 6) | col_index;
     pair_array[pair_index] = row_col;
     predicted_row_index = row_index;
@@ -662,7 +664,7 @@
 
 uint64_t read_unary(
     const uint32_t* compressed_words,
-    size_t& next_word_index,
+    uint32_t& next_word_index,
     uint64_t& bitbuf,
     uint8_t& bufbits
 ) {
@@ -689,7 +691,7 @@
 
 void write_unary(
     uint32_t* compressed_words,
-    size_t& next_word_index,
+    uint32_t& next_word_index,
     uint64_t& bitbuf,
     uint8_t& bufbits,
     uint64_t value
@@ -709,9 +711,9 @@
 
   if (remaining > 15) throw std::out_of_range("remaining out of range");
 
-  const uint64_t the_unary_code = 1 << remaining;
+  const uint64_t the_unary_code = 1ULL << remaining;
   bitbuf |= the_unary_code << bufbits;
-  bufbits += 1 + remaining;
+  bufbits += static_cast<uint8_t>(remaining + 1);
   maybe_flush_bitbuf(bitbuf, bufbits, compressed_words, next_word_index);
 }
 
@@ -738,12 +740,12 @@
 // returns an integer that is between
 // zero and ceiling(log_2(k)) - 1, inclusive
 template<typename A>
-uint64_t cpc_compressor<A>::golomb_choose_number_of_base_bits(uint64_t k, uint64_t count) {
+uint8_t cpc_compressor<A>::golomb_choose_number_of_base_bits(uint32_t k, uint64_t count) {
   if (k < 1) throw std::invalid_argument("golomb_choose_number_of_base_bits: k < 1");
   if (count < 1) throw std::invalid_argument("golomb_choose_number_of_base_bits: count < 1");
   const uint64_t quotient = (k - count) / count; // integer division
   if (quotient == 0) return 0;
-  else return long_floor_log2_of_long(quotient);
+  else return floor_log2_of_long(quotient);
 }
 
 } /* namespace datasketches */
diff --git a/cpc/include/cpc_sketch.hpp b/cpc/include/cpc_sketch.hpp
index a4bf8f6..651c254 100644
--- a/cpc/include/cpc_sketch.hpp
+++ b/cpc/include/cpc_sketch.hpp
@@ -192,7 +192,7 @@
    * @param data pointer to the data
    * @param length of the data in bytes
    */
-  void update(const void* value, int size);
+  void update(const void* value, size_t size);
 
   /**
    * Returns a human-readable summary of this sketch
diff --git a/cpc/include/cpc_sketch_impl.hpp b/cpc/include/cpc_sketch_impl.hpp
index 60429b6..1bb1be1 100644
--- a/cpc/include/cpc_sketch_impl.hpp
+++ b/cpc/include/cpc_sketch_impl.hpp
@@ -176,7 +176,7 @@
 
 static inline uint32_t row_col_from_two_hashes(uint64_t hash0, uint64_t hash1, uint8_t lg_k) {
   if (lg_k > 26) throw std::logic_error("lg_k > 26");
-  const uint64_t k = 1 << lg_k;
+  const uint32_t k = 1 << lg_k;
   uint8_t col = count_leading_zeros_in_u64(hash1); // 0 <= col <= 64
   if (col > 63) col = 63; // clip so that 0 <= col <= 63
   const uint32_t row = hash0 & (k - 1);
@@ -188,7 +188,7 @@
 }
 
 template<typename A>
-void cpc_sketch_alloc<A>::update(const void* value, int size) {
+void cpc_sketch_alloc<A>::update(const void* value, size_t size) {
   HashState hashes;
   MurmurHash3_x64_128(value, size, seed, hashes);
   row_col_update(row_col_from_two_hashes(hashes.h1, hashes.h2, lg_k));
@@ -208,7 +208,7 @@
 
 template<typename A>
 void cpc_sketch_alloc<A>::update_sparse(uint32_t row_col) {
-  const uint64_t k = 1 << lg_k;
+  const uint32_t k = 1 << lg_k;
   const uint64_t c32pre = static_cast<uint64_t>(num_coupons) << 5;
   if (c32pre >= 3 * k) throw std::logic_error("c32pre >= 3 * k"); // C < 3K/32, in other words flavor == SPARSE
   bool is_novel = surprising_value_table.maybe_insert(row_col);
@@ -224,7 +224,7 @@
 template<typename A>
 void cpc_sketch_alloc<A>::update_windowed(uint32_t row_col) {
   if (window_offset > 56) throw std::logic_error("wrong window offset");
-  const uint64_t k = 1 << lg_k;
+  const uint32_t k = 1 << lg_k;
   const uint64_t c32pre = static_cast<uint64_t>(num_coupons) << 5;
   if (c32pre < 3 * k) throw std::logic_error("c32pre < 3 * k"); // C < 3K/32, in other words flavor >= HYBRID
   const uint64_t c8pre = static_cast<uint64_t>(num_coupons) << 3;
@@ -266,7 +266,7 @@
 // Call this whenever a new coupon has been collected.
 template<typename A>
 void cpc_sketch_alloc<A>::update_hip(uint32_t row_col) {
-  const uint64_t k = 1 << lg_k;
+  const uint32_t k = 1 << lg_k;
   const uint8_t col = row_col & 63;
   const double one_over_p = static_cast<double>(k) / kxp;
   hip_est_accum += one_over_p;
@@ -276,7 +276,7 @@
 // In terms of flavor, this promotes SPARSE to HYBRID
 template<typename A>
 void cpc_sketch_alloc<A>::promote_sparse_to_windowed() {
-  const uint64_t k = 1 << lg_k;
+  const uint32_t k = 1 << lg_k;
   const uint64_t c32 = static_cast<uint64_t>(num_coupons) << 5;
   if (!(c32 == 3 * k || (lg_k == 4 && c32 > 3 * k))) throw std::logic_error("wrong c32");
 
@@ -285,16 +285,16 @@
   u32_table<A> new_table(2, 6 + lg_k, sliding_window.get_allocator());
 
   const uint32_t* old_slots = surprising_value_table.get_slots();
-  const size_t old_num_slots = 1 << surprising_value_table.get_lg_size();
+  const uint32_t old_num_slots = 1 << surprising_value_table.get_lg_size();
 
   if (window_offset != 0) throw std::logic_error("window_offset != 0");
 
-  for (size_t i = 0; i < old_num_slots; i++) {
+  for (uint32_t i = 0; i < old_num_slots; i++) {
     const uint32_t row_col = old_slots[i];
     if (row_col != UINT32_MAX) {
       const uint8_t col = row_col & 63;
       if (col < 8) {
-        const size_t row = row_col >> 6;
+        const uint32_t row = row_col >> 6;
         sliding_window[row] |= 1 << col;
       } else {
         // cannot use u32_table::must_insert(), because it doesn't provide for growth
@@ -314,7 +314,7 @@
   if (new_offset != determine_correct_offset(lg_k, num_coupons)) throw std::logic_error("new_offset is wrong");
 
   if (sliding_window.size() == 0) throw std::logic_error("no sliding window");
-  const uint64_t k = 1 << lg_k;
+  const uint32_t k = 1 << lg_k;
 
   // Construct the full-sized bit matrix that corresponds to the sketch
   vector_u64<A> bit_matrix = build_bit_matrix();
@@ -328,7 +328,7 @@
   const uint64_t mask_for_flipping_early_zone = (static_cast<uint64_t>(1) << new_offset) - 1;
   uint64_t all_surprises_ored = 0;
 
-  for (size_t i = 0; i < k; i++) {
+  for (uint32_t i = 0; i < k; i++) {
     uint64_t pattern = bit_matrix[i];
     sliding_window[i] = (pattern >> new_offset) & 0xff;
     pattern &= mask_for_clearing_window;
@@ -357,7 +357,7 @@
 // so that it will reflect changes that were previously outside the mantissa.
 template<typename A>
 void cpc_sketch_alloc<A>::refresh_kxp(const uint64_t* bit_matrix) {
-  const uint64_t k = 1 << lg_k;
+  const uint32_t k = 1 << lg_k;
 
   // for improved numerical accuracy, we separately sum the bytes of the U64's
   double byte_sums[8]; // allocating on the stack
@@ -689,7 +689,7 @@
 template<typename A>
 bool cpc_sketch_alloc<A>::validate() const {
   vector_u64<A> bit_matrix = build_bit_matrix();
-  const uint64_t num_bits_set = count_bits_set_in_matrix(bit_matrix.data(), 1 << lg_k);
+  const uint64_t num_bits_set = count_bits_set_in_matrix(bit_matrix.data(), 1ULL << lg_k);
   return num_bits_set == num_coupons;
 }
 
@@ -737,7 +737,7 @@
 
 template<typename A>
 typename cpc_sketch_alloc<A>::flavor cpc_sketch_alloc<A>::determine_flavor(uint8_t lg_k, uint64_t c) {
-  const uint64_t k = 1 << lg_k;
+  const uint32_t k = 1 << lg_k;
   const uint64_t c2 = c << 1;
   const uint64_t c8 = c << 3;
   const uint64_t c32 = c << 5;
@@ -750,15 +750,15 @@
 
 template<typename A>
 uint8_t cpc_sketch_alloc<A>::determine_correct_offset(uint8_t lg_k, uint64_t c) {
-  const uint64_t k = 1 << lg_k;
+  const uint32_t k = 1 << lg_k;
   const int64_t tmp = static_cast<int64_t>(c << 3) - static_cast<int64_t>(19 * k); // 8C - 19K
   if (tmp < 0) return 0;
-  return tmp >> (lg_k + 3); // tmp / 8K
+  return static_cast<uint8_t>(tmp >> (lg_k + 3)); // tmp / 8K
 }
 
 template<typename A>
 vector_u64<A> cpc_sketch_alloc<A>::build_bit_matrix() const {
-  const size_t k = 1 << lg_k;
+  const uint32_t k = 1 << lg_k;
   if (window_offset > 56) throw std::logic_error("offset > 56");
 
   // Fill the matrix with default rows in which the "early zone" is filled with ones.
@@ -775,12 +775,12 @@
   }
 
   const uint32_t* slots = surprising_value_table.get_slots();
-  const size_t num_slots = 1 << surprising_value_table.get_lg_size();
+  const uint32_t num_slots = 1 << surprising_value_table.get_lg_size();
   for (size_t i = 0; i < num_slots; i++) {
     const uint32_t row_col = slots[i];
     if (row_col != UINT32_MAX) {
       const uint8_t col = row_col & 63;
-      const size_t row = row_col >> 6;
+      const uint32_t row = row_col >> 6;
       // Flip the specified matrix bit from its default value.
       // In the "early" zone the bit changes from 1 to 0.
       // In the "late" zone the bit changes from 0 to 1.
diff --git a/cpc/include/cpc_union_impl.hpp b/cpc/include/cpc_union_impl.hpp
index 5acfe5f..e5a1e5d 100644
--- a/cpc/include/cpc_union_impl.hpp
+++ b/cpc/include/cpc_union_impl.hpp
@@ -191,8 +191,8 @@
 
 template<typename A>
 cpc_sketch_alloc<A> cpc_union_alloc<A>::get_result_from_bit_matrix() const {
-  const uint64_t k = 1 << lg_k;
-  const uint64_t num_coupons = count_bits_set_in_matrix(bit_matrix.data(), k);
+  const uint32_t k = 1 << lg_k;
+  const uint32_t num_coupons = count_bits_set_in_matrix(bit_matrix.data(), k);
 
   const auto flavor = cpc_sketch_alloc<A>::determine_flavor(lg_k, num_coupons);
   if (flavor != cpc_sketch_alloc<A>::flavor::HYBRID && flavor != cpc_sketch_alloc<A>::flavor::PINNED
@@ -215,7 +215,7 @@
 
   // The snowplow effect was caused by processing the rows in order,
   // but we have fixed it by using a sufficiently large hash table.
-  for (unsigned i = 0; i < k; i++) {
+  for (uint32_t i = 0; i < k; i++) {
     uint64_t pattern = bit_matrix[i];
     sliding_window[i] = (pattern >> offset) & 0xff;
     pattern &= mask_for_clearing_window;
@@ -250,17 +250,17 @@
 template<typename A>
 void cpc_union_alloc<A>::walk_table_updating_sketch(const u32_table<A>& table) {
   const uint32_t* slots = table.get_slots();
-  const size_t num_slots = 1 << table.get_lg_size();
+  const uint32_t num_slots = 1 << table.get_lg_size();
   const uint64_t dst_mask = (((1 << accumulator->get_lg_k()) - 1) << 6) | 63; // downsamples when dst lgK < src LgK
 
   // Using a golden ratio stride fixes the snowplow effect.
   const double golden = 0.6180339887498949025;
-  size_t stride = static_cast<size_t>(golden * static_cast<double>(num_slots));
+  uint32_t stride = static_cast<uint32_t>(golden * static_cast<double>(num_slots));
   if (stride < 2) throw std::logic_error("stride < 2");
   if (stride == ((stride >> 1) << 1)) stride += 1; // force the stride to be odd
   if (stride < 3 || stride >= num_slots) throw std::out_of_range("stride out of range");
 
-  for (size_t i = 0, j = 0; i < num_slots; i++, j += stride) {
+  for (uint32_t i = 0, j = 0; i < num_slots; i++, j += stride) {
     j &= num_slots - 1;
     const uint32_t row_col = slots[j];
     if (row_col != UINT32_MAX) {
@@ -272,13 +272,13 @@
 template<typename A>
 void cpc_union_alloc<A>::or_table_into_matrix(const u32_table<A>& table) {
   const uint32_t* slots = table.get_slots();
-  const size_t num_slots = 1 << table.get_lg_size();
+  const uint32_t num_slots = 1 << table.get_lg_size();
   const uint64_t dest_mask = (1 << lg_k) - 1;  // downsamples when dst lgK < sr LgK
-  for (size_t i = 0; i < num_slots; i++) {
+  for (uint32_t i = 0; i < num_slots; i++) {
     const uint32_t row_col = slots[i];
     if (row_col != UINT32_MAX) {
       const uint8_t col = row_col & 63;
-      const size_t row = row_col >> 6;
+      const uint32_t row = row_col >> 6;
       bit_matrix[row & dest_mask] |= static_cast<uint64_t>(1) << col; // set the bit
     }
   }
@@ -288,8 +288,8 @@
 void cpc_union_alloc<A>::or_window_into_matrix(const vector_u8<A>& sliding_window, uint8_t offset, uint8_t src_lg_k) {
   if (lg_k > src_lg_k) throw std::logic_error("dst LgK > src LgK");
   const uint64_t dst_mask = (1 << lg_k) - 1; // downsamples when dst lgK < src LgK
-  const size_t src_k = 1 << src_lg_k;
-  for (size_t src_row = 0; src_row < src_k; src_row++) {
+  const uint32_t src_k = 1 << src_lg_k;
+  for (uint32_t src_row = 0; src_row < src_k; src_row++) {
     bit_matrix[src_row & dst_mask] |= static_cast<uint64_t>(sliding_window[src_row]) << offset;
   }
 }
@@ -298,8 +298,8 @@
 void cpc_union_alloc<A>::or_matrix_into_matrix(const vector_u64<A>& src_matrix, uint8_t src_lg_k) {
   if (lg_k > src_lg_k) throw std::logic_error("dst LgK > src LgK");
   const uint64_t dst_mask = (1 << lg_k) - 1; // downsamples when dst lgK < src LgK
-  const size_t src_k = 1 << src_lg_k;
-  for (size_t src_row = 0; src_row < src_k; src_row++) {
+  const uint32_t src_k = 1 << src_lg_k;
+  for (uint32_t src_row = 0; src_row < src_k; src_row++) {
     bit_matrix[src_row & dst_mask] |= src_matrix[src_row];
   }
 }
@@ -313,7 +313,7 @@
     if (accumulator != nullptr) throw std::logic_error("accumulator is not null");
     vector_u64<A> old_matrix = std::move(bit_matrix);
     const uint8_t old_lg_k = lg_k;
-    const size_t new_k = 1 << new_lg_k;
+    const uint32_t new_k = 1 << new_lg_k;
     bit_matrix = vector_u64<A>(new_k, 0, old_matrix.get_allocator());
     lg_k = new_lg_k;
     or_matrix_into_matrix(old_matrix, old_lg_k);
diff --git a/cpc/include/cpc_util.hpp b/cpc/include/cpc_util.hpp
index 1a33b3a..9bf8aa3 100644
--- a/cpc/include/cpc_util.hpp
+++ b/cpc/include/cpc_util.hpp
@@ -31,9 +31,9 @@
   else return quotient + 1;
 }
 
-static inline uint64_t long_floor_log2_of_long(uint64_t x) {
-  if (x < 1) throw std::invalid_argument("long_floor_log2_of_long: bad argument");
-  uint64_t p = 0;
+static inline uint8_t floor_log2_of_long(uint64_t x) {
+  if (x < 1) throw std::invalid_argument("floor_log2_of_long: bad argument");
+  uint8_t p = 0;
   uint64_t y = 1;
   while (true) {
     if (y == x) return p;
@@ -69,7 +69,7 @@
 // Note: this is an adaptation of the Java code,
 // which is apparently a variation of Figure 5-2 in "Hacker's Delight"
 // by Henry S. Warren.
-static inline uint64_t warren_bit_count(uint64_t i) {
+static inline uint32_t warren_bit_count(uint64_t i) {
   i = i - ((i >> 1) & 0x5555555555555555ULL);
   i = (i & 0x3333333333333333ULL) + ((i >> 2) & 0x3333333333333333ULL);
   i = (i + (i >> 4)) & 0x0f0f0f0f0f0f0f0fULL;
@@ -79,9 +79,9 @@
   return i & 0x7f;
 }
 
-static inline uint64_t warren_count_bits_set_in_matrix(const uint64_t* array, size_t length) {
-  uint64_t count = 0;
-  for (size_t i = 0; i < length; i++) {
+static inline uint32_t warren_count_bits_set_in_matrix(const uint64_t* array, uint32_t length) {
+  uint32_t count = 0;
+  for (uint32_t i = 0; i < length; i++) {
     count += warren_bit_count(array[i]);
   }
   return count;
@@ -91,13 +91,13 @@
 
 #define CSA(h,l,a,b,c) {uint64_t u = a ^ b; uint64_t v = c; h = (a & b) | (u & v); l = u ^ v;}
 
-static inline uint64_t count_bits_set_in_matrix(const uint64_t* a, size_t length) {
+static inline uint32_t count_bits_set_in_matrix(const uint64_t* a, uint32_t length) {
   if ((length & 0x7) != 0) throw std::invalid_argument("the length of the array must be a multiple of 8");
-  uint64_t total = 0;
+  uint32_t total = 0;
   uint64_t ones, twos, twos_a, twos_b, fours, fours_a, fours_b, eights;
   fours = twos = ones = 0;
 
-  for (size_t i = 0; i <= length - 8; i = i + 8) {
+  for (uint32_t i = 0; i <= length - 8; i += 8) {
     CSA(twos_a, ones, ones, a[i+0], a[i+1]);
     CSA(twos_b, ones, ones, a[i+2], a[i+3]);
     CSA(fours_a, twos, twos, twos_a, twos_b);
diff --git a/cpc/include/icon_estimator.hpp b/cpc/include/icon_estimator.hpp
index 4a9daea..fb3c0c6 100644
--- a/cpc/include/icon_estimator.hpp
+++ b/cpc/include/icon_estimator.hpp
@@ -245,12 +245,12 @@
   return (0.7940236163830469 * k * pow(2.0, c / k));
 }
 
-static inline double compute_icon_estimate(uint8_t lg_k, uint64_t c) {
+static inline double compute_icon_estimate(uint8_t lg_k, uint32_t c) {
   if (lg_k < ICON_MIN_LOG_K || lg_k > ICON_MAX_LOG_K) throw std::out_of_range("lg_k out of range");
   if (c < 2) return ((c == 0) ? 0.0 : 1.0);
-  const size_t k = 1 << lg_k;
-  const double double_k = k;
-  const double double_c = c;
+  const uint32_t k = 1 << lg_k;
+  const double double_k = static_cast<double>(k);
+  const double double_c = static_cast<double>(c);
   // Differing thresholds ensure that the approximated estimator is monotonically increasing.
   const double threshold_factor = ((lg_k < 14) ? 5.7 : 5.6);
   if (double_c > (threshold_factor * double_k)) return icon_exponential_approximation(double_k, double_c);
diff --git a/cpc/include/u32_table.hpp b/cpc/include/u32_table.hpp
index fe228a5..a344a17 100644
--- a/cpc/include/u32_table.hpp
+++ b/cpc/include/u32_table.hpp
@@ -29,11 +29,11 @@
 
 namespace datasketches {
 
-static const uint64_t U32_TABLE_UPSIZE_NUMER = 3LL;
-static const uint64_t U32_TABLE_UPSIZE_DENOM = 4LL;
+static const uint32_t U32_TABLE_UPSIZE_NUMER = 3LL;
+static const uint32_t U32_TABLE_UPSIZE_DENOM = 4LL;
 
-static const uint64_t U32_TABLE_DOWNSIZE_NUMER = 1LL;
-static const uint64_t U32_TABLE_DOWNSIZE_DENOM = 4LL;
+static const uint32_t U32_TABLE_DOWNSIZE_NUMER = 1LL;
+static const uint32_t U32_TABLE_DOWNSIZE_DENOM = 4LL;
 
 template<typename A>
 class u32_table {
@@ -42,7 +42,7 @@
   u32_table(const A& allocator);
   u32_table(uint8_t lg_size, uint8_t num_valid_bits, const A& allocator);
 
-  inline size_t get_num_items() const;
+  inline uint32_t get_num_items() const;
   inline const uint32_t* get_slots() const;
   inline uint8_t get_lg_size() const;
   inline void clear();
@@ -52,7 +52,7 @@
   // returns true iff the item was present and was therefore removed from the table
   inline bool maybe_delete(uint32_t item);
 
-  static u32_table make_from_pairs(const uint32_t* pairs, size_t num_pairs, uint8_t lg_k, const A& allocator);
+  static u32_table make_from_pairs(const uint32_t* pairs, uint32_t num_pairs, uint8_t lg_k, const A& allocator);
 
   vector_u32<A> unwrapping_get_items() const;
 
@@ -69,10 +69,10 @@
 
   uint8_t lg_size; // log2 of number of slots
   uint8_t num_valid_bits;
-  size_t num_items;
+  uint32_t num_items;
   vector_u32<A> slots;
 
-  inline size_t lookup(uint32_t item) const;
+  inline uint32_t lookup(uint32_t item) const;
   inline void must_insert(uint32_t item);
   inline void rebuild(uint8_t new_lg_size);
 };
diff --git a/cpc/include/u32_table_impl.hpp b/cpc/include/u32_table_impl.hpp
index bf8ece9..a82e7de 100644
--- a/cpc/include/u32_table_impl.hpp
+++ b/cpc/include/u32_table_impl.hpp
@@ -41,14 +41,14 @@
 lg_size(lg_size),
 num_valid_bits(num_valid_bits),
 num_items(0),
-slots(1 << lg_size, UINT32_MAX, allocator)
+slots(1ULL << lg_size, UINT32_MAX, allocator)
 {
   if (lg_size < 2) throw std::invalid_argument("lg_size must be >= 2");
   if (num_valid_bits < 1 || num_valid_bits > 32) throw std::invalid_argument("num_valid_bits must be between 1 and 32");
 }
 
 template<typename A>
-size_t u32_table<A>::get_num_items() const {
+uint32_t u32_table<A>::get_num_items() const {
   return num_items;
 }
 
@@ -70,7 +70,7 @@
 
 template<typename A>
 bool u32_table<A>::maybe_insert(uint32_t item) {
-  const size_t index = lookup(item);
+  const uint32_t index = lookup(item);
   if (slots[index] == item) return false;
   if (slots[index] != UINT32_MAX) throw std::logic_error("could not insert");
   slots[index] = item;
@@ -83,7 +83,7 @@
 
 template<typename A>
 bool u32_table<A>::maybe_delete(uint32_t item) {
-  const size_t index = lookup(item);
+  const uint32_t index = lookup(item);
   if (slots[index] == UINT32_MAX) return false;
   if (slots[index] != item) throw std::logic_error("item does not exist");
   if (num_items == 0) throw std::logic_error("delete error");
@@ -110,7 +110,7 @@
 
 // this one is specifically tailored to be a part of fm85 decompression scheme
 template<typename A>
-u32_table<A> u32_table<A>::make_from_pairs(const uint32_t* pairs, size_t num_pairs, uint8_t lg_k, const A& allocator) {
+u32_table<A> u32_table<A>::make_from_pairs(const uint32_t* pairs, uint32_t num_pairs, uint8_t lg_k, const A& allocator) {
   uint8_t lg_num_slots = 2;
   while (U32_TABLE_UPSIZE_DENOM * num_pairs > U32_TABLE_UPSIZE_NUMER * (1 << lg_num_slots)) lg_num_slots++;
   u32_table<A> table(lg_num_slots, 6 + lg_k, allocator);
@@ -124,11 +124,11 @@
 }
 
 template<typename A>
-size_t u32_table<A>::lookup(uint32_t item) const {
-  const size_t size = 1 << lg_size;
-  const size_t mask = size - 1;
+uint32_t u32_table<A>::lookup(uint32_t item) const {
+  const uint32_t size = 1 << lg_size;
+  const uint32_t mask = size - 1;
   const uint8_t shift = num_valid_bits - lg_size;
-  size_t probe = item >> shift;
+  uint32_t probe = item >> shift;
   if (probe > mask) throw std::logic_error("probe out of range");
   while (slots[probe] != item && slots[probe] != UINT32_MAX) {
     probe = (probe + 1) & mask;
@@ -139,7 +139,7 @@
 // counts and resizing must be handled by the caller
 template<typename A>
 void u32_table<A>::must_insert(uint32_t item) {
-  const size_t index = lookup(item);
+  const uint32_t index = lookup(item);
   if (slots[index] == item) throw std::logic_error("item exists");
   if (slots[index] != UINT32_MAX) throw std::logic_error("could not insert");
   slots[index] = item;
@@ -148,13 +148,13 @@
 template<typename A>
 void u32_table<A>::rebuild(uint8_t new_lg_size) {
   if (new_lg_size < 2) throw std::logic_error("lg_size must be >= 2");
-  const size_t old_size = 1 << lg_size;
-  const size_t new_size = 1 << new_lg_size;
+  const uint32_t old_size = 1 << lg_size;
+  const uint32_t new_size = 1 << new_lg_size;
   if (new_size <= num_items) throw std::logic_error("new_size <= num_items");
   vector_u32<A> old_slots = std::move(slots);
   slots = vector_u32<A>(new_size, UINT32_MAX, old_slots.get_allocator());
   lg_size = new_lg_size;
-  for (size_t i = 0; i < old_size; i++) {
+  for (uint32_t i = 0; i < old_size; i++) {
     if (old_slots[i] != UINT32_MAX) {
       must_insert(old_slots[i]);
     }
@@ -170,7 +170,7 @@
 template<typename A>
 vector_u32<A> u32_table<A>::unwrapping_get_items() const {
   if (num_items == 0) return vector_u32<A>(slots.get_allocator());
-  const size_t table_size = 1 << lg_size;
+  const uint32_t table_size = 1 << lg_size;
   vector_u32<A> result(num_items, 0, slots.get_allocator());
   size_t i = 0;
   size_t l = 0;
diff --git a/cpc/test/compression_test.cpp b/cpc/test/compression_test.cpp
index ed98274..9ce3e06 100644
--- a/cpc/test/compression_test.cpp
+++ b/cpc/test/compression_test.cpp
@@ -27,38 +27,38 @@
 typedef u32_table<std::allocator<void>> table;
 
 TEST_CASE("cpc sketch: compress and decompress pairs", "[cpc_sketch]") {
-  const int N = 200;
-  const int MAXWORDS = 1000;
+  const size_t N = 200;
+  const size_t MAXWORDS = 1000;
 
   HashState twoHashes;
   uint32_t pairArray[N];
   uint32_t pairArray2[N];
   uint64_t value = 35538947; // some arbitrary starting value
   const uint64_t golden64 = 0x9e3779b97f4a7c13ULL; // the golden ratio
-  for (int i = 0; i < N; i++) {
+  for (size_t i = 0; i < N; i++) {
     MurmurHash3_x64_128(&value, sizeof(value), 0, twoHashes);
     uint32_t rand = twoHashes.h1 & 0xffff;
     pairArray[i] = rand;
     value += golden64;
   }
   //table::knuth_shell_sort3(pairArray, 0, N - 1); // unsigned numerical sort
-  std::sort(pairArray, &pairArray[N]);
+  std::sort(pairArray, pairArray + N);
   uint32_t prev = UINT32_MAX;
-  int nxt = 0;
-  for (int i = 0; i < N; i++) { // uniquify
+  uint32_t nxt = 0;
+  for (size_t i = 0; i < N; i++) { // uniquify
     if (pairArray[i] != prev) {
       prev = pairArray[i];
       pairArray[nxt++] = pairArray[i];
     }
   }
-  int numPairs = nxt;
+  uint32_t numPairs = nxt;
 
   uint32_t compressedWords[MAXWORDS];
 
-  for (size_t numBaseBits = 0; numBaseBits <= 11; numBaseBits++) {
-    size_t numWordsWritten = get_compressor<std::allocator<void>>().low_level_compress_pairs(pairArray, numPairs, numBaseBits, compressedWords);
+  for (uint8_t numBaseBits = 0; numBaseBits <= 11; numBaseBits++) {
+    uint32_t numWordsWritten = get_compressor<std::allocator<void>>().low_level_compress_pairs(pairArray, numPairs, numBaseBits, compressedWords);
     get_compressor<std::allocator<void>>().low_level_uncompress_pairs(pairArray2, numPairs, numBaseBits, compressedWords, numWordsWritten);
-    for (int i = 0; i < numPairs; i++) {
+    for (size_t i = 0; i < numPairs; i++) {
       REQUIRE(pairArray[i] == pairArray2[i]);
     }
   }
diff --git a/cpc/test/cpc_sketch_test.cpp b/cpc/test/cpc_sketch_test.cpp
index 837a61d..0a2ca74 100644
--- a/cpc/test/cpc_sketch_test.cpp
+++ b/cpc/test/cpc_sketch_test.cpp
@@ -283,6 +283,26 @@
   REQUIRE(deserialized.validate());
 }
 
+TEST_CASE("cpc sketch: serialize deserialize sliding huge", "[cpc_sketch]") {
+  cpc_sketch sketch(26);
+  const int n = 10000000;
+  for (int i = 0; i < n; i++) sketch.update(i);
+  REQUIRE(sketch.get_estimate() == Approx(n).margin(n * 0.001));
+  auto bytes = sketch.serialize();
+  cpc_sketch deserialized = cpc_sketch::deserialize(bytes.data(), bytes.size());
+  REQUIRE(deserialized.is_empty() == sketch.is_empty());
+  REQUIRE(deserialized.get_estimate() == sketch.get_estimate());
+  REQUIRE(deserialized.validate());
+  REQUIRE_THROWS_AS(cpc_sketch::deserialize(bytes.data(), 7), std::out_of_range);
+  REQUIRE_THROWS_AS(cpc_sketch::deserialize(bytes.data(), 15), std::out_of_range);
+  REQUIRE_THROWS_AS(cpc_sketch::deserialize(bytes.data(), bytes.size() - 1), std::out_of_range);
+
+  // updating again with the same values should not change the sketch
+  for (int i = 0; i < n; i++) deserialized.update(i);
+  REQUIRE(deserialized.get_estimate() == sketch.get_estimate());
+  REQUIRE(deserialized.validate());
+}
+
 TEST_CASE("cpc sketch: copy", "[cpc_sketch]") {
   cpc_sketch s1(11);
   s1.update(1);
diff --git a/cpc/test/cpc_union_test.cpp b/cpc/test/cpc_union_test.cpp
index e114cd0..688ea12 100644
--- a/cpc/test/cpc_union_test.cpp
+++ b/cpc/test/cpc_union_test.cpp
@@ -81,7 +81,7 @@
   cpc_union u(11);
   for (int i = 0; i < 1000; i++) {
     cpc_sketch tmp(11);
-    for (int i = 0; i < 10000; i++) {
+    for (int j = 0; j < 10000; j++) {
       s.update(key);
       tmp.update(key);
       key++;
diff --git a/fi/include/frequent_items_sketch_impl.hpp b/fi/include/frequent_items_sketch_impl.hpp
index b61ee55..593aa03 100644
--- a/fi/include/frequent_items_sketch_impl.hpp
+++ b/fi/include/frequent_items_sketch_impl.hpp
@@ -65,7 +65,7 @@
 void frequent_items_sketch<T, W, H, E, S, A>::merge(const frequent_items_sketch& other) {
   if (other.is_empty()) return;
   const W merged_total_weight = total_weight + other.get_total_weight(); // for correction at the end
-  for (auto &it: other.map) {
+  for (auto it: other.map) {
     update(it.first, it.second);
   }
   offset += other.offset;
@@ -76,7 +76,7 @@
 void frequent_items_sketch<T, W, H, E, S, A>::merge(frequent_items_sketch&& other) {
   if (other.is_empty()) return;
   const W merged_total_weight = total_weight + other.get_total_weight(); // for correction at the end
-  for (auto &it: other.map) {
+  for (auto it: other.map) {
     update(std::move(it.first), it.second);
   }
   offset += other.offset;
@@ -147,7 +147,7 @@
 typename frequent_items_sketch<T, W, H, E, S, A>::vector_row
 frequent_items_sketch<T, W, H, E, S, A>::get_frequent_items(frequent_items_error_type err_type, W threshold) const {
   vector_row items(map.get_allocator());
-  for (auto &it: map) {
+  for (auto it: map) {
     const W lb = it.second;
     const W ub = it.second + offset;
     if ((err_type == NO_FALSE_NEGATIVES && ub > threshold) || (err_type == NO_FALSE_POSITIVES && lb > threshold)) {
@@ -192,14 +192,14 @@
     A alloc(map.get_allocator());
     T* items = alloc.allocate(num_items);
     uint32_t i = 0;
-    for (auto &it: map) {
+    for (auto it: map) {
       new (&items[i]) T(it.first);
       weights[i++] = it.second;
     }
     write(os, weights, sizeof(W) * num_items);
     aw.deallocate(weights, num_items);
     S().serialize(os, items, num_items);
-    for (unsigned i = 0; i < num_items; i++) items[i].~T();
+    for (i = 0; i < num_items; i++) items[i].~T();
     alloc.deallocate(items, num_items);
   }
 }
@@ -208,7 +208,7 @@
 size_t frequent_items_sketch<T, W, H, E, S, A>::get_serialized_size_bytes() const {
   if (is_empty()) return PREAMBLE_LONGS_EMPTY * sizeof(uint64_t);
   size_t size = PREAMBLE_LONGS_NONEMPTY * sizeof(uint64_t) + map.get_num_active() * sizeof(W);
-  for (auto &it: map) size += S().size_of_item(it.first);
+  for (auto it: map) size += S().size_of_item(it.first);
   return size;
 }
 
@@ -248,7 +248,7 @@
     A alloc(map.get_allocator());
     T* items = alloc.allocate(num_items);
     uint32_t i = 0;
-    for (auto &it: map) {
+    for (auto it: map) {
       new (&items[i]) T(it.first);
       weights[i++] = it.second;
     }
@@ -256,7 +256,7 @@
     aw.deallocate(weights, num_items);
     const size_t bytes_remaining = end_ptr - ptr;
     ptr += S().serialize(ptr, bytes_remaining, items, num_items);
-    for (unsigned i = 0; i < num_items; i++) items[i].~T();
+    for (i = 0; i < num_items; i++) items[i].~T();
     alloc.deallocate(items, num_items);
   }
   return bytes;
@@ -266,20 +266,20 @@
 class frequent_items_sketch<T, W, H, E, S, A>::items_deleter {
 public:
   items_deleter(uint32_t num, bool destroy, const A& allocator):
-    allocator(allocator), num(num), destroy(destroy) {}
-  void set_destroy(bool destroy) { this->destroy = destroy; }
+    allocator_(allocator), num_(num), destroy_(destroy) {}
+  void set_destroy(bool destroy) { destroy_ = destroy; }
   void operator() (T* ptr) {
     if (ptr != nullptr) {
-      if (destroy) {
-        for (uint32_t i = 0; i < num; ++i) ptr[i].~T();
+      if (destroy_) {
+        for (uint32_t i = 0; i < num_; ++i) ptr[i].~T();
       }
-      allocator.deallocate(ptr, num);
+      allocator_.deallocate(ptr, num_);
     }
   }
 private:
-  A allocator;
-  uint32_t num;
-  bool destroy;
+  A allocator_;
+  uint32_t num_;
+  bool destroy_;
 };
 
 template<typename T, typename W, typename H, typename E, typename S, typename A>
@@ -350,7 +350,7 @@
   check_serial_version(serial_version);
   check_family_id(family_id);
   check_size(lg_cur_size, lg_max_size);
-  ensure_minimum_memory(size, 1 << preamble_longs);
+  ensure_minimum_memory(size, 1ULL << preamble_longs);
 
   frequent_items_sketch<T, W, H, E, S, A> sketch(lg_max_size, lg_cur_size, allocator);
   if (!is_empty) {
@@ -431,14 +431,14 @@
   os << "### End sketch summary" << std::endl;
   if (print_items) {
     vector_row items;
-    for (auto &it: map) {
+    for (auto it: map) {
       items.push_back(row(&it.first, it.second, offset));
     }
     // sort by estimate in descending order
     std::sort(items.begin(), items.end(), [](row a, row b){ return a.get_estimate() > b.get_estimate(); });
     os << "### Items in descending order by estimate" << std::endl;
     os << "   item, estimate, lower bound, upper bound" << std::endl;
-    for (auto &it: items) {
+    for (auto it: items) {
       os << "   " << it.get_item() << ", " << it.get_estimate() << ", "
          << it.get_lower_bound() << ", " << it.get_upper_bound() << std::endl;
     }
diff --git a/fi/include/reverse_purge_hash_map_impl.hpp b/fi/include/reverse_purge_hash_map_impl.hpp
index beccea4..0b05d89 100644
--- a/fi/include/reverse_purge_hash_map_impl.hpp
+++ b/fi/include/reverse_purge_hash_map_impl.hpp
@@ -39,15 +39,15 @@
 lg_cur_size_(lg_cur_size),
 lg_max_size_(lg_max_size),
 num_active_(0),
-keys_(allocator_.allocate(1 << lg_cur_size)),
+keys_(allocator_.allocate(1ULL << lg_cur_size)),
 values_(nullptr),
 states_(nullptr)
 {
   AllocV av(allocator_);
-  values_ = av.allocate(1 << lg_cur_size);
+  values_ = av.allocate(1ULL << lg_cur_size);
   AllocU16 au16(allocator_);
-  states_ = au16.allocate(1 << lg_cur_size);
-  std::fill(states_, states_ + (1 << lg_cur_size), 0);
+  states_ = au16.allocate(1ULL << lg_cur_size);
+  std::fill(states_, states_ + (1ULL << lg_cur_size), static_cast<uint16_t>(0));
 }
 
 template<typename K, typename V, typename H, typename E, typename A>
@@ -56,14 +56,14 @@
 lg_cur_size_(other.lg_cur_size_),
 lg_max_size_(other.lg_max_size_),
 num_active_(other.num_active_),
-keys_(allocator_.allocate(1 << lg_cur_size_)),
+keys_(allocator_.allocate(1ULL << lg_cur_size_)),
 values_(nullptr),
 states_(nullptr)
 {
   AllocV av(allocator_);
-  values_ = av.allocate(1 << lg_cur_size_);
+  values_ = av.allocate(1ULL << lg_cur_size_);
   AllocU16 au16(allocator_);
-  states_ = au16.allocate(1 << lg_cur_size_);
+  states_ = au16.allocate(1ULL << lg_cur_size_);
   const uint32_t size = 1 << lg_cur_size_;
   if (num_active_ > 0) {
     auto num = num_active_;
@@ -177,7 +177,7 @@
 
 template<typename K, typename V, typename H, typename E, typename A>
 uint32_t reverse_purge_hash_map<K, V, H, E, A>::get_capacity() const {
-  return (1 << lg_cur_size_) * LOAD_FACTOR;
+  return static_cast<uint32_t>((1 << lg_cur_size_) * LOAD_FACTOR);
 }
 
 template<typename K, typename V, typename H, typename E, typename A>
@@ -246,7 +246,7 @@
   // if none are found, the status is changed
   states_[delete_index] = 0; // mark as empty
   keys_[delete_index].~K();
-  uint32_t drift = 1;
+  uint16_t drift = 1;
   const uint32_t mask = (1 << lg_cur_size_) - 1;
   uint32_t probe = (delete_index + drift) & mask; // map length must be a power of 2
   // advance until we find a free location replacing locations as needed
@@ -322,7 +322,7 @@
   values_ = av.allocate(new_size);
   AllocU16 au16(allocator_);
   states_ = au16.allocate(new_size);
-  std::fill(states_, states_ + new_size, 0);
+  std::fill(states_, states_ + new_size, static_cast<uint16_t>(0));
   num_active_ = 0;
   lg_cur_size_ = lg_new_size;
   for (uint32_t i = 0; i < old_size; i++) {
diff --git a/fi/test/reverse_purge_hash_map_test.cpp b/fi/test/reverse_purge_hash_map_test.cpp
index a74345c..fedda6b 100644
--- a/fi/test/reverse_purge_hash_map_test.cpp
+++ b/fi/test/reverse_purge_hash_map_test.cpp
@@ -39,8 +39,8 @@
 TEST_CASE("reverse purge hash map: iterator", "[frequent_items_sketch]") {
   reverse_purge_hash_map<int> map(3, 4, std::allocator<int>());
   for (int i = 0; i < 11; i++) map.adjust_or_insert(i, 1); // this should fit with no purge
-  int sum = 0;
-  for (auto &it: map) sum += it.second;
+  uint64_t sum = 0;
+  for (auto it: map) sum += it.second;
   REQUIRE(sum == 11);
 }
 
diff --git a/hll/include/AuxHashMap-internal.hpp b/hll/include/AuxHashMap-internal.hpp
index dbc7f84..751c74a 100644
--- a/hll/include/AuxHashMap-internal.hpp
+++ b/hll/include/AuxHashMap-internal.hpp
@@ -26,15 +26,15 @@
 namespace datasketches {
 
 template<typename A>
-AuxHashMap<A>::AuxHashMap(int lgAuxArrInts, int lgConfigK, const A& allocator):
+AuxHashMap<A>::AuxHashMap(uint8_t lgAuxArrInts, uint8_t lgConfigK, const A& allocator):
 lgConfigK(lgConfigK),
 lgAuxArrInts(lgAuxArrInts),
 auxCount(0),
-entries(1 << lgAuxArrInts, 0, allocator)
+entries(1ULL << lgAuxArrInts, 0, allocator)
 {}
 
 template<typename A>
-AuxHashMap<A>* AuxHashMap<A>::newAuxHashMap(int lgAuxArrInts, int lgConfigK, const A& allocator) {
+AuxHashMap<A>* AuxHashMap<A>::newAuxHashMap(uint8_t lgAuxArrInts, uint8_t lgConfigK, const A& allocator) {
   return new (ahmAlloc(allocator).allocate(1)) AuxHashMap<A>(lgAuxArrInts, lgConfigK, allocator);
 }
 
@@ -45,42 +45,42 @@
 
 template<typename A>
 AuxHashMap<A>* AuxHashMap<A>::deserialize(const void* bytes, size_t len,
-                                          int lgConfigK,
-                                          int auxCount, int lgAuxArrInts,
+                                          uint8_t lgConfigK,
+                                          uint32_t auxCount, uint8_t lgAuxArrInts,
                                           bool srcCompact, const A& allocator) {
-  int lgArrInts = lgAuxArrInts;
+  uint8_t lgArrInts = lgAuxArrInts;
   if (srcCompact) { // early compact versions didn't use LgArr byte field so ignore input
     lgArrInts = HllUtil<A>::computeLgArrInts(HLL, auxCount, lgConfigK);
   } else { // updatable
     lgArrInts = lgAuxArrInts;
   }
   
-  int configKmask = (1 << lgConfigK) - 1;
+  const uint32_t configKmask = (1 << lgConfigK) - 1;
 
   AuxHashMap<A>* auxHashMap;
-  const int* auxPtr = static_cast<const int*>(bytes);
+  const uint32_t* auxPtr = static_cast<const uint32_t*>(bytes);
   if (srcCompact) {
     if (len < auxCount * sizeof(int)) {
       throw std::out_of_range("Input array too small to hold AuxHashMap image");
     }
     auxHashMap = new (ahmAlloc(allocator).allocate(1)) AuxHashMap<A>(lgArrInts, lgConfigK, allocator);
-    for (int i = 0; i < auxCount; ++i) {
-      int pair = auxPtr[i];
-      int slotNo = HllUtil<A>::getLow26(pair) & configKmask;
-      int value = HllUtil<A>::getValue(pair);
+    for (uint32_t i = 0; i < auxCount; ++i) {
+      const uint32_t pair = auxPtr[i];
+      const uint32_t slotNo = HllUtil<A>::getLow26(pair) & configKmask;
+      const uint8_t value = HllUtil<A>::getValue(pair);
       auxHashMap->mustAdd(slotNo, value);
     }
   } else { // updatable
-    int itemsToRead = 1 << lgAuxArrInts;
-    if (len < itemsToRead * sizeof(int)) {
+    uint32_t itemsToRead = 1 << lgAuxArrInts;
+    if (len < itemsToRead * sizeof(uint32_t)) {
       throw std::out_of_range("Input array too small to hold AuxHashMap image");
     }
     auxHashMap = new (ahmAlloc(allocator).allocate(1)) AuxHashMap<A>(lgArrInts, lgConfigK, allocator);
-    for (int i = 0; i < itemsToRead; ++i) {
-      int pair = auxPtr[i];
-      if (pair == HllUtil<A>::EMPTY) { continue; }
-      int slotNo = HllUtil<A>::getLow26(pair) & configKmask;
-      int value = HllUtil<A>::getValue(pair);
+    for (uint32_t i = 0; i < itemsToRead; ++i) {
+      const uint32_t pair = auxPtr[i];
+      if (pair == hll_constants::EMPTY) { continue; }
+      const uint32_t slotNo = HllUtil<A>::getLow26(pair) & configKmask;
+      const uint8_t value = HllUtil<A>::getValue(pair);
       auxHashMap->mustAdd(slotNo, value);
     }
   }
@@ -94,10 +94,10 @@
 }
 
 template<typename A>
-AuxHashMap<A>* AuxHashMap<A>::deserialize(std::istream& is, const int lgConfigK,
-                                          const int auxCount, const int lgAuxArrInts,
-                                          const bool srcCompact, const A& allocator) {
-  int lgArrInts = lgAuxArrInts;
+AuxHashMap<A>* AuxHashMap<A>::deserialize(std::istream& is, uint8_t lgConfigK,
+                                          uint32_t auxCount, uint8_t lgAuxArrInts,
+                                          bool srcCompact, const A& allocator) {
+  uint8_t lgArrInts = lgAuxArrInts;
   if (srcCompact) { // early compact versions didn't use LgArr byte field so ignore input
     lgArrInts = HllUtil<A>::computeLgArrInts(HLL, auxCount, lgConfigK);
   } else { // updatable
@@ -108,22 +108,22 @@
   typedef std::unique_ptr<AuxHashMap<A>, std::function<void(AuxHashMap<A>*)>> aux_hash_map_ptr;
   aux_hash_map_ptr aux_ptr(auxHashMap, auxHashMap->make_deleter());
 
-  int configKmask = (1 << lgConfigK) - 1;
+  const uint32_t configKmask = (1 << lgConfigK) - 1;
 
   if (srcCompact) {
-    for (int i = 0; i < auxCount; ++i) {
+    for (uint32_t i = 0; i < auxCount; ++i) {
       const auto pair = read<int>(is);
-      int slotNo = HllUtil<A>::getLow26(pair) & configKmask;
-      int value = HllUtil<A>::getValue(pair);
+      uint32_t slotNo = HllUtil<A>::getLow26(pair) & configKmask;
+      uint8_t value = HllUtil<A>::getValue(pair);
       auxHashMap->mustAdd(slotNo, value);
     }
   } else { // updatable
-    int itemsToRead = 1 << lgAuxArrInts;
-    for (int i = 0; i < itemsToRead; ++i) {
+    const uint32_t itemsToRead = 1 << lgAuxArrInts;
+    for (uint32_t i = 0; i < itemsToRead; ++i) {
       const auto pair = read<int>(is);
-      if (pair == HllUtil<A>::EMPTY) { continue; }
-      int slotNo = HllUtil<A>::getLow26(pair) & configKmask;
-      int value = HllUtil<A>::getValue(pair);
+      if (pair == hll_constants::EMPTY) { continue; }
+      const uint32_t slotNo = HllUtil<A>::getLow26(pair) & configKmask;
+      const uint8_t value = HllUtil<A>::getValue(pair);
       auxHashMap->mustAdd(slotNo, value);
     }
   }
@@ -151,34 +151,34 @@
 }
 
 template<typename A>
-int AuxHashMap<A>::getAuxCount() const {
+uint32_t AuxHashMap<A>::getAuxCount() const {
   return auxCount;
 }
 
 template<typename A>
-int* AuxHashMap<A>::getAuxIntArr(){
+uint32_t* AuxHashMap<A>::getAuxIntArr(){
   return entries.data();
 }
 
 template<typename A>
-int AuxHashMap<A>::getLgAuxArrInts() const {
+uint8_t AuxHashMap<A>::getLgAuxArrInts() const {
   return lgAuxArrInts;
 }
 
 template<typename A>
-int AuxHashMap<A>::getCompactSizeBytes() const {
+uint32_t AuxHashMap<A>::getCompactSizeBytes() const {
   return auxCount << 2;
 }
 
 template<typename A>
-int AuxHashMap<A>::getUpdatableSizeBytes() const {
+uint32_t AuxHashMap<A>::getUpdatableSizeBytes() const {
   return 4 << lgAuxArrInts;
 }
 
 template<typename A>
-void AuxHashMap<A>::mustAdd(const int slotNo, const int value) {
-  const int index = find(entries.data(), lgAuxArrInts, lgConfigK, slotNo);
-  const int entry_pair = HllUtil<A>::pair(slotNo, value);
+void AuxHashMap<A>::mustAdd(uint32_t slotNo, uint8_t value) {
+  const int32_t index = find(entries.data(), lgAuxArrInts, lgConfigK, slotNo);
+  const uint32_t entry_pair = HllUtil<A>::pair(slotNo, value);
   if (index >= 0) {
     throw std::invalid_argument("Found a slotNo that should not be there: SlotNo: "
                                 + std::to_string(slotNo) + ", Value: " + std::to_string(value));
@@ -191,8 +191,8 @@
 }
 
 template<typename A>
-int AuxHashMap<A>::mustFindValueFor(const int slotNo) const {
-  const int index = find(entries.data(), lgAuxArrInts, lgConfigK, slotNo);
+uint8_t AuxHashMap<A>::mustFindValueFor(uint32_t slotNo) const {
+  const int32_t index = find(entries.data(), lgAuxArrInts, lgConfigK, slotNo);
   if (index >= 0) {
     return HllUtil<A>::getValue(entries[index]);
   }
@@ -201,8 +201,8 @@
 }
 
 template<typename A>
-void AuxHashMap<A>::mustReplace(const int slotNo, const int value) {
-  const int idx = find(entries.data(), lgAuxArrInts, lgConfigK, slotNo);
+void AuxHashMap<A>::mustReplace(uint32_t slotNo, uint8_t value) {
+  const int32_t idx = find(entries.data(), lgAuxArrInts, lgConfigK, slotNo);
   if (idx >= 0) {
     entries[idx] = HllUtil<A>::pair(slotNo, value);
     return;
@@ -214,7 +214,7 @@
 
 template<typename A>
 void AuxHashMap<A>::checkGrow() {
-  if ((HllUtil<A>::RESIZE_DENOM * auxCount) > (HllUtil<A>::RESIZE_NUMER * (1 << lgAuxArrInts))) {
+  if ((hll_constants::RESIZE_DENOM * auxCount) > (hll_constants::RESIZE_NUMER * (1 << lgAuxArrInts))) {
     growAuxSpace();
   }
 }
@@ -225,10 +225,10 @@
   const int newArrLen = 1 << ++lgAuxArrInts;
   vector_int entries_new(newArrLen, 0, entries.get_allocator());
   for (size_t i = 0; i < entries.size(); ++i) {
-    const int fetched = entries[i];
-    if (fetched != HllUtil<A>::EMPTY) {
+    const uint32_t fetched = entries[i];
+    if (fetched != hll_constants::EMPTY) {
       // find empty in new array
-      const int idx = find(entries_new.data(), lgAuxArrInts, lgConfigK, fetched & configKmask);
+      const int32_t idx = find(entries_new.data(), lgAuxArrInts, lgConfigK, fetched & configKmask);
       entries_new[~idx] = fetched;
     }
   }
@@ -241,21 +241,20 @@
 //Continues searching.
 //If the probe comes back to original index, throws an exception.
 template<typename A>
-int AuxHashMap<A>::find(const int* auxArr, const int lgAuxArrInts, const int lgConfigK,
-                        const int slotNo) {
-  const int auxArrMask = (1 << lgAuxArrInts) - 1;
-  const int configKmask = (1 << lgConfigK) - 1;
-  int probe = slotNo & auxArrMask;
-  const  int loopIndex = probe;
+int32_t AuxHashMap<A>::find(const uint32_t* auxArr, uint8_t lgAuxArrInts, uint8_t lgConfigK, uint32_t slotNo) {
+  const uint32_t auxArrMask = (1 << lgAuxArrInts) - 1;
+  const uint32_t configKmask = (1 << lgConfigK) - 1;
+  uint32_t probe = slotNo & auxArrMask;
+  const uint32_t loopIndex = probe;
   do {
-    const int arrVal = auxArr[probe];
-    if (arrVal == HllUtil<A>::EMPTY) { //Compares on entire entry
+    const uint32_t arrVal = auxArr[probe];
+    if (arrVal == hll_constants::EMPTY) { //Compares on entire entry
       return ~probe; //empty
     }
     else if (slotNo == (arrVal & configKmask)) { //Compares only on slotNo
       return probe; //found given slotNo, return probe = index into aux array
     }
-    const int stride = (slotNo >> lgAuxArrInts) | 1;
+    const uint32_t stride = (slotNo >> lgAuxArrInts) | 1;
     probe = (probe + stride) & auxArrMask;
   } while (probe != loopIndex);
   throw std::runtime_error("Key not found and no empty slots!");
@@ -263,12 +262,12 @@
 
 template<typename A>
 coupon_iterator<A> AuxHashMap<A>::begin(bool all) const {
-  return coupon_iterator<A>(entries.data(), 1 << lgAuxArrInts, 0, all);
+  return coupon_iterator<A>(entries.data(), 1ULL << lgAuxArrInts, 0, all);
 }
 
 template<typename A>
 coupon_iterator<A> AuxHashMap<A>::end() const {
-  return coupon_iterator<A>(entries.data(), 1 << lgAuxArrInts, 1 << lgAuxArrInts, false);
+  return coupon_iterator<A>(entries.data(), 1ULL << lgAuxArrInts, 1ULL << lgAuxArrInts, false);
 }
 
 }
diff --git a/hll/include/AuxHashMap.hpp b/hll/include/AuxHashMap.hpp
index e18f15d..d4b155b 100644
--- a/hll/include/AuxHashMap.hpp
+++ b/hll/include/AuxHashMap.hpp
@@ -31,49 +31,49 @@
 template<typename A>
 class AuxHashMap final {
   public:
-    AuxHashMap(int lgAuxArrInts, int lgConfigK, const A& allocator);
-    static AuxHashMap* newAuxHashMap(int lgAuxArrInts, int lgConfigK, const A& allocator);
+    AuxHashMap(uint8_t lgAuxArrInts, uint8_t lgConfigK, const A& allocator);
+    static AuxHashMap* newAuxHashMap(uint8_t lgAuxArrInts, uint8_t lgConfigK, const A& allocator);
     static AuxHashMap* newAuxHashMap(const AuxHashMap<A>& that);
 
     static AuxHashMap* deserialize(const void* bytes, size_t len,
-                                   int lgConfigK,
-                                   int auxCount, int lgAuxArrInts,
+                                   uint8_t lgConfigK,
+                                   uint32_t auxCount, uint8_t lgAuxArrInts,
                                    bool srcCompact, const A& allocator);
-    static AuxHashMap* deserialize(std::istream& is, int lgConfigK,
-                                   int auxCount, int lgAuxArrInts,
+    static AuxHashMap* deserialize(std::istream& is, uint8_t lgConfigK,
+                                   uint32_t auxCount, uint8_t lgAuxArrInts,
                                    bool srcCompact, const A& allocator);
     virtual ~AuxHashMap() = default;
     static std::function<void(AuxHashMap<A>*)> make_deleter();
     
     AuxHashMap* copy() const;
-    int getUpdatableSizeBytes() const;
-    int getCompactSizeBytes() const;
+    uint32_t getUpdatableSizeBytes() const;
+    uint32_t getCompactSizeBytes() const;
 
-    int getAuxCount() const;
-    int* getAuxIntArr();
-    int getLgAuxArrInts() const;
+    uint32_t getAuxCount() const;
+    uint32_t* getAuxIntArr();
+    uint8_t getLgAuxArrInts() const;
 
     coupon_iterator<A> begin(bool all = false) const;
     coupon_iterator<A> end() const;
 
-    void mustAdd(int slotNo, int value);
-    int mustFindValueFor(int slotNo) const;
-    void mustReplace(int slotNo, int value);
+    void mustAdd(uint32_t slotNo, uint8_t value);
+    uint8_t mustFindValueFor(uint32_t slotNo) const;
+    void mustReplace(uint32_t slotNo, uint8_t value);
 
   private:
     typedef typename std::allocator_traits<A>::template rebind_alloc<AuxHashMap<A>> ahmAlloc;
 
-    using vector_int = std::vector<int, typename std::allocator_traits<A>::template rebind_alloc<int>>;
+    using vector_int = std::vector<uint32_t, typename std::allocator_traits<A>::template rebind_alloc<uint32_t>>;
 
     // static so it can be used when resizing
-    static int find(const int* auxArr, int lgAuxArrInts, int lgConfigK, int slotNo);
+    static int32_t find(const uint32_t* auxArr, uint8_t lgAuxArrInts, uint8_t lgConfigK, uint32_t slotNo);
 
     void checkGrow();
     void growAuxSpace();
 
-    const int lgConfigK;
-    int lgAuxArrInts;
-    int auxCount;
+    const uint8_t lgConfigK;
+    uint8_t lgAuxArrInts;
+    uint32_t auxCount;
     vector_int entries;
 };
 
diff --git a/hll/include/CompositeInterpolationXTable-internal.hpp b/hll/include/CompositeInterpolationXTable-internal.hpp
index 10aa047..0f6cae6 100644
--- a/hll/include/CompositeInterpolationXTable-internal.hpp
+++ b/hll/include/CompositeInterpolationXTable-internal.hpp
@@ -27,30 +27,30 @@
 
 namespace datasketches {
 
-static const int numXArrValues = 257;
+static const uint32_t numXArrValues = 257;
 
 /**
  * 18 Values, index 0 is LgK = 4, index 17 is LgK = 21.
  */
-static const int yStrides[] =
+static const uint32_t yStrides[] =
   {1, 2, 3, 5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120, 10240, 20480, 40960, 81920};
 
 template<typename A>
-int CompositeInterpolationXTable<A>::get_y_stride(const int logK) {
-  if (logK < HllUtil<A>::MIN_LOG_K || logK > HllUtil<A>::MAX_LOG_K) {
-    throw std::invalid_argument("logK must be in range [" + std::to_string(HllUtil<A>::MIN_LOG_K)
-                                + ", " + std::to_string(HllUtil<A>::MAX_LOG_K) + "]. Found: "
+uint32_t CompositeInterpolationXTable<A>::get_y_stride(uint8_t logK) {
+  if (logK < hll_constants::MIN_LOG_K || logK > hll_constants::MAX_LOG_K) {
+    throw std::invalid_argument("logK must be in range [" + std::to_string(hll_constants::MIN_LOG_K)
+                                + ", " + std::to_string(hll_constants::MAX_LOG_K) + "]. Found: "
                                 + std::to_string(logK));
   }
-  return yStrides[logK - HllUtil<A>::MIN_LOG_K];
+  return yStrides[logK - hll_constants::MIN_LOG_K];
 }
 
 template<typename A>
-int CompositeInterpolationXTable<A>::get_x_arr_length() {
+uint32_t CompositeInterpolationXTable<A>::get_x_arr_length() {
   return numXArrValues;
 }
 
-static const double xArr[18][numXArrValues] = {
+static const double xArray[18][numXArrValues] = {
 {
   10.767999803534, 11.237701481774, 11.722738717438, 12.223246391222,
   12.739366773787, 13.271184824495, 13.818759686650, 14.382159835785,
@@ -797,15 +797,15 @@
 };
 
 template<typename A>
-const double* CompositeInterpolationXTable<A>::get_x_arr(const int logK) {
-  if (logK < HllUtil<A>::MIN_LOG_K || logK > HllUtil<A>::MAX_LOG_K) {
-    throw std::invalid_argument("logK must be in range [" + std::to_string(HllUtil<A>::MIN_LOG_K)
-                                + ", " + std::to_string(HllUtil<A>::MAX_LOG_K) + "]. Found: "
+const double* CompositeInterpolationXTable<A>::get_x_arr(uint8_t logK) {
+  if (logK < hll_constants::MIN_LOG_K || logK > hll_constants::MAX_LOG_K) {
+    throw std::invalid_argument("logK must be in range [" + std::to_string(hll_constants::MIN_LOG_K)
+                                + ", " + std::to_string(hll_constants::MAX_LOG_K) + "]. Found: "
                                 + std::to_string(logK));
   }
-  return xArr[logK - HllUtil<A>::MIN_LOG_K];
+  return xArray[logK - hll_constants::MIN_LOG_K];
 }
 
 }
 
-#endif // _COMPOSITEINTERPOLATIONXTABLE_INTERNAL_HPP_
\ No newline at end of file
+#endif // _COMPOSITEINTERPOLATIONXTABLE_INTERNAL_HPP_
diff --git a/hll/include/CompositeInterpolationXTable.hpp b/hll/include/CompositeInterpolationXTable.hpp
index 0fa0af8..4370115 100644
--- a/hll/include/CompositeInterpolationXTable.hpp
+++ b/hll/include/CompositeInterpolationXTable.hpp
@@ -27,10 +27,10 @@
 template<typename A = std::allocator<uint8_t>>
 class CompositeInterpolationXTable {
   public:
-    static int get_y_stride(int logK);
+    static uint32_t get_y_stride(uint8_t logK);
 
-    static const double* get_x_arr(int logK);
-    static int get_x_arr_length();
+    static const double* get_x_arr(uint8_t logK);
+    static uint32_t get_x_arr_length();
 };
 
 }
diff --git a/hll/include/CouponHashSet-internal.hpp b/hll/include/CouponHashSet-internal.hpp
index 67237db..e7b5768 100644
--- a/hll/include/CouponHashSet-internal.hpp
+++ b/hll/include/CouponHashSet-internal.hpp
@@ -28,10 +28,10 @@
 namespace datasketches {
 
 template<typename A>
-static int find(const int* array, const int lgArrInts, const int coupon);
+static int32_t find(const uint32_t* array, uint8_t lgArrInts, uint32_t coupon);
 
 template<typename A>
-CouponHashSet<A>::CouponHashSet(const int lgConfigK, const target_hll_type tgtHllType, const A& allocator)
+CouponHashSet<A>::CouponHashSet(uint8_t lgConfigK, target_hll_type tgtHllType, const A& allocator)
   : CouponList<A>(lgConfigK, tgtHllType, hll_mode::SET, allocator)
 {
   if (lgConfigK <= 7) {
@@ -56,45 +56,45 @@
 
 template<typename A>
 CouponHashSet<A>* CouponHashSet<A>::newSet(const void* bytes, size_t len, const A& allocator) {
-  if (len < HllUtil<A>::HASH_SET_INT_ARR_START) { // hard-coded 
+  if (len < hll_constants::HASH_SET_INT_ARR_START) { // hard-coded
     throw std::out_of_range("Input data length insufficient to hold CouponHashSet");
   }
 
   const uint8_t* data = static_cast<const uint8_t*>(bytes);
-  if (data[HllUtil<A>::PREAMBLE_INTS_BYTE] != HllUtil<A>::HASH_SET_PREINTS) {
+  if (data[hll_constants::PREAMBLE_INTS_BYTE] != hll_constants::HASH_SET_PREINTS) {
     throw std::invalid_argument("Incorrect number of preInts in input stream");
   }
-  if (data[HllUtil<A>::SER_VER_BYTE] != HllUtil<A>::SER_VER) {
+  if (data[hll_constants::SER_VER_BYTE] != hll_constants::SER_VER) {
     throw std::invalid_argument("Wrong ser ver in input stream");
   }
-  if (data[HllUtil<A>::FAMILY_BYTE] != HllUtil<A>::FAMILY_ID) {
+  if (data[hll_constants::FAMILY_BYTE] != hll_constants::FAMILY_ID) {
     throw std::invalid_argument("Input stream is not an HLL sketch");
   }
 
-  const hll_mode mode = HllSketchImpl<A>::extractCurMode(data[HllUtil<A>::MODE_BYTE]);
+  const hll_mode mode = HllSketchImpl<A>::extractCurMode(data[hll_constants::MODE_BYTE]);
   if (mode != SET) {
     throw std::invalid_argument("Calling set constructor with non-set mode data");
   }
 
-  const target_hll_type tgtHllType = HllSketchImpl<A>::extractTgtHllType(data[HllUtil<A>::MODE_BYTE]);
+  const target_hll_type tgtHllType = HllSketchImpl<A>::extractTgtHllType(data[hll_constants::MODE_BYTE]);
 
-  const int lgK = data[HllUtil<A>::LG_K_BYTE];
+  const uint8_t lgK = data[hll_constants::LG_K_BYTE];
   if (lgK <= 7) {
     throw std::invalid_argument("Attempt to deserialize invalid CouponHashSet with lgConfigK <= 7. Found: "
                                 + std::to_string(lgK));
   }   
-  int lgArrInts = data[HllUtil<A>::LG_ARR_BYTE];
-  const bool compactFlag = ((data[HllUtil<A>::FLAGS_BYTE] & HllUtil<A>::COMPACT_FLAG_MASK) ? true : false);
+  uint8_t lgArrInts = data[hll_constants::LG_ARR_BYTE];
+  const bool compactFlag = ((data[hll_constants::FLAGS_BYTE] & hll_constants::COMPACT_FLAG_MASK) ? true : false);
 
-  int couponCount;
-  std::memcpy(&couponCount, data + HllUtil<A>::HASH_SET_COUNT_INT, sizeof(couponCount));
-  if (lgArrInts < HllUtil<A>::LG_INIT_SET_SIZE) { 
-    lgArrInts = HllUtil<A>::computeLgArrInts(SET, couponCount, lgK);
+  uint32_t couponCount;
+  std::memcpy(&couponCount, data + hll_constants::HASH_SET_COUNT_INT, sizeof(couponCount));
+  if (lgArrInts < hll_constants::LG_INIT_SET_SIZE) {
+    lgArrInts = HllUtil<>::computeLgArrInts(SET, couponCount, lgK);
   }
   // Don't set couponCount in sketch here;
   // we'll set later if updatable, and increment with updates if compact
-  const int couponsInArray = (compactFlag ? couponCount : (1 << lgArrInts));
-  const size_t expectedLength = HllUtil<A>::HASH_SET_INT_ARR_START + (couponsInArray * sizeof(int));
+  const uint32_t couponsInArray = (compactFlag ? couponCount : (1 << lgArrInts));
+  const size_t expectedLength = hll_constants::HASH_SET_INT_ARR_START + (couponsInArray * sizeof(uint32_t));
   if (len < expectedLength) {
     throw std::out_of_range("Byte array too short for sketch. Expected " + std::to_string(expectedLength)
                                 + ", found: " + std::to_string(len));
@@ -104,19 +104,19 @@
   CouponHashSet<A>* sketch = new (chsa.allocate(1)) CouponHashSet<A>(lgK, tgtHllType, allocator);
 
   if (compactFlag) {
-    const uint8_t* curPos = data + HllUtil<A>::HASH_SET_INT_ARR_START;
-    int coupon;
-    for (int i = 0; i < couponCount; ++i, curPos += sizeof(coupon)) {
+    const uint8_t* curPos = data + hll_constants::HASH_SET_INT_ARR_START;
+    uint32_t coupon;
+    for (uint32_t i = 0; i < couponCount; ++i, curPos += sizeof(coupon)) {
       std::memcpy(&coupon, curPos, sizeof(coupon));
       sketch->couponUpdate(coupon);
     }
   } else {
-    sketch->coupons.resize(1 << lgArrInts);
-    sketch->couponCount = couponCount;
+    sketch->coupons_.resize(1ULL << lgArrInts);
+    sketch->couponCount_ = couponCount;
     // only need to read valid coupons, unlike in stream case
-    std::memcpy(sketch->coupons.data(),
-                data + HllUtil<A>::HASH_SET_INT_ARR_START,
-                couponCount * sizeof(int));
+    std::memcpy(sketch->coupons_.data(),
+                data + hll_constants::HASH_SET_INT_ARR_START,
+                couponCount * sizeof(uint32_t));
   }
 
   return sketch;
@@ -127,34 +127,34 @@
   uint8_t listHeader[8];
   read(is, listHeader, 8 * sizeof(uint8_t));
 
-  if (listHeader[HllUtil<A>::PREAMBLE_INTS_BYTE] != HllUtil<A>::HASH_SET_PREINTS) {
+  if (listHeader[hll_constants::PREAMBLE_INTS_BYTE] != hll_constants::HASH_SET_PREINTS) {
     throw std::invalid_argument("Incorrect number of preInts in input stream");
   }
-  if (listHeader[HllUtil<A>::SER_VER_BYTE] != HllUtil<A>::SER_VER) {
+  if (listHeader[hll_constants::SER_VER_BYTE] != hll_constants::SER_VER) {
     throw std::invalid_argument("Wrong ser ver in input stream");
   }
-  if (listHeader[HllUtil<A>::FAMILY_BYTE] != HllUtil<A>::FAMILY_ID) {
+  if (listHeader[hll_constants::FAMILY_BYTE] != hll_constants::FAMILY_ID) {
     throw std::invalid_argument("Input stream is not an HLL sketch");
   }
 
-  hll_mode mode = HllSketchImpl<A>::extractCurMode(listHeader[HllUtil<A>::MODE_BYTE]);
+  hll_mode mode = HllSketchImpl<A>::extractCurMode(listHeader[hll_constants::MODE_BYTE]);
   if (mode != SET) {
     throw std::invalid_argument("Calling set constructor with non-set mode data");
   }
 
-  target_hll_type tgtHllType = HllSketchImpl<A>::extractTgtHllType(listHeader[HllUtil<A>::MODE_BYTE]);
+  const target_hll_type tgtHllType = HllSketchImpl<A>::extractTgtHllType(listHeader[hll_constants::MODE_BYTE]);
 
-  const int lgK = listHeader[HllUtil<A>::LG_K_BYTE];
+  const uint8_t lgK = listHeader[hll_constants::LG_K_BYTE];
   if (lgK <= 7) {
     throw std::invalid_argument("Attempt to deserialize invalid CouponHashSet with lgConfigK <= 7. Found: "
                                 + std::to_string(lgK));
   }
-  int lgArrInts = listHeader[HllUtil<A>::LG_ARR_BYTE];
-  const bool compactFlag = ((listHeader[HllUtil<A>::FLAGS_BYTE] & HllUtil<A>::COMPACT_FLAG_MASK) ? true : false);
+  uint8_t lgArrInts = listHeader[hll_constants::LG_ARR_BYTE];
+  const bool compactFlag = ((listHeader[hll_constants::FLAGS_BYTE] & hll_constants::COMPACT_FLAG_MASK) ? true : false);
 
-  const auto couponCount = read<int>(is);
-  if (lgArrInts < HllUtil<A>::LG_INIT_SET_SIZE) { 
-    lgArrInts = HllUtil<A>::computeLgArrInts(SET, couponCount, lgK);
+  const auto couponCount = read<uint32_t>(is);
+  if (lgArrInts < hll_constants::LG_INIT_SET_SIZE) {
+    lgArrInts = HllUtil<>::computeLgArrInts(SET, couponCount, lgK);
   }
 
   ChsAlloc chsa(allocator);
@@ -165,15 +165,15 @@
   // Don't set couponCount here;
   // we'll set later if updatable, and increment with updates if compact
   if (compactFlag) {
-    for (int i = 0; i < couponCount; ++i) {
-      const auto coupon = read<int>(is);
+    for (uint32_t i = 0; i < couponCount; ++i) {
+      const auto coupon = read<uint32_t>(is);
       sketch->couponUpdate(coupon);
     }
   } else {
-    sketch->coupons.resize(1 << lgArrInts);
-    sketch->couponCount = couponCount;
+    sketch->coupons_.resize(1ULL << lgArrInts);
+    sketch->couponCount_ = couponCount;
     // for stream processing, read entire list so read pointer ends up set correctly
-    read(is, sketch->coupons.data(), sketch->coupons.size() * sizeof(int));
+    read(is, sketch->coupons_.data(), sketch->coupons_.size() * sizeof(uint32_t));
   } 
 
   if (!is.good())
@@ -184,25 +184,25 @@
 
 template<typename A>
 CouponHashSet<A>* CouponHashSet<A>::copy() const {
-  ChsAlloc chsa(this->coupons.get_allocator());
+  ChsAlloc chsa(this->coupons_.get_allocator());
   return new (chsa.allocate(1)) CouponHashSet<A>(*this);
 }
 
 template<typename A>
-CouponHashSet<A>* CouponHashSet<A>::copyAs(const target_hll_type tgtHllType) const {
-  ChsAlloc chsa(this->coupons.get_allocator());
+CouponHashSet<A>* CouponHashSet<A>::copyAs(target_hll_type tgtHllType) const {
+  ChsAlloc chsa(this->coupons_.get_allocator());
   return new (chsa.allocate(1)) CouponHashSet<A>(*this, tgtHllType);
 }
 
 template<typename A>
-HllSketchImpl<A>* CouponHashSet<A>::couponUpdate(int coupon) {
-  const uint8_t lgCouponArrInts = count_trailing_zeros_in_u32(this->coupons.size());
-  const int index = find<A>(this->coupons.data(), lgCouponArrInts, coupon);
+HllSketchImpl<A>* CouponHashSet<A>::couponUpdate(uint32_t coupon) {
+  const uint8_t lgCouponArrInts = count_trailing_zeros_in_u32(static_cast<uint32_t>(this->coupons_.size()));
+  const int32_t index = find<A>(this->coupons_.data(), lgCouponArrInts, coupon);
   if (index >= 0) {
     return this; // found duplicate, ignore
   }
-  this->coupons[~index] = coupon; // found empty
-  ++this->couponCount;
+  this->coupons_[~index] = coupon; // found empty
+  ++this->couponCount_;
   if (checkGrowOrPromote()) {
     return this->promoteHeapListOrSetToHll(*this);
   }
@@ -210,20 +210,20 @@
 }
 
 template<typename A>
-int CouponHashSet<A>::getMemDataStart() const {
-  return HllUtil<A>::HASH_SET_INT_ARR_START;
+uint32_t CouponHashSet<A>::getMemDataStart() const {
+  return hll_constants::HASH_SET_INT_ARR_START;
 }
 
 template<typename A>
-int CouponHashSet<A>::getPreInts() const {
-  return HllUtil<A>::HASH_SET_PREINTS;
+uint8_t CouponHashSet<A>::getPreInts() const {
+  return hll_constants::HASH_SET_PREINTS;
 }
 
 template<typename A>
 bool CouponHashSet<A>::checkGrowOrPromote() {
-  if (static_cast<size_t>(HllUtil<A>::RESIZE_DENOM * this->couponCount) > (HllUtil<A>::RESIZE_NUMER * this->coupons.size())) {
-    const uint8_t lgCouponArrInts = count_trailing_zeros_in_u32(this->coupons.size());
-    if (lgCouponArrInts == (this->lgConfigK - 3)) { // at max size
+  if (static_cast<size_t>(hll_constants::RESIZE_DENOM * this->couponCount_) > (hll_constants::RESIZE_NUMER * this->coupons_.size())) {
+    const uint8_t lgCouponArrInts = count_trailing_zeros_in_u32(static_cast<uint32_t>(this->coupons_.size()));
+    if (lgCouponArrInts == (this->lgConfigK_ - 3)) { // at max size
       return true; // promote to HLL
     }
     growHashSet(lgCouponArrInts + 1);
@@ -232,15 +232,15 @@
 }
 
 template<typename A>
-void CouponHashSet<A>::growHashSet(int tgtLgCoupArrSize) {
-  const int tgtLen = 1 << tgtLgCoupArrSize;
-  vector_int coupons_new(tgtLen, 0, this->coupons.get_allocator());
+void CouponHashSet<A>::growHashSet(uint8_t tgtLgCoupArrSize) {
+  const uint32_t tgtLen = 1 << tgtLgCoupArrSize;
+  vector_int coupons_new(tgtLen, 0, this->coupons_.get_allocator());
 
-  const int srcLen = this->coupons.size();
-  for (int i = 0; i < srcLen; ++i) { // scan existing array for non-zero values
-    const int fetched = this->coupons[i];
-    if (fetched != HllUtil<A>::EMPTY) {
-      const int idx = find<A>(coupons_new.data(), tgtLgCoupArrSize, fetched); // search TGT array
+  const uint32_t srcLen = static_cast<uint32_t>(this->coupons_.size());
+  for (uint32_t i = 0; i < srcLen; ++i) { // scan existing array for non-zero values
+    const uint32_t fetched = this->coupons_[i];
+    if (fetched != hll_constants::EMPTY) {
+      const int32_t idx = find<A>(coupons_new.data(), tgtLgCoupArrSize, fetched); // search TGT array
       if (idx < 0) { // found EMPTY
         coupons_new[~idx] = fetched; // insert
         continue;
@@ -248,23 +248,23 @@
       throw std::runtime_error("Error: Found duplicate coupon");
     }
   }
-  this->coupons = std::move(coupons_new);
+  this->coupons_ = std::move(coupons_new);
 }
 
 template<typename A>
-static int find(const int* array, const int lgArrInts, const int coupon) {
-  const int arrMask = (1 << lgArrInts) - 1;
-  int probe = coupon & arrMask;
-  const int loopIndex = probe;
+static int32_t find(const uint32_t* array, uint8_t lgArrInts, uint32_t coupon) {
+  const uint32_t arrMask = (1 << lgArrInts) - 1;
+  uint32_t probe = coupon & arrMask;
+  const uint32_t loopIndex = probe;
   do {
-    const int couponAtIdx = array[probe];
-    if (couponAtIdx == HllUtil<A>::EMPTY) {
+    const uint32_t couponAtIdx = array[probe];
+    if (couponAtIdx == hll_constants::EMPTY) {
       return ~probe; //empty
     }
     else if (coupon == couponAtIdx) {
       return probe; //duplicate
     }
-    const int stride = ((coupon & HllUtil<A>::KEY_MASK_26) >> lgArrInts) | 1;
+    const uint32_t stride = ((coupon & hll_constants::KEY_MASK_26) >> lgArrInts) | 1;
     probe = (probe + stride) & arrMask;
   } while (probe != loopIndex);
   throw std::invalid_argument("Key not found and no empty slots!");
diff --git a/hll/include/CouponHashSet.hpp b/hll/include/CouponHashSet.hpp
index b9b99b7..fd22106 100644
--- a/hll/include/CouponHashSet.hpp
+++ b/hll/include/CouponHashSet.hpp
@@ -29,29 +29,29 @@
   public:
     static CouponHashSet* newSet(const void* bytes, size_t len, const A& allocator);
     static CouponHashSet* newSet(std::istream& is, const A& allocator);
-    CouponHashSet(int lgConfigK, target_hll_type tgtHllType, const A& allocator);
+    CouponHashSet(uint8_t lgConfigK, target_hll_type tgtHllType, const A& allocator);
     CouponHashSet(const CouponHashSet& that, target_hll_type tgtHllType);
 
     virtual ~CouponHashSet() = default;
     virtual std::function<void(HllSketchImpl<A>*)> get_deleter() const;
 
   protected:
-    using vector_int = std::vector<int, typename std::allocator_traits<A>::template rebind_alloc<int>>;
+    using vector_int = std::vector<uint32_t, typename std::allocator_traits<A>::template rebind_alloc<uint32_t>>;
 
     virtual CouponHashSet* copy() const;
     virtual CouponHashSet* copyAs(target_hll_type tgtHllType) const;
 
-    virtual HllSketchImpl<A>* couponUpdate(int coupon);
+    virtual HllSketchImpl<A>* couponUpdate(uint32_t coupon);
 
-    virtual int getMemDataStart() const;
-    virtual int getPreInts() const;
+    virtual uint32_t getMemDataStart() const;
+    virtual uint8_t getPreInts() const;
 
     friend class HllSketchImplFactory<A>;
 
   private:
     using ChsAlloc = typename std::allocator_traits<A>::template rebind_alloc<CouponHashSet<A>>;
     bool checkGrowOrPromote();
-    void growHashSet(int tgtLgCoupArrSize);
+    void growHashSet(uint8_t tgtLgCoupArrSize);
 };
 
 }
diff --git a/hll/include/CouponList-internal.hpp b/hll/include/CouponList-internal.hpp
index c48c7c2..c80c294 100644
--- a/hll/include/CouponList-internal.hpp
+++ b/hll/include/CouponList-internal.hpp
@@ -31,19 +31,19 @@
 namespace datasketches {
 
 template<typename A>
-CouponList<A>::CouponList(const int lgConfigK, const target_hll_type tgtHllType, const hll_mode mode, const A& allocator):
+CouponList<A>::CouponList(uint8_t lgConfigK, target_hll_type tgtHllType, hll_mode mode, const A& allocator):
 HllSketchImpl<A>(lgConfigK, tgtHllType, mode, false),
-couponCount(0),
-oooFlag(false),
-coupons(1 << (mode == hll_mode::LIST ? HllUtil<A>::LG_INIT_LIST_SIZE : HllUtil<A>::LG_INIT_SET_SIZE), 0, allocator)
+couponCount_(0),
+oooFlag_(false),
+coupons_(1ULL << (mode == hll_mode::LIST ? hll_constants::LG_INIT_LIST_SIZE : hll_constants::LG_INIT_SET_SIZE), 0, allocator)
 {}
 
 template<typename A>
 CouponList<A>::CouponList(const CouponList& that, const target_hll_type tgtHllType):
-HllSketchImpl<A>(that.lgConfigK, tgtHllType, that.mode, false),
-couponCount(that.couponCount),
-oooFlag(that.oooFlag),
-coupons(that.coupons)
+HllSketchImpl<A>(that.lgConfigK_, tgtHllType, that.mode_, false),
+couponCount_(that.couponCount_),
+oooFlag_(that.oooFlag_),
+coupons_(that.coupons_)
 {}
 
 template<typename A>
@@ -58,48 +58,48 @@
 
 template<typename A>
 CouponList<A>* CouponList<A>::copy() const {
-  ClAlloc cla(coupons.get_allocator());
+  ClAlloc cla(coupons_.get_allocator());
   return new (cla.allocate(1)) CouponList<A>(*this);
 }
 
 template<typename A>
 CouponList<A>* CouponList<A>::copyAs(target_hll_type tgtHllType) const {
-  ClAlloc cla(coupons.get_allocator());
+  ClAlloc cla(coupons_.get_allocator());
   return new (cla.allocate(1)) CouponList<A>(*this, tgtHllType);
 }
 
 template<typename A>
 CouponList<A>* CouponList<A>::newList(const void* bytes, size_t len, const A& allocator) {
-  if (len < HllUtil<A>::LIST_INT_ARR_START) {
+  if (len < hll_constants::LIST_INT_ARR_START) {
     throw std::out_of_range("Input data length insufficient to hold CouponHashSet");
   }
 
   const uint8_t* data = static_cast<const uint8_t*>(bytes);
-  if (data[HllUtil<A>::PREAMBLE_INTS_BYTE] != HllUtil<A>::LIST_PREINTS) {
+  if (data[hll_constants::PREAMBLE_INTS_BYTE] != hll_constants::LIST_PREINTS) {
     throw std::invalid_argument("Incorrect number of preInts in input stream");
   }
-  if (data[HllUtil<A>::SER_VER_BYTE] != HllUtil<A>::SER_VER) {
+  if (data[hll_constants::SER_VER_BYTE] != hll_constants::SER_VER) {
     throw std::invalid_argument("Wrong ser ver in input stream");
   }
-  if (data[HllUtil<A>::FAMILY_BYTE] != HllUtil<A>::FAMILY_ID) {
+  if (data[hll_constants::FAMILY_BYTE] != hll_constants::FAMILY_ID) {
     throw std::invalid_argument("Input stream is not an HLL sketch");
   }
 
-  hll_mode mode = HllSketchImpl<A>::extractCurMode(data[HllUtil<A>::MODE_BYTE]);
+  hll_mode mode = HllSketchImpl<A>::extractCurMode(data[hll_constants::MODE_BYTE]);
   if (mode != LIST) {
     throw std::invalid_argument("Calling list constructor with non-list mode data");
   }
 
-  target_hll_type tgtHllType = HllSketchImpl<A>::extractTgtHllType(data[HllUtil<A>::MODE_BYTE]);
+  target_hll_type tgtHllType = HllSketchImpl<A>::extractTgtHllType(data[hll_constants::MODE_BYTE]);
 
-  const int lgK = data[HllUtil<A>::LG_K_BYTE];
-  const bool compact = ((data[HllUtil<A>::FLAGS_BYTE] & HllUtil<A>::COMPACT_FLAG_MASK) ? true : false);
-  const bool oooFlag = ((data[HllUtil<A>::FLAGS_BYTE] & HllUtil<A>::OUT_OF_ORDER_FLAG_MASK) ? true : false);
-  const bool emptyFlag = ((data[HllUtil<A>::FLAGS_BYTE] & HllUtil<A>::EMPTY_FLAG_MASK) ? true : false);
+  const uint8_t lgK = data[hll_constants::LG_K_BYTE];
+  const bool compact = ((data[hll_constants::FLAGS_BYTE] & hll_constants::COMPACT_FLAG_MASK) ? true : false);
+  const bool oooFlag = ((data[hll_constants::FLAGS_BYTE] & hll_constants::OUT_OF_ORDER_FLAG_MASK) ? true : false);
+  const bool emptyFlag = ((data[hll_constants::FLAGS_BYTE] & hll_constants::EMPTY_FLAG_MASK) ? true : false);
 
-  const int couponCount = data[HllUtil<A>::LIST_COUNT_BYTE];
-  const int couponsInArray = (compact ? couponCount : (1 << HllUtil<A>::computeLgArrInts(LIST, couponCount, lgK)));
-  const size_t expectedLength = HllUtil<A>::LIST_INT_ARR_START + (couponsInArray * sizeof(int));
+  const uint32_t couponCount = data[hll_constants::LIST_COUNT_BYTE];
+  const uint32_t couponsInArray = (compact ? couponCount : (1 << HllUtil<A>::computeLgArrInts(LIST, couponCount, lgK)));
+  const size_t expectedLength = hll_constants::LIST_INT_ARR_START + (couponsInArray * sizeof(uint32_t));
   if (len < expectedLength) {
     throw std::out_of_range("Byte array too short for sketch. Expected " + std::to_string(expectedLength)
                                 + ", found: " + std::to_string(len));
@@ -107,12 +107,12 @@
 
   ClAlloc cla(allocator);
   CouponList<A>* sketch = new (cla.allocate(1)) CouponList<A>(lgK, tgtHllType, mode, allocator);
-  sketch->couponCount = couponCount;
+  sketch->couponCount_ = couponCount;
   sketch->putOutOfOrderFlag(oooFlag); // should always be false for LIST
 
   if (!emptyFlag) {
     // only need to read valid coupons, unlike in stream case
-    std::memcpy(sketch->coupons.data(), data + HllUtil<A>::LIST_INT_ARR_START, couponCount * sizeof(int));
+    std::memcpy(sketch->coupons_.data(), data + hll_constants::LIST_INT_ARR_START, couponCount * sizeof(uint32_t));
   }
   
   return sketch;
@@ -123,42 +123,42 @@
   uint8_t listHeader[8];
   read(is, listHeader, 8 * sizeof(uint8_t));
 
-  if (listHeader[HllUtil<A>::PREAMBLE_INTS_BYTE] != HllUtil<A>::LIST_PREINTS) {
+  if (listHeader[hll_constants::PREAMBLE_INTS_BYTE] != hll_constants::LIST_PREINTS) {
     throw std::invalid_argument("Incorrect number of preInts in input stream");
   }
-  if (listHeader[HllUtil<A>::SER_VER_BYTE] != HllUtil<A>::SER_VER) {
+  if (listHeader[hll_constants::SER_VER_BYTE] != hll_constants::SER_VER) {
     throw std::invalid_argument("Wrong ser ver in input stream");
   }
-  if (listHeader[HllUtil<A>::FAMILY_BYTE] != HllUtil<A>::FAMILY_ID) {
+  if (listHeader[hll_constants::FAMILY_BYTE] != hll_constants::FAMILY_ID) {
     throw std::invalid_argument("Input stream is not an HLL sketch");
   }
 
-  hll_mode mode = HllSketchImpl<A>::extractCurMode(listHeader[HllUtil<A>::MODE_BYTE]);
+  hll_mode mode = HllSketchImpl<A>::extractCurMode(listHeader[hll_constants::MODE_BYTE]);
   if (mode != LIST) {
     throw std::invalid_argument("Calling list constructor with non-list mode data");
   }
 
-  const target_hll_type tgtHllType = HllSketchImpl<A>::extractTgtHllType(listHeader[HllUtil<A>::MODE_BYTE]);
+  const target_hll_type tgtHllType = HllSketchImpl<A>::extractTgtHllType(listHeader[hll_constants::MODE_BYTE]);
 
-  const int lgK = (int) listHeader[HllUtil<A>::LG_K_BYTE];
-  const bool compact = ((listHeader[HllUtil<A>::FLAGS_BYTE] & HllUtil<A>::COMPACT_FLAG_MASK) ? true : false);
-  const bool oooFlag = ((listHeader[HllUtil<A>::FLAGS_BYTE] & HllUtil<A>::OUT_OF_ORDER_FLAG_MASK) ? true : false);
-  const bool emptyFlag = ((listHeader[HllUtil<A>::FLAGS_BYTE] & HllUtil<A>::EMPTY_FLAG_MASK) ? true : false);
+  const uint8_t lgK = listHeader[hll_constants::LG_K_BYTE];
+  const bool compact = ((listHeader[hll_constants::FLAGS_BYTE] & hll_constants::COMPACT_FLAG_MASK) ? true : false);
+  const bool oooFlag = ((listHeader[hll_constants::FLAGS_BYTE] & hll_constants::OUT_OF_ORDER_FLAG_MASK) ? true : false);
+  const bool emptyFlag = ((listHeader[hll_constants::FLAGS_BYTE] & hll_constants::EMPTY_FLAG_MASK) ? true : false);
 
   ClAlloc cla(allocator);
   CouponList<A>* sketch = new (cla.allocate(1)) CouponList<A>(lgK, tgtHllType, mode, allocator);
   using coupon_list_ptr = std::unique_ptr<CouponList<A>, std::function<void(HllSketchImpl<A>*)>>;
   coupon_list_ptr ptr(sketch, sketch->get_deleter());
-  const int couponCount = listHeader[HllUtil<A>::LIST_COUNT_BYTE];
-  sketch->couponCount = couponCount;
+  const uint32_t couponCount = listHeader[hll_constants::LIST_COUNT_BYTE];
+  sketch->couponCount_ = couponCount;
   sketch->putOutOfOrderFlag(oooFlag); // should always be false for LIST
 
   if (!emptyFlag) {
     // For stream processing, need to read entire number written to stream so read
     // pointer ends up set correctly.
     // If not compact, still need to read empty items even though in order.
-    const int numToRead = (compact ? couponCount : sketch->coupons.size());
-    read(is, sketch->coupons.data(), numToRead * sizeof(int));
+    const uint32_t numToRead = (compact ? couponCount : static_cast<uint32_t>(sketch->coupons_.size()));
+    read(is, sketch->coupons_.data(), numToRead * sizeof(uint32_t));
   }
 
   if (!is.good())
@@ -173,17 +173,17 @@
   vector_u8<A> byteArr(sketchSizeBytes, 0, getAllocator());
   uint8_t* bytes = byteArr.data() + header_size_bytes;
 
-  bytes[HllUtil<A>::PREAMBLE_INTS_BYTE] = static_cast<uint8_t>(getPreInts());
-  bytes[HllUtil<A>::SER_VER_BYTE] = static_cast<uint8_t>(HllUtil<A>::SER_VER);
-  bytes[HllUtil<A>::FAMILY_BYTE] = static_cast<uint8_t>(HllUtil<A>::FAMILY_ID);
-  bytes[HllUtil<A>::LG_K_BYTE] = static_cast<uint8_t>(this->lgConfigK);
-  bytes[HllUtil<A>::LG_ARR_BYTE] = count_trailing_zeros_in_u32(coupons.size());
-  bytes[HllUtil<A>::FLAGS_BYTE] = this->makeFlagsByte(compact);
-  bytes[HllUtil<A>::LIST_COUNT_BYTE] = static_cast<uint8_t>(this->mode == LIST ? couponCount : 0);
-  bytes[HllUtil<A>::MODE_BYTE] = this->makeModeByte();
+  bytes[hll_constants::PREAMBLE_INTS_BYTE] = static_cast<uint8_t>(getPreInts());
+  bytes[hll_constants::SER_VER_BYTE] = static_cast<uint8_t>(hll_constants::SER_VER);
+  bytes[hll_constants::FAMILY_BYTE] = static_cast<uint8_t>(hll_constants::FAMILY_ID);
+  bytes[hll_constants::LG_K_BYTE] = static_cast<uint8_t>(this->lgConfigK_);
+  bytes[hll_constants::LG_ARR_BYTE] = count_trailing_zeros_in_u32(static_cast<uint32_t>(coupons_.size()));
+  bytes[hll_constants::FLAGS_BYTE] = this->makeFlagsByte(compact);
+  bytes[hll_constants::LIST_COUNT_BYTE] = static_cast<uint8_t>(this->mode_ == LIST ? couponCount_ : 0);
+  bytes[hll_constants::MODE_BYTE] = this->makeModeByte();
 
-  if (this->mode == SET) {
-    std::memcpy(bytes + HllUtil<A>::HASH_SET_COUNT_INT, &couponCount, sizeof(couponCount));
+  if (this->mode_ == SET) {
+    std::memcpy(bytes + hll_constants::HASH_SET_COUNT_INT, &couponCount_, sizeof(couponCount_));
   }
 
   // coupons
@@ -191,12 +191,12 @@
   const int sw = (isCompact() ? 2 : 0) | (compact ? 1 : 0);
   switch (sw) {
     case 0: { // src updatable, dst updatable
-      std::memcpy(bytes + getMemDataStart(), coupons.data(), coupons.size() * sizeof(int));
+      std::memcpy(bytes + getMemDataStart(), coupons_.data(), coupons_.size() * sizeof(uint32_t));
       break;
     }
     case 1: { // src updatable, dst compact
       bytes += getMemDataStart(); // reusing pointer for incremental writes
-      for (uint32_t coupon: *this) {
+      for (const uint32_t coupon: *this) {
         std::memcpy(bytes, &coupon, sizeof(coupon));
         bytes += sizeof(coupon);
       }
@@ -213,33 +213,33 @@
 template<typename A>
 void CouponList<A>::serialize(std::ostream& os, const bool compact) const {
   // header
-  const uint8_t preInts(getPreInts());
+  const uint8_t preInts = getPreInts();
   write(os, preInts);
-  const uint8_t serialVersion(HllUtil<A>::SER_VER);
+  const uint8_t serialVersion(hll_constants::SER_VER);
   write(os, serialVersion);
-  const uint8_t familyId(HllUtil<A>::FAMILY_ID);
+  const uint8_t familyId(hll_constants::FAMILY_ID);
   write(os, familyId);
-  const uint8_t lgKByte((uint8_t) this->lgConfigK);
+  const uint8_t lgKByte = this->lgConfigK_;
   write(os, lgKByte);
-  const uint8_t lgArrIntsByte(count_trailing_zeros_in_u32(coupons.size()));
+  const uint8_t lgArrIntsByte = count_trailing_zeros_in_u32(static_cast<uint32_t>(coupons_.size()));
   write(os, lgArrIntsByte);
-  const uint8_t flagsByte(this->makeFlagsByte(compact));
+  const uint8_t flagsByte = this->makeFlagsByte(compact);
   write(os, flagsByte);
 
-  if (this->mode == LIST) {
-    const uint8_t listCount((uint8_t) couponCount);
+  if (this->mode_ == LIST) {
+    const uint8_t listCount = static_cast<uint8_t>(couponCount_);
     write(os, listCount);
   } else { // mode == SET
-    const uint8_t unused(0);
+      const uint8_t unused = 0;
     write(os, unused);
   }
 
-  const uint8_t modeByte(this->makeModeByte());
+  const uint8_t modeByte = this->makeModeByte();
   write(os, modeByte);
 
-  if (this->mode == SET) {
+  if (this->mode_ == SET) {
     // writing as int, already stored as int
-    write(os, couponCount);
+    write(os, couponCount_);
   }
 
   // coupons
@@ -247,11 +247,11 @@
   const int sw = (isCompact() ? 2 : 0) | (compact ? 1 : 0);
   switch (sw) {
     case 0: { // src updatable, dst updatable
-      write(os, coupons.data(), coupons.size() * sizeof(int));
+      write(os, coupons_.data(), coupons_.size() * sizeof(uint32_t));
       break;
     }
     case 1: { // src updatable, dst compact
-      for (uint32_t coupon: *this) {
+      for (const uint32_t coupon: *this) {
         write(os, coupon);
       }
       break;
@@ -265,14 +265,14 @@
 }
 
 template<typename A>
-HllSketchImpl<A>* CouponList<A>::couponUpdate(int coupon) {
-  for (size_t i = 0; i < coupons.size(); ++i) { // search for empty slot
-    const int couponAtIdx = coupons[i];
-    if (couponAtIdx == HllUtil<A>::EMPTY) {
-      coupons[i] = coupon; // the actual update
-      ++couponCount;
-      if (couponCount == static_cast<int>(coupons.size())) { // array full
-        if (this->lgConfigK < 8) {
+HllSketchImpl<A>* CouponList<A>::couponUpdate(uint32_t coupon) {
+  for (size_t i = 0; i < coupons_.size(); ++i) { // search for empty slot
+    const uint32_t couponAtIdx = coupons_[i];
+    if (couponAtIdx == hll_constants::EMPTY) {
+      coupons_[i] = coupon; // the actual update
+      ++couponCount_;
+      if (couponCount_ == static_cast<uint32_t>(coupons_.size())) { // array full
+        if (this->lgConfigK_ < 8) {
           return promoteHeapListOrSetToHll(*this);
         }
         return promoteHeapListToSet(*this);
@@ -293,71 +293,68 @@
 
 template<typename A>
 double CouponList<A>::getEstimate() const {
-  const int couponCount = getCouponCount();
-  const double est = CubicInterpolation<A>::usingXAndYTables(couponCount);
-  return fmax(est, couponCount);
+  const double est = CubicInterpolation<A>::usingXAndYTables(couponCount_);
+  return fmax(est, couponCount_);
 }
 
 template<typename A>
-double CouponList<A>::getLowerBound(const int numStdDev) const {
+double CouponList<A>::getLowerBound(uint8_t numStdDev) const {
   HllUtil<A>::checkNumStdDev(numStdDev);
-  const int couponCount = getCouponCount();
-  const double est = CubicInterpolation<A>::usingXAndYTables(couponCount);
-  const double tmp = est / (1.0 + (numStdDev * HllUtil<A>::COUPON_RSE));
-  return fmax(tmp, couponCount);
+  const double est = CubicInterpolation<A>::usingXAndYTables(couponCount_);
+  const double tmp = est / (1.0 + (numStdDev * hll_constants::COUPON_RSE));
+  return fmax(tmp, couponCount_);
 }
 
 template<typename A>
-double CouponList<A>::getUpperBound(const int numStdDev) const {
+double CouponList<A>::getUpperBound(uint8_t numStdDev) const {
   HllUtil<A>::checkNumStdDev(numStdDev);
-  const int couponCount = getCouponCount();
-  const double est = CubicInterpolation<A>::usingXAndYTables(couponCount);
-  const double tmp = est / (1.0 - (numStdDev * HllUtil<A>::COUPON_RSE));
-  return fmax(tmp, couponCount);
+  const double est = CubicInterpolation<A>::usingXAndYTables(couponCount_);
+  const double tmp = est / (1.0 - (numStdDev * hll_constants::COUPON_RSE));
+  return fmax(tmp, couponCount_);
 }
 
 template<typename A>
 bool CouponList<A>::isEmpty() const { return getCouponCount() == 0; }
 
 template<typename A>
-int CouponList<A>::getUpdatableSerializationBytes() const {
-  return getMemDataStart() + coupons.size() * sizeof(int);
+uint32_t CouponList<A>::getUpdatableSerializationBytes() const {
+  return getMemDataStart() + static_cast<uint32_t>(coupons_.size()) * sizeof(uint32_t);
 }
 
 template<typename A>
-int CouponList<A>::getCouponCount() const {
-  return couponCount;
+uint32_t CouponList<A>::getCouponCount() const {
+  return couponCount_;
 }
 
 template<typename A>
-int CouponList<A>::getCompactSerializationBytes() const {
-  return getMemDataStart() + (couponCount << 2);
+uint32_t CouponList<A>::getCompactSerializationBytes() const {
+  return getMemDataStart() + (couponCount_ << 2);
 }
 
 template<typename A>
-int CouponList<A>::getMemDataStart() const {
-  return HllUtil<A>::LIST_INT_ARR_START;
+uint32_t CouponList<A>::getMemDataStart() const {
+  return hll_constants::LIST_INT_ARR_START;
 }
 
 template<typename A>
-int CouponList<A>::getPreInts() const {
-  return HllUtil<A>::LIST_PREINTS;
+uint8_t CouponList<A>::getPreInts() const {
+  return hll_constants::LIST_PREINTS;
 }
 
 template<typename A>
 bool CouponList<A>::isCompact() const { return false; }
 
 template<typename A>
-bool CouponList<A>::isOutOfOrderFlag() const { return oooFlag; }
+bool CouponList<A>::isOutOfOrderFlag() const { return oooFlag_; }
 
 template<typename A>
 void CouponList<A>::putOutOfOrderFlag(bool oooFlag) {
-  this->oooFlag = oooFlag;
+  oooFlag_ = oooFlag;
 }
 
 template<typename A>
 A CouponList<A>::getAllocator() const {
-  return coupons.get_allocator();
+  return coupons_.get_allocator();
 }
 
 template<typename A>
@@ -372,12 +369,12 @@
 
 template<typename A>
 coupon_iterator<A> CouponList<A>::begin(bool all) const {
-  return coupon_iterator<A>(coupons.data(), coupons.size(), 0, all);
+  return coupon_iterator<A>(coupons_.data(), coupons_.size(), 0, all);
 }
 
 template<typename A>
 coupon_iterator<A> CouponList<A>::end() const {
-  return coupon_iterator<A>(coupons.data(), coupons.size(), coupons.size(), false);
+  return coupon_iterator<A>(coupons_.data(), coupons_.size(), coupons_.size(), false);
 }
 
 }
diff --git a/hll/include/CouponList.hpp b/hll/include/CouponList.hpp
index c19569e..cf0a662 100644
--- a/hll/include/CouponList.hpp
+++ b/hll/include/CouponList.hpp
@@ -33,7 +33,7 @@
 template<typename A>
 class CouponList : public HllSketchImpl<A> {
   public:
-    CouponList(int lgConfigK, target_hll_type tgtHllType, hll_mode mode, const A& allocator);
+    CouponList(uint8_t lgConfigK, target_hll_type tgtHllType, hll_mode mode, const A& allocator);
     CouponList(const CouponList& that, target_hll_type tgtHllType);
 
     static CouponList* newList(const void* bytes, size_t len, const A& allocator);
@@ -47,15 +47,15 @@
     virtual CouponList* copy() const;
     virtual CouponList* copyAs(target_hll_type tgtHllType) const;
 
-    virtual HllSketchImpl<A>* couponUpdate(int coupon);
+    virtual HllSketchImpl<A>* couponUpdate(uint32_t coupon);
 
     virtual double getEstimate() const;
     virtual double getCompositeEstimate() const;
-    virtual double getUpperBound(int numStdDev) const;
-    virtual double getLowerBound(int numStdDev) const;
+    virtual double getUpperBound(uint8_t numStdDev) const;
+    virtual double getLowerBound(uint8_t numStdDev) const;
 
     virtual bool isEmpty() const;
-    virtual int getCouponCount() const;
+    virtual uint32_t getCouponCount() const;
 
     coupon_iterator<A> begin(bool all = false) const;
     coupon_iterator<A> end() const;
@@ -63,24 +63,24 @@
   protected:
     using ClAlloc = typename std::allocator_traits<A>::template rebind_alloc<CouponList<A>>;
 
-    using vector_int = std::vector<int, typename std::allocator_traits<A>::template rebind_alloc<int>>;
+    using vector_int = std::vector<uint32_t, typename std::allocator_traits<A>::template rebind_alloc<uint32_t>>;
 
     HllSketchImpl<A>* promoteHeapListToSet(CouponList& list);
     HllSketchImpl<A>* promoteHeapListOrSetToHll(CouponList& src);
 
-    virtual int getUpdatableSerializationBytes() const;
-    virtual int getCompactSerializationBytes() const;
-    virtual int getMemDataStart() const;
-    virtual int getPreInts() const;
+    virtual uint32_t getUpdatableSerializationBytes() const;
+    virtual uint32_t getCompactSerializationBytes() const;
+    virtual uint32_t getMemDataStart() const;
+    virtual uint8_t getPreInts() const;
     virtual bool isCompact() const;
     virtual bool isOutOfOrderFlag() const;
     virtual void putOutOfOrderFlag(bool oooFlag);
 
     virtual A getAllocator() const;
 
-    int couponCount;
-    bool oooFlag;
-    vector_int coupons;
+    uint32_t couponCount_;
+    bool oooFlag_;
+    vector_int coupons_;
 
     friend class HllSketchImplFactory<A>;
 };
diff --git a/hll/include/CubicInterpolation-internal.hpp b/hll/include/CubicInterpolation-internal.hpp
index be03e80..c60ddab 100644
--- a/hll/include/CubicInterpolation-internal.hpp
+++ b/hll/include/CubicInterpolation-internal.hpp
@@ -102,10 +102,8 @@
   else if (offset == numEntries-2) { // corner case
     return (interpolateUsingXAndYTables<A>(xArr, yArr, (offset-2), x));
   }
-  else { // main case
-    return (interpolateUsingXAndYTables<A>(xArr, yArr, (offset-1), x));
-  }
-  throw std::logic_error("Exception should be unreachable");
+  // main case
+  return (interpolateUsingXAndYTables<A>(xArr, yArr, (offset-1), x));
 }
 
 // In C: again-two-registers cubic_interpolate_aux L1368
diff --git a/hll/include/HarmonicNumbers-internal.hpp b/hll/include/HarmonicNumbers-internal.hpp
index db73b86..4ac1e72 100644
--- a/hll/include/HarmonicNumbers-internal.hpp
+++ b/hll/include/HarmonicNumbers-internal.hpp
@@ -68,7 +68,7 @@
   if (x_i < NUM_EXACT_HARMONIC_NUMBERS) {
     return tableOfExactHarmonicNumbers[x_i];
   } else {
-    double x = x_i;
+    double x = static_cast<double>(x_i);
     double invSq = 1.0 / (x * x);
     double sum = log(x) + EULER_MASCHERONI_CONSTANT + (1.0 / (2.0 * x));
     /* note: the number of terms included from this series expansion is appropriate
diff --git a/hll/include/Hll4Array-internal.hpp b/hll/include/Hll4Array-internal.hpp
index f93014a..b0e09a7 100644
--- a/hll/include/Hll4Array-internal.hpp
+++ b/hll/include/Hll4Array-internal.hpp
@@ -30,12 +30,12 @@
 namespace datasketches {
 
 template<typename A>
-Hll4Array<A>::Hll4Array(const int lgConfigK, const bool startFullSize, const A& allocator):
+Hll4Array<A>::Hll4Array(uint8_t lgConfigK, bool startFullSize, const A& allocator):
 HllArray<A>(lgConfigK, target_hll_type::HLL_4, startFullSize, allocator),
-auxHashMap(nullptr)
+auxHashMap_(nullptr)
 {
-  const int numBytes = this->hll4ArrBytes(lgConfigK);
-  this->hllByteArr.resize(numBytes, 0);
+  const uint32_t numBytes = this->hll4ArrBytes(lgConfigK);
+  this->hllByteArr_.resize(numBytes, 0);
 }
 
 template<typename A>
@@ -44,18 +44,18 @@
 {
   // can determine hllByteArr size in parent class, no need to allocate here
   // but parent class doesn't handle the auxHashMap
-  if (that.auxHashMap != nullptr) {
-    auxHashMap = that.auxHashMap->copy();
+  if (that.auxHashMap_ != nullptr) {
+    auxHashMap_ = that.auxHashMap_->copy();
   } else {
-    auxHashMap = nullptr;
+    auxHashMap_ = nullptr;
   }
 }
 
 template<typename A>
 Hll4Array<A>::~Hll4Array() {
   // hllByteArr deleted in parent
-  if (auxHashMap != nullptr) {
-    AuxHashMap<A>::make_deleter()(auxHashMap);
+  if (auxHashMap_ != nullptr) {
+    AuxHashMap<A>::make_deleter()(auxHashMap_);
   }
 }
 
@@ -78,91 +78,91 @@
 }
 
 template<typename A>
-int Hll4Array<A>::getUpdatableSerializationBytes() const {
+uint32_t Hll4Array<A>::getUpdatableSerializationBytes() const {
   AuxHashMap<A>* auxHashMap = getAuxHashMap();
-  int auxBytes;
+  uint32_t auxBytes;
   if (auxHashMap == nullptr) {
-    auxBytes = 4 << HllUtil<A>::LG_AUX_ARR_INTS[this->lgConfigK];
+    auxBytes = 4 << hll_constants::LG_AUX_ARR_INTS[this->lgConfigK_];
   } else {
     auxBytes = 4 << auxHashMap->getLgAuxArrInts();
   }
-  return HllUtil<A>::HLL_BYTE_ARR_START + getHllByteArrBytes() + auxBytes;
+  return hll_constants::HLL_BYTE_ARR_START + getHllByteArrBytes() + auxBytes;
 }
 
 template<typename A>
-int Hll4Array<A>::getHllByteArrBytes() const {
-  return this->hll4ArrBytes(this->lgConfigK);
+uint32_t Hll4Array<A>::getHllByteArrBytes() const {
+  return this->hll4ArrBytes(this->lgConfigK_);
 }
 
 template<typename A>
 AuxHashMap<A>* Hll4Array<A>::getAuxHashMap() const {
-  return auxHashMap;
+  return auxHashMap_;
 }
 
 template<typename A>
 void Hll4Array<A>::putAuxHashMap(AuxHashMap<A>* auxHashMap) {
-  this->auxHashMap = auxHashMap;
+  this->auxHashMap_ = auxHashMap;
 }
 
 template<typename A>
-uint8_t Hll4Array<A>::getSlot(int slotNo) const {
-  const uint8_t byte = this->hllByteArr[slotNo >> 1];
+uint8_t Hll4Array<A>::getSlot(uint32_t slotNo) const {
+  const uint8_t byte = this->hllByteArr_[slotNo >> 1];
   if ((slotNo & 1) > 0) { // odd?
     return byte >> 4;
   }
-  return byte & HllUtil<A>::loNibbleMask;
+  return byte & hll_constants::loNibbleMask;
 }
 
 template<typename A>
 uint8_t Hll4Array<A>::get_value(uint32_t index) const {
   const uint8_t value = getSlot(index);
-  if (value != HllUtil<A>::AUX_TOKEN) return value + this->curMin;
-  return auxHashMap->mustFindValueFor(index);
+  if (value != hll_constants::AUX_TOKEN) return value + this->curMin_;
+  return auxHashMap_->mustFindValueFor(index);
 }
 
 template<typename A>
-HllSketchImpl<A>* Hll4Array<A>::couponUpdate(const int coupon) {
+HllSketchImpl<A>* Hll4Array<A>::couponUpdate(uint32_t coupon) {
   internalCouponUpdate(coupon);
   return this;
 }
 
 template<typename A>
-void Hll4Array<A>::internalCouponUpdate(const int coupon) {
-  const int newValue = HllUtil<A>::getValue(coupon);
-  if (newValue <= this->curMin) {
+void Hll4Array<A>::internalCouponUpdate(uint32_t coupon) {
+  const uint8_t newValue = HllUtil<A>::getValue(coupon);
+  if (newValue <= this->curMin_) {
     return; // quick rejection, but only works for large N
   }
-  const int configKmask = (1 << this->lgConfigK) - 1;
-  const int slotNo = HllUtil<A>::getLow26(coupon) & configKmask;
+  const uint32_t configKmask = (1 << this->lgConfigK_) - 1;
+  const uint32_t slotNo = HllUtil<A>::getLow26(coupon) & configKmask;
   internalHll4Update(slotNo, newValue);
 }
 
 template<typename A>
-void Hll4Array<A>::putSlot(int slotNo, uint8_t newValue) {
-  const int byteno = slotNo >> 1;
-  const uint8_t oldValue = this->hllByteArr[byteno];
+void Hll4Array<A>::putSlot(uint32_t slotNo, uint8_t newValue) {
+  const uint32_t byteno = slotNo >> 1;
+  const uint8_t oldValue = this->hllByteArr_[byteno];
   if ((slotNo & 1) == 0) { // set low nibble
-    this->hllByteArr[byteno]
-      = ((oldValue & HllUtil<A>::hiNibbleMask) | (newValue & HllUtil<A>::loNibbleMask));
+    this->hllByteArr_[byteno]
+      = ((oldValue & hll_constants::hiNibbleMask) | (newValue & hll_constants::loNibbleMask));
   } else { // set high nibble
-    this->hllByteArr[byteno]
-      = ((oldValue & HllUtil<A>::loNibbleMask) | ((newValue << 4) & HllUtil<A>::hiNibbleMask));
+    this->hllByteArr_[byteno]
+      = ((oldValue & hll_constants::loNibbleMask) | ((newValue << 4) & hll_constants::hiNibbleMask));
   }
 }
 
 //In C: two-registers.c Line 836 in "hhb_abstract_set_slot_if_new_value_bigger" non-sparse
 template<typename A>
-void Hll4Array<A>::internalHll4Update(const int slotNo, const int newVal) {
+void Hll4Array<A>::internalHll4Update(uint32_t slotNo, uint8_t newVal) {
 
-  const int rawStoredOldValue = getSlot(slotNo); // could be a 0
+  const uint8_t rawStoredOldValue = getSlot(slotNo); // could be a 0
   // this is provably a LB:
-  const int lbOnOldValue = rawStoredOldValue + this->curMin; // lower bound, could be 0
+  const uint8_t lbOnOldValue = rawStoredOldValue + this->curMin_; // lower bound, could be 0
 
   if (newVal > lbOnOldValue) { // 842
     // Note: if an AUX_TOKEN exists, then auxHashMap must already exist
     // 846: rawStoredOldValue == AUX_TOKEN
-    const int actualOldValue = (rawStoredOldValue < HllUtil<A>::AUX_TOKEN)
-       ? (lbOnOldValue) : (auxHashMap->mustFindValueFor(slotNo));
+    const uint8_t actualOldValue = (rawStoredOldValue < hll_constants::AUX_TOKEN)
+       ? (lbOnOldValue) : (auxHashMap_->mustFindValueFor(slotNo));
 
     if (newVal > actualOldValue) { // 848: actualOldValue could still be 0; newValue > 0
       // we know that the array will change, but we haven't actually updated yet
@@ -170,35 +170,36 @@
 
       // newVal >= curMin
 
-      const int shiftedNewValue = newVal - this->curMin; // 874
+      const uint8_t shiftedNewValue = newVal - this->curMin_; // 874
       // redundant since we know newVal >= curMin,
       // and lgConfigK bounds do not allow overflowing an int
       //assert(shiftedNewValue >= 0);
 
-      if (rawStoredOldValue == HllUtil<A>::AUX_TOKEN) { // 879
+      if (rawStoredOldValue == hll_constants::AUX_TOKEN) { // 879
         // Given that we have an AUX_TOKEN, there are 4 cases for how to
         // actually modify the data structure
 
-        if (shiftedNewValue >= HllUtil<A>::AUX_TOKEN) { // case 1: 881
+        if (shiftedNewValue >= hll_constants::AUX_TOKEN) { // case 1: 881
           // the byte array already contains aux token
           // This is the case where old and new values are both exceptions.
           // The 4-bit array already is AUX_TOKEN, only need to update auxHashMap
-          auxHashMap->mustReplace(slotNo, newVal);
+          auxHashMap_->mustReplace(slotNo, newVal);
         }
         else { // case 2: 885
           // This is the hypothetical case where the old value is an exception and the new one is not,
           // which is impossible given that curMin has not changed here and newVal > oldValue
         }
       } else { // rawStoredOldValue != AUX_TOKEN
-        if (shiftedNewValue >= HllUtil<A>::AUX_TOKEN) { // case 3: 892
+        if (shiftedNewValue >= hll_constants::AUX_TOKEN) { // case 3: 892
           // This is the case where the old value is not an exception and the new value is.
           // The AUX_TOKEN must be stored in the 4-bit array and the new value
           // added to the exception table
-          putSlot(slotNo, HllUtil<A>::AUX_TOKEN);
-          if (auxHashMap == nullptr) {
-            auxHashMap = AuxHashMap<A>::newAuxHashMap(HllUtil<A>::LG_AUX_ARR_INTS[this->lgConfigK], this->lgConfigK, this->getAllocator());
+          putSlot(slotNo, hll_constants::AUX_TOKEN);
+          if (auxHashMap_ == nullptr) {
+            auxHashMap_ = AuxHashMap<A>::newAuxHashMap(hll_constants::LG_AUX_ARR_INTS[this->lgConfigK_],
+                this->lgConfigK_, this->getAllocator());
           }
-          auxHashMap->mustAdd(slotNo, newVal);
+          auxHashMap_->mustAdd(slotNo, newVal);
         }
         else { // case 4: 897
           // This is the case where neither the old value nor the new value is an exception.
@@ -208,9 +209,9 @@
       }
 
       // we just increased a pair value, so it might be time to change curMin
-      if (actualOldValue == this->curMin) { // 908
+      if (actualOldValue == this->curMin_) { // 908
         this->decNumAtCurMin();
-        while (this->numAtCurMin == 0) {
+        while (this->numAtCurMin_ == 0) {
           shiftToBiggerCurMin(); // increases curMin by 1, builds a new aux table
           // shifts values in 4-bit table and recounts curMin
         }
@@ -227,29 +228,29 @@
 // In C: again-two-registers.c Lines 710 "hhb_shift_to_bigger_curmin"
 template<typename A>
 void Hll4Array<A>::shiftToBiggerCurMin() {
-  const int newCurMin = this->curMin + 1;
-  const int configK = 1 << this->lgConfigK;
-  const int configKmask = configK - 1;
+  const uint8_t newCurMin = this->curMin_ + 1;
+  const uint32_t configK = 1 << this->lgConfigK_;
+  const uint32_t configKmask = configK - 1;
 
-  int numAtNewCurMin = 0;
-  int numAuxTokens = 0;
+  uint32_t numAtNewCurMin = 0;
+  uint32_t numAuxTokens = 0;
 
   // Walk through the slots of 4-bit array decrementing stored values by one unless it
   // equals AUX_TOKEN, where it is left alone but counted to be checked later.
   // If oldStoredValue is 0 it is an error.
   // If the decremented value is 0, we increment numAtNewCurMin.
   // Because getNibble is masked to 4 bits oldStoredValue can never be > 15 or negative
-  for (int i = 0; i < configK; i++) { //724
-    int oldStoredValue = getSlot(i);
+  for (uint32_t i = 0; i < configK; i++) { //724
+    uint8_t oldStoredValue = getSlot(i);
     if (oldStoredValue == 0) {
       throw std::runtime_error("Array slots cannot be 0 at this point.");
     }
-    if (oldStoredValue < HllUtil<A>::AUX_TOKEN) {
+    if (oldStoredValue < hll_constants::AUX_TOKEN) {
       putSlot(i, --oldStoredValue);
       if (oldStoredValue == 0) { numAtNewCurMin++; }
     } else { //oldStoredValue == AUX_TOKEN
       numAuxTokens++;
-      if (auxHashMap == nullptr) {
+      if (auxHashMap_ == nullptr) {
         throw std::logic_error("auxHashMap cannot be null at this point");
       }
     }
@@ -258,12 +259,12 @@
   // If old AuxHashMap exists, walk through it updating some slots and build a new AuxHashMap
   // if needed.
   AuxHashMap<A>* newAuxMap = nullptr;
-  if (auxHashMap != nullptr) {
-    int slotNum;
-    int oldActualVal;
-    int newShiftedVal;
+  if (auxHashMap_ != nullptr) {
+    uint32_t slotNum;
+    uint8_t oldActualVal;
+    uint8_t newShiftedVal;
 
-    for (auto coupon: *auxHashMap) {
+    for (const auto coupon: *auxHashMap_) {
       slotNum = HllUtil<A>::getLow26(coupon) & configKmask;
       oldActualVal = HllUtil<A>::getValue(coupon);
       newShiftedVal = oldActualVal - newCurMin;
@@ -271,11 +272,11 @@
         throw std::logic_error("oldActualVal < newCurMin when incrementing curMin");
       }
 
-      if (getSlot(slotNum) != HllUtil<A>::AUX_TOKEN) {
+      if (getSlot(slotNum) != hll_constants::AUX_TOKEN) {
         throw std::logic_error("getSlot(slotNum) != AUX_TOKEN for item in auxiliary hash map");
       }
       // Array slot != AUX_TOKEN at getSlot(slotNum);
-      if (newShiftedVal < HllUtil<A>::AUX_TOKEN) { // 756
+      if (newShiftedVal < hll_constants::AUX_TOKEN) { // 756
         if (newShiftedVal != 14) {
           throw std::logic_error("newShiftedVal != 14 for item in old auxHashMap despite curMin increment");
         }
@@ -286,7 +287,8 @@
       } else { //newShiftedVal >= AUX_TOKEN
         // the former exception remains an exception, so must be added to the newAuxMap
         if (newAuxMap == nullptr) {
-          newAuxMap = AuxHashMap<A>::newAuxHashMap(HllUtil<A>::LG_AUX_ARR_INTS[this->lgConfigK], this->lgConfigK, this->getAllocator());
+          newAuxMap = AuxHashMap<A>::newAuxHashMap(hll_constants::LG_AUX_ARR_INTS[this->lgConfigK_],
+              this->lgConfigK_, this->getAllocator());
         }
         newAuxMap->mustAdd(slotNum, oldActualVal);
       }
@@ -305,28 +307,30 @@
     }
   }
 
-  if (auxHashMap != nullptr) {
-    AuxHashMap<A>::make_deleter()(auxHashMap);
+  if (auxHashMap_ != nullptr) {
+    AuxHashMap<A>::make_deleter()(auxHashMap_);
   }
-  auxHashMap = newAuxMap;
+  auxHashMap_ = newAuxMap;
 
-  this->curMin = newCurMin;
-  this->numAtCurMin = numAtNewCurMin;
+  this->curMin_ = newCurMin;
+  this->numAtCurMin_ = numAtNewCurMin;
 }
 
 template<typename A>
 typename HllArray<A>::const_iterator Hll4Array<A>::begin(bool all) const {
-  return typename HllArray<A>::const_iterator(this->hllByteArr.data(), 1 << this->lgConfigK, 0, this->tgtHllType, auxHashMap, this->curMin, all);
+  return typename HllArray<A>::const_iterator(this->hllByteArr_.data(), 1 << this->lgConfigK_, 0, this->tgtHllType_,
+      auxHashMap_, this->curMin_, all);
 }
 
 template<typename A>
 typename HllArray<A>::const_iterator Hll4Array<A>::end() const {
-  return typename HllArray<A>::const_iterator(this->hllByteArr.data(), 1 << this->lgConfigK, 1 << this->lgConfigK, this->tgtHllType, auxHashMap, this->curMin, false);
+  return typename HllArray<A>::const_iterator(this->hllByteArr_.data(), 1 << this->lgConfigK_, 1 << this->lgConfigK_,
+      this->tgtHllType_, auxHashMap_, this->curMin_, false);
 }
 
 template<typename A>
 void Hll4Array<A>::mergeHll(const HllArray<A>& src) {
-  for (auto coupon: src) {
+  for (const auto coupon: src) {
     internalCouponUpdate(coupon);
   }
 }
diff --git a/hll/include/Hll4Array.hpp b/hll/include/Hll4Array.hpp
index 38b2c94..4542dec 100644
--- a/hll/include/Hll4Array.hpp
+++ b/hll/include/Hll4Array.hpp
@@ -31,7 +31,7 @@
 template<typename A>
 class Hll4Array final : public HllArray<A> {
   public:
-    explicit Hll4Array(int lgConfigK, bool startFullSize, const A& allocator);
+    explicit Hll4Array(uint8_t lgConfigK, bool startFullSize, const A& allocator);
     explicit Hll4Array(const Hll4Array<A>& that);
 
     virtual ~Hll4Array();
@@ -39,14 +39,14 @@
 
     virtual Hll4Array* copy() const;
 
-    inline uint8_t getSlot(int slotNo) const;
-    inline void putSlot(int slotNo, uint8_t value);
+    inline uint8_t getSlot(uint32_t slotNo) const;
+    inline void putSlot(uint32_t slotNo, uint8_t value);
     inline uint8_t get_value(uint32_t index) const;
 
-    virtual int getUpdatableSerializationBytes() const;
-    virtual int getHllByteArrBytes() const;
+    virtual uint32_t getUpdatableSerializationBytes() const;
+    virtual uint32_t getHllByteArrBytes() const;
 
-    virtual HllSketchImpl<A>* couponUpdate(int coupon) final;
+    virtual HllSketchImpl<A>* couponUpdate(uint32_t coupon) final;
     void mergeHll(const HllArray<A>& src);
 
     virtual AuxHashMap<A>* getAuxHashMap() const;
@@ -57,11 +57,11 @@
     virtual typename HllArray<A>::const_iterator end() const;
 
   private:
-    void internalCouponUpdate(int coupon);
-    void internalHll4Update(int slotNo, int newVal);
+    void internalCouponUpdate(uint32_t coupon);
+    void internalHll4Update(uint32_t slotNo, uint8_t newVal);
     void shiftToBiggerCurMin();
 
-    AuxHashMap<A>* auxHashMap;
+    AuxHashMap<A>* auxHashMap_;
 };
 
 }
diff --git a/hll/include/Hll6Array-internal.hpp b/hll/include/Hll6Array-internal.hpp
index e9f6e9f..dccb82e 100644
--- a/hll/include/Hll6Array-internal.hpp
+++ b/hll/include/Hll6Array-internal.hpp
@@ -27,11 +27,11 @@
 namespace datasketches {
 
 template<typename A>
-Hll6Array<A>::Hll6Array(const int lgConfigK, const bool startFullSize, const A& allocator):
+Hll6Array<A>::Hll6Array(uint8_t lgConfigK, bool startFullSize, const A& allocator):
 HllArray<A>(lgConfigK, target_hll_type::HLL_6, startFullSize, allocator)
 {
   const int numBytes = this->hll6ArrBytes(lgConfigK);
-  this->hllByteArr.resize(numBytes, 0);
+  this->hllByteArr_.resize(numBytes, 0);
 }
 
 template<typename A>
@@ -53,57 +53,57 @@
 }
 
 template<typename A>
-uint8_t Hll6Array<A>::getSlot(int slotNo) const {
-  const int startBit = slotNo * 6;
-  const int shift = startBit & 0x7;
-  const int byteIdx = startBit >> 3;  
-  const uint16_t twoByteVal = (this->hllByteArr[byteIdx + 1] << 8) | this->hllByteArr[byteIdx];
-  return (twoByteVal >> shift) & HllUtil<A>::VAL_MASK_6;
+uint8_t Hll6Array<A>::getSlot(uint32_t slotNo) const {
+  const uint32_t startBit = slotNo * 6;
+  const uint32_t shift = startBit & 0x7;
+  const uint32_t byteIdx = startBit >> 3;  
+  const uint16_t twoByteVal = (this->hllByteArr_[byteIdx + 1] << 8) | this->hllByteArr_[byteIdx];
+  return (twoByteVal >> shift) & hll_constants::VAL_MASK_6;
 }
 
 template<typename A>
-void Hll6Array<A>::putSlot(int slotNo, uint8_t value) {
-  const int startBit = slotNo * 6;
-  const int shift = startBit & 0x7;
-  const int byteIdx = startBit >> 3;
+void Hll6Array<A>::putSlot(uint32_t slotNo, uint8_t value) {
+  const uint32_t startBit = slotNo * 6;
+  const uint32_t shift = startBit & 0x7;
+  const uint32_t byteIdx = startBit >> 3;
   const uint16_t valShifted = (value & 0x3F) << shift;
-  uint16_t curMasked = (this->hllByteArr[byteIdx + 1] << 8) | this->hllByteArr[byteIdx];
-  curMasked &= (~(HllUtil<A>::VAL_MASK_6 << shift));
+  uint16_t curMasked = (this->hllByteArr_[byteIdx + 1] << 8) | this->hllByteArr_[byteIdx];
+  curMasked &= (~(hll_constants::VAL_MASK_6 << shift));
   const uint16_t insert = curMasked | valShifted;
-  this->hllByteArr[byteIdx]     = insert & 0xFF;
-  this->hllByteArr[byteIdx + 1] = (insert & 0xFF00) >> 8;
+  this->hllByteArr_[byteIdx]     = insert & 0xFF;
+  this->hllByteArr_[byteIdx + 1] = (insert & 0xFF00) >> 8;
 }
 
 template<typename A>
-int Hll6Array<A>::getHllByteArrBytes() const {
-  return this->hll6ArrBytes(this->lgConfigK);
+uint32_t Hll6Array<A>::getHllByteArrBytes() const {
+  return this->hll6ArrBytes(this->lgConfigK_);
 }
 
 template<typename A>
-HllSketchImpl<A>* Hll6Array<A>::couponUpdate(const int coupon) {
+HllSketchImpl<A>* Hll6Array<A>::couponUpdate(uint32_t coupon) {
   internalCouponUpdate(coupon);
   return this;
 }
 
 template<typename A>
-void Hll6Array<A>::internalCouponUpdate(const int coupon) {
-  const int configKmask = (1 << this->lgConfigK) - 1;
-  const int slotNo = HllUtil<A>::getLow26(coupon) & configKmask;
-  const int newVal = HllUtil<A>::getValue(coupon);
+void Hll6Array<A>::internalCouponUpdate(uint32_t coupon) {
+  const uint32_t configKmask = (1 << this->lgConfigK_) - 1;
+  const uint32_t slotNo = HllUtil<A>::getLow26(coupon) & configKmask;
+  const uint8_t newVal = HllUtil<A>::getValue(coupon);
 
-  const int curVal = getSlot(slotNo);
+  const uint8_t curVal = getSlot(slotNo);
   if (newVal > curVal) {
     putSlot(slotNo, newVal);
     this->hipAndKxQIncrementalUpdate(curVal, newVal);
     if (curVal == 0) {
-      this->numAtCurMin--; // interpret numAtCurMin as num zeros
+      this->numAtCurMin_--; // interpret numAtCurMin as num zeros
     }
   }
 }
 
 template<typename A>
 void Hll6Array<A>::mergeHll(const HllArray<A>& src) {
-  for (auto coupon: src) {
+  for (const auto coupon: src) {
     internalCouponUpdate(coupon);
   }
 }
diff --git a/hll/include/Hll6Array.hpp b/hll/include/Hll6Array.hpp
index 03370b2..3c821c6 100644
--- a/hll/include/Hll6Array.hpp
+++ b/hll/include/Hll6Array.hpp
@@ -30,23 +30,23 @@
 template<typename A>
 class Hll6Array final : public HllArray<A> {
   public:
-    Hll6Array(int lgConfigK, bool startFullSize, const A& allocator);
+    Hll6Array(uint8_t lgConfigK, bool startFullSize, const A& allocator);
 
     virtual ~Hll6Array() = default;
     virtual std::function<void(HllSketchImpl<A>*)> get_deleter() const;
 
     virtual Hll6Array* copy() const;
 
-    inline uint8_t getSlot(int slotNo) const;
-    inline void putSlot(int slotNo, uint8_t value);
+    inline uint8_t getSlot(uint32_t slotNo) const;
+    inline void putSlot(uint32_t slotNo, uint8_t value);
 
-    virtual HllSketchImpl<A>* couponUpdate(int coupon) final;
+    virtual HllSketchImpl<A>* couponUpdate(uint32_t coupon) final;
     void mergeHll(const HllArray<A>& src);
 
-    virtual int getHllByteArrBytes() const;
+    virtual uint32_t getHllByteArrBytes() const;
 
   private:
-    void internalCouponUpdate(int coupon);
+    void internalCouponUpdate(uint32_t coupon);
 };
 
 }
diff --git a/hll/include/Hll8Array-internal.hpp b/hll/include/Hll8Array-internal.hpp
index f27a796..d4de2a1 100644
--- a/hll/include/Hll8Array-internal.hpp
+++ b/hll/include/Hll8Array-internal.hpp
@@ -25,11 +25,11 @@
 namespace datasketches {
 
 template<typename A>
-Hll8Array<A>::Hll8Array(const int lgConfigK, const bool startFullSize, const A& allocator):
+Hll8Array<A>::Hll8Array(uint8_t lgConfigK, bool startFullSize, const A& allocator):
 HllArray<A>(lgConfigK, target_hll_type::HLL_8, startFullSize, allocator)
 {
   const int numBytes = this->hll8ArrBytes(lgConfigK);
-  this->hllByteArr.resize(numBytes, 0);
+  this->hllByteArr_.resize(numBytes, 0);
 }
 
 template<typename A>
@@ -51,45 +51,45 @@
 }
 
 template<typename A>
-uint8_t Hll8Array<A>::getSlot(const int slotNo) const {
-  return this->hllByteArr[slotNo];
+uint8_t Hll8Array<A>::getSlot(uint32_t slotNo) const {
+  return this->hllByteArr_[slotNo];
 }
 
 template<typename A>
-void Hll8Array<A>::putSlot(const int slotNo, uint8_t value) {
-  this->hllByteArr[slotNo] = value;
+void Hll8Array<A>::putSlot(uint32_t slotNo, uint8_t value) {
+  this->hllByteArr_[slotNo] = value;
 }
 
 template<typename A>
-int Hll8Array<A>::getHllByteArrBytes() const {
-  return this->hll8ArrBytes(this->lgConfigK);
+uint32_t Hll8Array<A>::getHllByteArrBytes() const {
+  return this->hll8ArrBytes(this->lgConfigK_);
 }
 
 template<typename A>
-HllSketchImpl<A>* Hll8Array<A>::couponUpdate(int coupon) {
+HllSketchImpl<A>* Hll8Array<A>::couponUpdate(uint32_t coupon) {
   internalCouponUpdate(coupon);
   return this;
 }
 
 template<typename A>
-void Hll8Array<A>::internalCouponUpdate(int coupon) {
-  const int configKmask = (1 << this->lgConfigK) - 1;
-  const int slotNo = HllUtil<A>::getLow26(coupon) & configKmask;
-  const int newVal = HllUtil<A>::getValue(coupon);
+void Hll8Array<A>::internalCouponUpdate(uint32_t coupon) {
+  const uint32_t configKmask = (1 << this->lgConfigK_) - 1;
+  const uint32_t slotNo = HllUtil<A>::getLow26(coupon) & configKmask;
+  const uint8_t newVal = HllUtil<A>::getValue(coupon);
 
-  const int curVal = getSlot(slotNo);
+  const uint8_t curVal = getSlot(slotNo);
   if (newVal > curVal) {
     putSlot(slotNo, newVal);
     this->hipAndKxQIncrementalUpdate(curVal, newVal);
     if (curVal == 0) {
-      this->numAtCurMin--; // interpret numAtCurMin as num zeros
+      this->numAtCurMin_--; // interpret numAtCurMin as num zeros
     }
   }
 }
 
 template<typename A>
 void Hll8Array<A>::mergeList(const CouponList<A>& src) {
-  for (auto coupon: src) {
+  for (const auto coupon: src) {
     internalCouponUpdate(coupon);
   }
 }
@@ -97,45 +97,45 @@
 template<typename A>
 void Hll8Array<A>::mergeHll(const HllArray<A>& src) {
   // at this point src_k >= dst_k
-  const int src_k = 1 << src.getLgConfigK();
-  const  int dst_mask = (1 << this->getLgConfigK()) - 1;
+  const uint32_t src_k = 1 << src.getLgConfigK();
+  const uint32_t dst_mask = (1 << this->getLgConfigK()) - 1;
   // duplication below is to avoid a virtual method call in a loop
   if (src.getTgtHllType() == target_hll_type::HLL_8) {
-    for (int i = 0; i < src_k; i++) {
+    for (uint32_t i = 0; i < src_k; i++) {
       const uint8_t new_v = static_cast<const Hll8Array<A>&>(src).getSlot(i);
-      const int j = i & dst_mask;
-      const uint8_t old_v = this->hllByteArr[j];
+      const uint32_t j = i & dst_mask;
+      const uint8_t old_v = this->hllByteArr_[j];
       if (new_v > old_v) {
-        this->hllByteArr[j] = new_v;
+        this->hllByteArr_[j] = new_v;
         this->hipAndKxQIncrementalUpdate(old_v, new_v);
         if (old_v == 0) {
-          this->numAtCurMin--;
+          this->numAtCurMin_--;
         }
       }
     }
   } else if (src.getTgtHllType() == target_hll_type::HLL_6) {
-    for (int i = 0; i < src_k; i++) {
+    for (uint32_t i = 0; i < src_k; i++) {
       const uint8_t new_v = static_cast<const Hll6Array<A>&>(src).getSlot(i);
-      const int j = i & dst_mask;
-      const uint8_t old_v = this->hllByteArr[j];
+      const uint32_t j = i & dst_mask;
+      const uint8_t old_v = this->hllByteArr_[j];
       if (new_v > old_v) {
-        this->hllByteArr[j] = new_v;
+        this->hllByteArr_[j] = new_v;
         this->hipAndKxQIncrementalUpdate(old_v, new_v);
         if (old_v == 0) {
-          this->numAtCurMin--;
+          this->numAtCurMin_--;
         }
       }
     }
   } else { // HLL_4
-    for (int i = 0; i < src_k; i++) {
+    for (uint32_t i = 0; i < src_k; i++) {
       const uint8_t new_v = static_cast<const Hll4Array<A>&>(src).get_value(i);
-      const int j = i & dst_mask;
-      const uint8_t old_v = this->hllByteArr[j];
+      const uint32_t j = i & dst_mask;
+      const uint8_t old_v = this->hllByteArr_[j];
       if (new_v > old_v) {
-        this->hllByteArr[j] = new_v;
+        this->hllByteArr_[j] = new_v;
         this->hipAndKxQIncrementalUpdate(old_v, new_v);
         if (old_v == 0) {
-          this->numAtCurMin--;
+          this->numAtCurMin_--;
         }
       }
     }
diff --git a/hll/include/Hll8Array.hpp b/hll/include/Hll8Array.hpp
index ea9a5bd..54db472 100644
--- a/hll/include/Hll8Array.hpp
+++ b/hll/include/Hll8Array.hpp
@@ -30,24 +30,24 @@
 template<typename A>
 class Hll8Array final : public HllArray<A> {
   public:
-    Hll8Array(int lgConfigK, bool startFullSize, const A& allocator);
+    Hll8Array(uint8_t lgConfigK, bool startFullSize, const A& allocator);
 
     virtual ~Hll8Array() = default;
     virtual std::function<void(HllSketchImpl<A>*)> get_deleter() const;
 
     virtual Hll8Array<A>* copy() const;
 
-    inline uint8_t getSlot(int slotNo) const;
-    inline void putSlot(int slotNo, uint8_t value);
+    inline uint8_t getSlot(uint32_t slotNo) const;
+    inline void putSlot(uint32_t slotNo, uint8_t value);
 
-    virtual HllSketchImpl<A>* couponUpdate(int coupon) final;
+    virtual HllSketchImpl<A>* couponUpdate(uint32_t coupon) final;
     void mergeList(const CouponList<A>& src);
     void mergeHll(const HllArray<A>& src);
 
-    virtual int getHllByteArrBytes() const;
+    virtual uint32_t getHllByteArrBytes() const;
 
   private:
-    inline void internalCouponUpdate(int coupon);
+    inline void internalCouponUpdate(uint32_t coupon);
 };
 
 }
diff --git a/hll/include/HllArray-internal.hpp b/hll/include/HllArray-internal.hpp
index 95ef116..92524fb 100644
--- a/hll/include/HllArray-internal.hpp
+++ b/hll/include/HllArray-internal.hpp
@@ -35,19 +35,19 @@
 namespace datasketches {
 
 template<typename A>
-HllArray<A>::HllArray(const int lgConfigK, const target_hll_type tgtHllType, bool startFullSize, const A& allocator):
+HllArray<A>::HllArray(uint8_t lgConfigK, target_hll_type tgtHllType, bool startFullSize, const A& allocator):
 HllSketchImpl<A>(lgConfigK, tgtHllType, hll_mode::HLL, startFullSize),
-hipAccum(0.0),
-kxq0(1 << lgConfigK),
-kxq1(0.0),
-hllByteArr(allocator),
-curMin(0),
-numAtCurMin(1 << lgConfigK),
-oooFlag(false)
+hipAccum_(0.0),
+kxq0_(1 << lgConfigK),
+kxq1_(0.0),
+hllByteArr_(allocator),
+curMin_(0),
+numAtCurMin_(1 << lgConfigK),
+oooFlag_(false)
 {}
 
 template<typename A>
-HllArray<A>* HllArray<A>::copyAs(const target_hll_type tgtHllType) const {
+HllArray<A>* HllArray<A>::copyAs(target_hll_type tgtHllType) const {
   if (tgtHllType == this->getTgtHllType()) {
     return static_cast<HllArray*>(copy());
   }
@@ -62,54 +62,54 @@
 
 template<typename A>
 HllArray<A>* HllArray<A>::newHll(const void* bytes, size_t len, const A& allocator) {
-  if (len < HllUtil<A>::HLL_BYTE_ARR_START) {
+  if (len < hll_constants::HLL_BYTE_ARR_START) {
     throw std::out_of_range("Input data length insufficient to hold HLL array");
   }
 
   const uint8_t* data = static_cast<const uint8_t*>(bytes);
-  if (data[HllUtil<A>::PREAMBLE_INTS_BYTE] != HllUtil<A>::HLL_PREINTS) {
+  if (data[hll_constants::PREAMBLE_INTS_BYTE] != hll_constants::HLL_PREINTS) {
     throw std::invalid_argument("Incorrect number of preInts in input stream");
   }
-  if (data[HllUtil<A>::SER_VER_BYTE] != HllUtil<A>::SER_VER) {
+  if (data[hll_constants::SER_VER_BYTE] != hll_constants::SER_VER) {
     throw std::invalid_argument("Wrong ser ver in input stream");
   }
-  if (data[HllUtil<A>::FAMILY_BYTE] != HllUtil<A>::FAMILY_ID) {
+  if (data[hll_constants::FAMILY_BYTE] != hll_constants::FAMILY_ID) {
     throw std::invalid_argument("Input array is not an HLL sketch");
   }
 
-  const hll_mode mode = HllSketchImpl<A>::extractCurMode(data[HllUtil<A>::MODE_BYTE]);
+  const hll_mode mode = HllSketchImpl<A>::extractCurMode(data[hll_constants::MODE_BYTE]);
   if (mode != HLL) {
-    throw std::invalid_argument("Calling HLL array construtor with non-HLL mode data");
+    throw std::invalid_argument("Calling HLL array constructor with non-HLL mode data");
   }
 
-  const target_hll_type tgtHllType = HllSketchImpl<A>::extractTgtHllType(data[HllUtil<A>::MODE_BYTE]);
-  const bool oooFlag = ((data[HllUtil<A>::FLAGS_BYTE] & HllUtil<A>::OUT_OF_ORDER_FLAG_MASK) ? true : false);
-  const bool comapctFlag = ((data[HllUtil<A>::FLAGS_BYTE] & HllUtil<A>::COMPACT_FLAG_MASK) ? true : false);
-  const bool startFullSizeFlag = ((data[HllUtil<A>::FLAGS_BYTE] & HllUtil<A>::FULL_SIZE_FLAG_MASK) ? true : false);
+  const target_hll_type tgtHllType = HllSketchImpl<A>::extractTgtHllType(data[hll_constants::MODE_BYTE]);
+  const bool oooFlag = ((data[hll_constants::FLAGS_BYTE] & hll_constants::OUT_OF_ORDER_FLAG_MASK) ? true : false);
+  const bool comapctFlag = ((data[hll_constants::FLAGS_BYTE] & hll_constants::COMPACT_FLAG_MASK) ? true : false);
+  const bool startFullSizeFlag = ((data[hll_constants::FLAGS_BYTE] & hll_constants::FULL_SIZE_FLAG_MASK) ? true : false);
 
-  const int lgK = (int) data[HllUtil<A>::LG_K_BYTE];
-  const int curMin = (int) data[HllUtil<A>::HLL_CUR_MIN_BYTE];
+  const uint8_t lgK = data[hll_constants::LG_K_BYTE];
+  const uint8_t curMin = data[hll_constants::HLL_CUR_MIN_BYTE];
 
-  const int arrayBytes = hllArrBytes(tgtHllType, lgK);
-  if (len < static_cast<size_t>(HllUtil<A>::HLL_BYTE_ARR_START + arrayBytes)) {
+  const uint32_t arrayBytes = hllArrBytes(tgtHllType, lgK);
+  if (len < static_cast<size_t>(hll_constants::HLL_BYTE_ARR_START + arrayBytes)) {
     throw std::out_of_range("Input array too small to hold sketch image");
   }
 
   double hip, kxq0, kxq1;
-  std::memcpy(&hip, data + HllUtil<A>::HIP_ACCUM_DOUBLE, sizeof(double));
-  std::memcpy(&kxq0, data + HllUtil<A>::KXQ0_DOUBLE, sizeof(double));
-  std::memcpy(&kxq1, data + HllUtil<A>::KXQ1_DOUBLE, sizeof(double));
+  std::memcpy(&hip, data + hll_constants::HIP_ACCUM_DOUBLE, sizeof(double));
+  std::memcpy(&kxq0, data + hll_constants::KXQ0_DOUBLE, sizeof(double));
+  std::memcpy(&kxq1, data + hll_constants::KXQ1_DOUBLE, sizeof(double));
 
-  int numAtCurMin, auxCount;
-  std::memcpy(&numAtCurMin, data + HllUtil<A>::CUR_MIN_COUNT_INT, sizeof(int));
-  std::memcpy(&auxCount, data + HllUtil<A>::AUX_COUNT_INT, sizeof(int));
+  uint32_t numAtCurMin, auxCount;
+  std::memcpy(&numAtCurMin, data + hll_constants::CUR_MIN_COUNT_INT, sizeof(int));
+  std::memcpy(&auxCount, data + hll_constants::AUX_COUNT_INT, sizeof(int));
 
   AuxHashMap<A>* auxHashMap = nullptr;
   typedef std::unique_ptr<AuxHashMap<A>, std::function<void(AuxHashMap<A>*)>> aux_hash_map_ptr;
   aux_hash_map_ptr aux_ptr;
   if (auxCount > 0) { // necessarily TgtHllType == HLL_4
-    int auxLgIntArrSize = (int) data[4];
-    const size_t offset = HllUtil<A>::HLL_BYTE_ARR_START + arrayBytes;
+    uint8_t auxLgIntArrSize = data[4];
+    const size_t offset = hll_constants::HLL_BYTE_ARR_START + arrayBytes;
     const uint8_t* auxDataStart = data + offset;
     auxHashMap = AuxHashMap<A>::deserialize(auxDataStart, len - offset, lgK, auxCount, auxLgIntArrSize, comapctFlag, allocator);
     aux_ptr = aux_hash_map_ptr(auxHashMap, auxHashMap->make_deleter());
@@ -123,7 +123,7 @@
   sketch->putKxQ1(kxq1);
   sketch->putNumAtCurMin(numAtCurMin);
 
-  std::memcpy(sketch->hllByteArr.data(), data + HllUtil<A>::HLL_BYTE_ARR_START, arrayBytes);
+  std::memcpy(sketch->hllByteArr_.data(), data + hll_constants::HLL_BYTE_ARR_START, arrayBytes);
 
   if (auxHashMap != nullptr)
     ((Hll4Array<A>*)sketch)->putAuxHashMap(auxHashMap);
@@ -137,28 +137,28 @@
   uint8_t listHeader[8];
   read(is, listHeader, 8 * sizeof(uint8_t));
 
-  if (listHeader[HllUtil<A>::PREAMBLE_INTS_BYTE] != HllUtil<A>::HLL_PREINTS) {
+  if (listHeader[hll_constants::PREAMBLE_INTS_BYTE] != hll_constants::HLL_PREINTS) {
     throw std::invalid_argument("Incorrect number of preInts in input stream");
   }
-  if (listHeader[HllUtil<A>::SER_VER_BYTE] != HllUtil<A>::SER_VER) {
+  if (listHeader[hll_constants::SER_VER_BYTE] != hll_constants::SER_VER) {
     throw std::invalid_argument("Wrong ser ver in input stream");
   }
-  if (listHeader[HllUtil<A>::FAMILY_BYTE] != HllUtil<A>::FAMILY_ID) {
+  if (listHeader[hll_constants::FAMILY_BYTE] != hll_constants::FAMILY_ID) {
     throw std::invalid_argument("Input stream is not an HLL sketch");
   }
 
-  hll_mode mode = HllSketchImpl<A>::extractCurMode(listHeader[HllUtil<A>::MODE_BYTE]);
+  hll_mode mode = HllSketchImpl<A>::extractCurMode(listHeader[hll_constants::MODE_BYTE]);
   if (mode != HLL) {
     throw std::invalid_argument("Calling HLL construtor with non-HLL mode data");
   }
 
-  const target_hll_type tgtHllType = HllSketchImpl<A>::extractTgtHllType(listHeader[HllUtil<A>::MODE_BYTE]);
-  const bool oooFlag = ((listHeader[HllUtil<A>::FLAGS_BYTE] & HllUtil<A>::OUT_OF_ORDER_FLAG_MASK) ? true : false);
-  const bool comapctFlag = ((listHeader[HllUtil<A>::FLAGS_BYTE] & HllUtil<A>::COMPACT_FLAG_MASK) ? true : false);
-  const bool startFullSizeFlag = ((listHeader[HllUtil<A>::FLAGS_BYTE] & HllUtil<A>::FULL_SIZE_FLAG_MASK) ? true : false);
+  const target_hll_type tgtHllType = HllSketchImpl<A>::extractTgtHllType(listHeader[hll_constants::MODE_BYTE]);
+  const bool oooFlag = ((listHeader[hll_constants::FLAGS_BYTE] & hll_constants::OUT_OF_ORDER_FLAG_MASK) ? true : false);
+  const bool comapctFlag = ((listHeader[hll_constants::FLAGS_BYTE] & hll_constants::COMPACT_FLAG_MASK) ? true : false);
+  const bool startFullSizeFlag = ((listHeader[hll_constants::FLAGS_BYTE] & hll_constants::FULL_SIZE_FLAG_MASK) ? true : false);
 
-  const int lgK = (int) listHeader[HllUtil<A>::LG_K_BYTE];
-  const int curMin = (int) listHeader[HllUtil<A>::HLL_CUR_MIN_BYTE];
+  const uint8_t lgK = listHeader[hll_constants::LG_K_BYTE];
+  const uint8_t curMin = listHeader[hll_constants::HLL_CUR_MIN_BYTE];
 
   HllArray* sketch = HllSketchImplFactory<A>::newHll(lgK, tgtHllType, startFullSizeFlag, allocator);
   typedef std::unique_ptr<HllArray<A>, std::function<void(HllSketchImpl<A>*)>> hll_array_ptr;
@@ -173,14 +173,14 @@
   sketch->putKxQ0(kxq0);
   sketch->putKxQ1(kxq1);
 
-  const auto numAtCurMin = read<int>(is);
-  const auto auxCount = read<int>(is);
+  const auto numAtCurMin = read<uint32_t>(is);
+  const auto auxCount = read<uint32_t>(is);
   sketch->putNumAtCurMin(numAtCurMin);
   
-  read(is, sketch->hllByteArr.data(), sketch->getHllByteArrBytes());
+  read(is, sketch->hllByteArr_.data(), sketch->getHllByteArrBytes());
   
   if (auxCount > 0) { // necessarily TgtHllType == HLL_4
-    int auxLgIntArrSize = listHeader[4];
+    uint8_t auxLgIntArrSize = listHeader[4];
     AuxHashMap<A>* auxHashMap = AuxHashMap<A>::deserialize(is, lgK, auxCount, auxLgIntArrSize, comapctFlag, allocator);
     ((Hll4Array<A>*)sketch)->putAuxHashMap(auxHashMap);
   }
@@ -198,31 +198,31 @@
   uint8_t* bytes = byteArr.data() + header_size_bytes;
   AuxHashMap<A>* auxHashMap = getAuxHashMap();
 
-  bytes[HllUtil<A>::PREAMBLE_INTS_BYTE] = static_cast<uint8_t>(getPreInts());
-  bytes[HllUtil<A>::SER_VER_BYTE] = static_cast<uint8_t>(HllUtil<A>::SER_VER);
-  bytes[HllUtil<A>::FAMILY_BYTE] = static_cast<uint8_t>(HllUtil<A>::FAMILY_ID);
-  bytes[HllUtil<A>::LG_K_BYTE] = static_cast<uint8_t>(this->lgConfigK);
-  bytes[HllUtil<A>::LG_ARR_BYTE] = static_cast<uint8_t>(auxHashMap == nullptr ? 0 : auxHashMap->getLgAuxArrInts());
-  bytes[HllUtil<A>::FLAGS_BYTE] = this->makeFlagsByte(compact);
-  bytes[HllUtil<A>::HLL_CUR_MIN_BYTE] = static_cast<uint8_t>(curMin);
-  bytes[HllUtil<A>::MODE_BYTE] = this->makeModeByte();
+  bytes[hll_constants::PREAMBLE_INTS_BYTE] = static_cast<uint8_t>(getPreInts());
+  bytes[hll_constants::SER_VER_BYTE] = static_cast<uint8_t>(hll_constants::SER_VER);
+  bytes[hll_constants::FAMILY_BYTE] = static_cast<uint8_t>(hll_constants::FAMILY_ID);
+  bytes[hll_constants::LG_K_BYTE] = static_cast<uint8_t>(this->lgConfigK_);
+  bytes[hll_constants::LG_ARR_BYTE] = static_cast<uint8_t>(auxHashMap == nullptr ? 0 : auxHashMap->getLgAuxArrInts());
+  bytes[hll_constants::FLAGS_BYTE] = this->makeFlagsByte(compact);
+  bytes[hll_constants::HLL_CUR_MIN_BYTE] = static_cast<uint8_t>(curMin_);
+  bytes[hll_constants::MODE_BYTE] = this->makeModeByte();
 
-  std::memcpy(bytes + HllUtil<A>::HIP_ACCUM_DOUBLE, &hipAccum, sizeof(double));
-  std::memcpy(bytes + HllUtil<A>::KXQ0_DOUBLE, &kxq0, sizeof(double));
-  std::memcpy(bytes + HllUtil<A>::KXQ1_DOUBLE, &kxq1, sizeof(double));
-  std::memcpy(bytes + HllUtil<A>::CUR_MIN_COUNT_INT, &numAtCurMin, sizeof(int));
-  const int auxCount = (auxHashMap == nullptr ? 0 : auxHashMap->getAuxCount());
-  std::memcpy(bytes + HllUtil<A>::AUX_COUNT_INT, &auxCount, sizeof(int));
+  std::memcpy(bytes + hll_constants::HIP_ACCUM_DOUBLE, &hipAccum_, sizeof(double));
+  std::memcpy(bytes + hll_constants::KXQ0_DOUBLE, &kxq0_, sizeof(double));
+  std::memcpy(bytes + hll_constants::KXQ1_DOUBLE, &kxq1_, sizeof(double));
+  std::memcpy(bytes + hll_constants::CUR_MIN_COUNT_INT, &numAtCurMin_, sizeof(uint32_t));
+  const uint32_t auxCount = (auxHashMap == nullptr ? 0 : auxHashMap->getAuxCount());
+  std::memcpy(bytes + hll_constants::AUX_COUNT_INT, &auxCount, sizeof(uint32_t));
 
-  const int hllByteArrBytes = getHllByteArrBytes();
-  std::memcpy(bytes + getMemDataStart(), hllByteArr.data(), hllByteArrBytes);
+  const uint32_t hllByteArrBytes = getHllByteArrBytes();
+  std::memcpy(bytes + getMemDataStart(), hllByteArr_.data(), hllByteArrBytes);
 
   // aux map if HLL_4
-  if (this->tgtHllType == HLL_4) {
+  if (this->tgtHllType_ == HLL_4) {
     bytes += getMemDataStart() + hllByteArrBytes; // start of auxHashMap
     if (auxHashMap != nullptr) {
       if (compact) {
-        for (uint32_t coupon: *auxHashMap) {
+        for (const uint32_t coupon: *auxHashMap) {
           std::memcpy(bytes, &coupon, sizeof(coupon));
           bytes += sizeof(coupon);
         }
@@ -231,8 +231,8 @@
       }
     } else if (!compact) {
       // if updatable, we write even if currently unused so the binary can be wrapped
-      int auxBytes = 4 << HllUtil<A>::LG_AUX_ARR_INTS[this->lgConfigK];
-      std::fill_n(bytes, auxBytes, 0);
+      uint32_t auxBytes = 4 << hll_constants::LG_AUX_ARR_INTS[this->lgConfigK_];
+      std::fill_n(bytes, auxBytes, static_cast<uint8_t>(0));
     }
   }
 
@@ -240,48 +240,47 @@
 }
 
 template<typename A>
-void HllArray<A>::serialize(std::ostream& os, const bool compact) const {
+void HllArray<A>::serialize(std::ostream& os, bool compact) const {
   // header
-  const uint8_t preInts(getPreInts());
+  const uint8_t preInts = getPreInts();
   write(os, preInts);
-  const uint8_t serialVersion(HllUtil<A>::SER_VER);
+  const uint8_t serialVersion = hll_constants::SER_VER;
   write(os, serialVersion);
-  const uint8_t familyId(HllUtil<A>::FAMILY_ID);
+  const uint8_t familyId = hll_constants::FAMILY_ID;
   write(os, familyId);
-  const uint8_t lgKByte((uint8_t) this->lgConfigK);
+  const uint8_t lgKByte = this->lgConfigK_;
   write(os, lgKByte);
 
   AuxHashMap<A>* auxHashMap = getAuxHashMap();
-  uint8_t lgArrByte(0);
+  uint8_t lgArrByte = 0;
   if (auxHashMap != nullptr) {
     lgArrByte = auxHashMap->getLgAuxArrInts();
   }
   write(os, lgArrByte);
 
-  const uint8_t flagsByte(this->makeFlagsByte(compact));
+  const uint8_t flagsByte = this->makeFlagsByte(compact);
   write(os, flagsByte);
-  const uint8_t curMinByte((uint8_t) curMin);
-  write(os, curMinByte);
-  const uint8_t modeByte(this->makeModeByte());
+  write(os, curMin_);
+  const uint8_t modeByte = this->makeModeByte();
   write(os, modeByte);
 
   // estimator data
-  write(os, hipAccum);
-  write(os, kxq0);
-  write(os, kxq1);
+  write(os, hipAccum_);
+  write(os, kxq0_);
+  write(os, kxq1_);
 
   // array data
-  write(os, numAtCurMin);
+  write(os, numAtCurMin_);
 
-  const int auxCount = (auxHashMap == nullptr ? 0 : auxHashMap->getAuxCount());
+  const uint32_t auxCount = (auxHashMap == nullptr ? 0 : auxHashMap->getAuxCount());
   write(os, auxCount);
-  write(os, hllByteArr.data(), getHllByteArrBytes());
+  write(os, hllByteArr_.data(), getHllByteArrBytes());
 
   // aux map if HLL_4
-  if (this->tgtHllType == HLL_4) {
+  if (this->tgtHllType_ == HLL_4) {
     if (auxHashMap != nullptr) {
       if (compact) {
-        for (uint32_t coupon: *auxHashMap) {
+        for (const uint32_t coupon: *auxHashMap) {
           write(os, coupon);
         }
       } else {
@@ -289,15 +288,15 @@
       }
     } else if (!compact) {
       // if updatable, we write even if currently unused so the binary can be wrapped      
-      int auxBytes = 4 << HllUtil<A>::LG_AUX_ARR_INTS[this->lgConfigK];
-      std::fill_n(std::ostreambuf_iterator<char>(os), auxBytes, 0);
+      uint32_t auxBytes = 4 << hll_constants::LG_AUX_ARR_INTS[this->lgConfigK_];
+      std::fill_n(std::ostreambuf_iterator<char>(os), auxBytes, static_cast<char>(0));
     }
   }
 }
 
 template<typename A>
 double HllArray<A>::getEstimate() const {
-  if (oooFlag) {
+  if (oooFlag_) {
     return getCompositeEstimate();
   }
   return getHipAccum();
@@ -319,50 +318,50 @@
  * the very small values <= k where curMin = 0 still apply.
  */
 template<typename A>
-double HllArray<A>::getLowerBound(const int numStdDev) const {
+double HllArray<A>::getLowerBound(uint8_t numStdDev) const {
   HllUtil<A>::checkNumStdDev(numStdDev);
-  const int configK = 1 << this->lgConfigK;
-  const double numNonZeros = ((curMin == 0) ? (configK - numAtCurMin) : configK);
+  const uint32_t configK = 1 << this->lgConfigK_;
+  const double numNonZeros = ((curMin_ == 0) ? (configK - numAtCurMin_) : configK);
 
   double estimate;
   double rseFactor;
-  if (oooFlag) {
+  if (oooFlag_) {
     estimate = getCompositeEstimate();
-    rseFactor = HllUtil<A>::HLL_NON_HIP_RSE_FACTOR;
+    rseFactor = hll_constants::HLL_NON_HIP_RSE_FACTOR;
   } else {
-    estimate = hipAccum;
-    rseFactor = HllUtil<A>::HLL_HIP_RSE_FACTOR;
+    estimate = hipAccum_;
+    rseFactor = hll_constants::HLL_HIP_RSE_FACTOR;
   }
 
   double relErr;
-  if (this->lgConfigK > 12) {
+  if (this->lgConfigK_ > 12) {
     relErr = (numStdDev * rseFactor) / sqrt(configK);
   } else {
-    relErr = HllUtil<A>::getRelErr(false, oooFlag, this->lgConfigK, numStdDev);
+    relErr = HllUtil<A>::getRelErr(false, oooFlag_, this->lgConfigK_, numStdDev);
   }
   return fmax(estimate / (1.0 + relErr), numNonZeros);
 }
 
 template<typename A>
-double HllArray<A>::getUpperBound(const int numStdDev) const {
+double HllArray<A>::getUpperBound(uint8_t numStdDev) const {
   HllUtil<A>::checkNumStdDev(numStdDev);
-  const int configK = 1 << this->lgConfigK;
+  const uint32_t configK = 1 << this->lgConfigK_;
 
   double estimate;
   double rseFactor;
-  if (oooFlag) {
+  if (oooFlag_) {
     estimate = getCompositeEstimate();
-    rseFactor = HllUtil<A>::HLL_NON_HIP_RSE_FACTOR;
+    rseFactor = hll_constants::HLL_NON_HIP_RSE_FACTOR;
   } else {
-    estimate = hipAccum;
-    rseFactor = HllUtil<A>::HLL_HIP_RSE_FACTOR;
+    estimate = hipAccum_;
+    rseFactor = hll_constants::HLL_HIP_RSE_FACTOR;
   }
 
   double relErr;
-  if (this->lgConfigK > 12) {
+  if (this->lgConfigK_ > 12) {
     relErr = (-1.0) * (numStdDev * rseFactor) / sqrt(configK);
   } else {
-    relErr = HllUtil<A>::getRelErr(true, oooFlag, this->lgConfigK, numStdDev);
+    relErr = HllUtil<A>::getRelErr(true, oooFlag_, this->lgConfigK_, numStdDev);
   }
   return estimate / (1.0 + relErr);
 }
@@ -376,21 +375,21 @@
 // Original C: again-two-registers.c hhb_get_composite_estimate L1489
 template<typename A>
 double HllArray<A>::getCompositeEstimate() const {
-  const double rawEst = getHllRawEstimate(this->lgConfigK, kxq0 + kxq1);
+  const double rawEst = getHllRawEstimate();
 
-  const double* xArr = CompositeInterpolationXTable<A>::get_x_arr(this->lgConfigK);
-  const int xArrLen = CompositeInterpolationXTable<A>::get_x_arr_length();
-  const double yStride = CompositeInterpolationXTable<A>::get_y_stride(this->lgConfigK);
+  const double* xArr = CompositeInterpolationXTable<A>::get_x_arr(this->lgConfigK_);
+  const uint32_t xArrLen = CompositeInterpolationXTable<A>::get_x_arr_length();
+  const double yStride = CompositeInterpolationXTable<A>::get_y_stride(this->lgConfigK_);
 
   if (rawEst < xArr[0]) {
     return 0;
   }
 
-  const int xArrLenM1 = xArrLen - 1;
+  const uint32_t xArrLenM1 = xArrLen - 1;
 
   if (rawEst > xArr[xArrLenM1]) {
-    double finalY = yStride * xArrLenM1;
-    double factor = finalY / xArr[xArrLenM1];
+    const double finalY = yStride * xArrLenM1;
+    const double factor = finalY / xArr[xArrLenM1];
     return rawEst * factor;
   }
 
@@ -399,10 +398,9 @@
   // We need to completely avoid the linear_counting estimator if it might have a crazy value.
   // Empirical evidence suggests that the threshold 3*k will keep us safe if 2^4 <= k <= 2^21.
 
-  if (adjEst > (3 << this->lgConfigK)) { return adjEst; }
+  if (adjEst > (3 << this->lgConfigK_)) { return adjEst; }
 
-  const double linEst =
-      getHllBitMapEstimate(this->lgConfigK, curMin, numAtCurMin);
+  const double linEst = getHllBitMapEstimate();
 
   // Bias is created when the value of an estimator is compared with a threshold to decide whether
   // to use that estimator or a different one.
@@ -414,70 +412,70 @@
   // The following constants comes from empirical measurements of the crossover point
   // between the average error of the linear estimator and the adjusted hll estimator
   double crossOver = 0.64;
-  if (this->lgConfigK == 4)      { crossOver = 0.718; }
-  else if (this->lgConfigK == 5) { crossOver = 0.672; }
+  if (this->lgConfigK_ == 4)      { crossOver = 0.718; }
+  else if (this->lgConfigK_ == 5) { crossOver = 0.672; }
 
-  return (avgEst > (crossOver * (1 << this->lgConfigK))) ? adjEst : linEst;
+  return (avgEst > (crossOver * (1 << this->lgConfigK_))) ? adjEst : linEst;
 }
 
 template<typename A>
 double HllArray<A>::getKxQ0() const {
-  return kxq0;
+  return kxq0_;
 }
 
 template<typename A>
 double HllArray<A>::getKxQ1() const {
-  return kxq1;
+  return kxq1_;
 }
 
 template<typename A>
 double HllArray<A>::getHipAccum() const {
-  return hipAccum;
+  return hipAccum_;
 }
 
 template<typename A>
-int HllArray<A>::getCurMin() const {
-  return curMin;
+uint8_t HllArray<A>::getCurMin() const {
+  return curMin_;
 }
 
 template<typename A>
-int HllArray<A>::getNumAtCurMin() const {
-  return numAtCurMin;
+uint32_t HllArray<A>::getNumAtCurMin() const {
+  return numAtCurMin_;
 }
 
 template<typename A>
-void HllArray<A>::putKxQ0(const double kxq0) {
-  this->kxq0 = kxq0;
+void HllArray<A>::putKxQ0(double kxq0) {
+  kxq0_ = kxq0;
 }
 
 template<typename A>
-void HllArray<A>::putKxQ1(const double kxq1) {
-  this->kxq1 = kxq1;
+void HllArray<A>::putKxQ1(double kxq1) {
+  kxq1_ = kxq1;
 }
 
 template<typename A>
-void HllArray<A>::putHipAccum(const double hipAccum) {
-  this->hipAccum = hipAccum;
+void HllArray<A>::putHipAccum(double hipAccum) {
+  hipAccum_ = hipAccum;
 }
 
 template<typename A>
-void HllArray<A>::putCurMin(const int curMin) {
-  this->curMin = curMin;
+void HllArray<A>::putCurMin(uint8_t curMin) {
+  curMin_ = curMin;
 }
 
 template<typename A>
-void HllArray<A>::putNumAtCurMin(const int numAtCurMin) {
-  this->numAtCurMin = numAtCurMin;
+void HllArray<A>::putNumAtCurMin(uint32_t numAtCurMin) {
+  numAtCurMin_ = numAtCurMin;
 }
 
 template<typename A>
 void HllArray<A>::decNumAtCurMin() {
-  --numAtCurMin;
+  --numAtCurMin_;
 }
 
 template<typename A>
-void HllArray<A>::addToHipAccum(const double delta) {
-  hipAccum += delta;
+void HllArray<A>::addToHipAccum(double delta) {
+  hipAccum_ += delta;
 }
 
 template<typename A>
@@ -487,22 +485,22 @@
 
 template<typename A>
 bool HllArray<A>::isEmpty() const {
-  const int configK = 1 << this->lgConfigK;
+  const uint32_t configK = 1 << this->lgConfigK_;
   return (getCurMin() == 0) && (getNumAtCurMin() == configK);
 }
 
 template<typename A>
 void HllArray<A>::putOutOfOrderFlag(bool flag) {
-  oooFlag = flag;
+  oooFlag_ = flag;
 }
 
 template<typename A>
 bool HllArray<A>::isOutOfOrderFlag() const {
-  return oooFlag;
+  return oooFlag_;
 }
 
 template<typename A>
-int HllArray<A>::hllArrBytes(target_hll_type tgtHllType, int lgConfigK) {
+uint32_t HllArray<A>::hllArrBytes(target_hll_type tgtHllType, uint8_t lgConfigK) {
   switch (tgtHllType) {
   case HLL_4:
     return hll4ArrBytes(lgConfigK);
@@ -516,41 +514,41 @@
 }
 
 template<typename A>
-int HllArray<A>::hll4ArrBytes(const int lgConfigK) {
+uint32_t HllArray<A>::hll4ArrBytes(uint8_t lgConfigK) {
   return 1 << (lgConfigK - 1);
 }
 
 template<typename A>
-int HllArray<A>::hll6ArrBytes(const int lgConfigK) {
-  const int numSlots = 1 << lgConfigK;
+uint32_t HllArray<A>::hll6ArrBytes(uint8_t lgConfigK) {
+  const uint32_t numSlots = 1 << lgConfigK;
   return ((numSlots * 3) >> 2) + 1;
 }
 
 template<typename A>
-int HllArray<A>::hll8ArrBytes(const int lgConfigK) {
+uint32_t HllArray<A>::hll8ArrBytes(uint8_t lgConfigK) {
   return 1 << lgConfigK;
 }
 
 template<typename A>
-int HllArray<A>::getMemDataStart() const {
-  return HllUtil<A>::HLL_BYTE_ARR_START;
+uint32_t HllArray<A>::getMemDataStart() const {
+  return hll_constants::HLL_BYTE_ARR_START;
 }
 
 template<typename A>
-int HllArray<A>::getUpdatableSerializationBytes() const {
-  return HllUtil<A>::HLL_BYTE_ARR_START + getHllByteArrBytes();
+uint32_t HllArray<A>::getUpdatableSerializationBytes() const {
+  return hll_constants::HLL_BYTE_ARR_START + getHllByteArrBytes();
 }
 
 template<typename A>
-int HllArray<A>::getCompactSerializationBytes() const {
+uint32_t HllArray<A>::getCompactSerializationBytes() const {
   AuxHashMap<A>* auxHashMap = getAuxHashMap();
-  const int auxCountBytes = ((auxHashMap == nullptr) ? 0 : auxHashMap->getCompactSizeBytes());
-  return HllUtil<A>::HLL_BYTE_ARR_START + getHllByteArrBytes() + auxCountBytes;
+  const uint32_t auxCountBytes = ((auxHashMap == nullptr) ? 0 : auxHashMap->getCompactSizeBytes());
+  return hll_constants::HLL_BYTE_ARR_START + getHllByteArrBytes() + auxCountBytes;
 }
 
 template<typename A>
-int HllArray<A>::getPreInts() const {
-  return HllUtil<A>::HLL_PREINTS;
+uint8_t HllArray<A>::getPreInts() const {
+  return hll_constants::HLL_PREINTS;
 }
 
 template<typename A>
@@ -560,14 +558,14 @@
 
 template<typename A>
 void HllArray<A>::hipAndKxQIncrementalUpdate(uint8_t oldValue, uint8_t newValue) {
-  const int configK = 1 << this->getLgConfigK();
+  const uint32_t configK = 1 << this->getLgConfigK();
   // update hip BEFORE updating kxq
-  if (!oooFlag) hipAccum += configK / (kxq0 + kxq1);
+  if (!oooFlag_) hipAccum_ += configK / (kxq0_ + kxq1_);
   // update kxq0 and kxq1; subtract first, then add
-  if (oldValue < 32) { kxq0 -= INVERSE_POWERS_OF_2[oldValue]; }
-  else               { kxq1 -= INVERSE_POWERS_OF_2[oldValue]; }
-  if (newValue < 32) { kxq0 += INVERSE_POWERS_OF_2[newValue]; }
-  else               { kxq1 += INVERSE_POWERS_OF_2[newValue]; }
+  if (oldValue < 32) { kxq0_ -= INVERSE_POWERS_OF_2[oldValue]; }
+  else               { kxq1_ -= INVERSE_POWERS_OF_2[oldValue]; }
+  if (newValue < 32) { kxq0_ += INVERSE_POWERS_OF_2[newValue]; }
+  else               { kxq1_ += INVERSE_POWERS_OF_2[newValue]; }
 }
 
 /**
@@ -577,91 +575,91 @@
  */
 //In C: again-two-registers.c hhb_get_improved_linear_counting_estimate L1274
 template<typename A>
-double HllArray<A>::getHllBitMapEstimate(const int lgConfigK, const int curMin, const int numAtCurMin) const {
-  const  int configK = 1 << lgConfigK;
-  const  int numUnhitBuckets =  ((curMin == 0) ? numAtCurMin : 0);
+double HllArray<A>::getHllBitMapEstimate() const {
+  const uint32_t configK = 1 << this->lgConfigK_;
+  const uint32_t numUnhitBuckets = curMin_ == 0 ? numAtCurMin_ : 0;
 
   //This will eventually go away.
   if (numUnhitBuckets == 0) {
     return configK * log(configK / 0.5);
   }
 
-  const int numHitBuckets = configK - numUnhitBuckets;
+  const uint32_t numHitBuckets = configK - numUnhitBuckets;
   return HarmonicNumbers<A>::getBitMapEstimate(configK, numHitBuckets);
 }
 
 //In C: again-two-registers.c hhb_get_raw_estimate L1167
 template<typename A>
-double HllArray<A>::getHllRawEstimate(const int lgConfigK, const double kxqSum) const {
-  const int configK = 1 << lgConfigK;
+double HllArray<A>::getHllRawEstimate() const {
+  const uint32_t configK = 1 << this->lgConfigK_;
   double correctionFactor;
-  if (lgConfigK == 4) { correctionFactor = 0.673; }
-  else if (lgConfigK == 5) { correctionFactor = 0.697; }
-  else if (lgConfigK == 6) { correctionFactor = 0.709; }
+  if (this->lgConfigK_ == 4) { correctionFactor = 0.673; }
+  else if (this->lgConfigK_ == 5) { correctionFactor = 0.697; }
+  else if (this->lgConfigK_ == 6) { correctionFactor = 0.709; }
   else { correctionFactor = 0.7213 / (1.0 + (1.079 / configK)); }
-  const double hyperEst = (correctionFactor * configK * configK) / kxqSum;
+  const double hyperEst = (correctionFactor * configK * configK) / (kxq0_ + kxq1_);
   return hyperEst;
 }
 
 template<typename A>
 typename HllArray<A>::const_iterator HllArray<A>::begin(bool all) const {
-  return const_iterator(hllByteArr.data(), 1 << this->lgConfigK, 0, this->tgtHllType, nullptr, 0, all);
+  return const_iterator(hllByteArr_.data(), 1 << this->lgConfigK_, 0, this->tgtHllType_, nullptr, 0, all);
 }
 
 template<typename A>
 typename HllArray<A>::const_iterator HllArray<A>::end() const {
-  return const_iterator(hllByteArr.data(), 1 << this->lgConfigK, 1 << this->lgConfigK, this->tgtHllType, nullptr, 0, false);
+  return const_iterator(hllByteArr_.data(), 1 << this->lgConfigK_, 1 << this->lgConfigK_, this->tgtHllType_, nullptr, 0, false);
 }
 
 template<typename A>
-HllArray<A>::const_iterator::const_iterator(const uint8_t* array, size_t array_size, size_t index, target_hll_type hll_type, const AuxHashMap<A>* exceptions, uint8_t offset, bool all):
-array(array), array_size(array_size), index(index), hll_type(hll_type), exceptions(exceptions), offset(offset), all(all)
+HllArray<A>::const_iterator::const_iterator(const uint8_t* array, uint32_t array_size, uint32_t index, target_hll_type hll_type, const AuxHashMap<A>* exceptions, uint8_t offset, bool all):
+array_(array), array_size_(array_size), index_(index), hll_type_(hll_type), exceptions_(exceptions), offset_(offset), all_(all)
 {
-  while (this->index < array_size) {
-    value = get_value(array, this->index, hll_type, exceptions, offset);
-    if (all || value != HllUtil<A>::EMPTY) break;
-    this->index++;
+  while (index_ < array_size_) {
+    value_ = get_value(array_, index_, hll_type_, exceptions_, offset_);
+    if (all_ || value_ != hll_constants::EMPTY) break;
+    ++index_;
   }
 }
 
 template<typename A>
 typename HllArray<A>::const_iterator& HllArray<A>::const_iterator::operator++() {
-  while (++index < array_size) {
-    value = get_value(array, index, hll_type, exceptions, offset);
-    if (all || value != HllUtil<A>::EMPTY) break;
+  while (++index_ < array_size_) {
+    value_ = get_value(array_, index_, hll_type_, exceptions_, offset_);
+    if (all_ || value_ != hll_constants::EMPTY) break;
   }
   return *this;
 }
 
 template<typename A>
 bool HllArray<A>::const_iterator::operator!=(const const_iterator& other) const {
-  return index != other.index;
+  return index_ != other.index_;
 }
 
 template<typename A>
 uint32_t HllArray<A>::const_iterator::operator*() const {
-  return HllUtil<A>::pair(index, value);
+  return HllUtil<A>::pair(index_, value_);
 }
 
 template<typename A>
-uint8_t HllArray<A>::const_iterator::get_value(const uint8_t* array, size_t index, target_hll_type hll_type, const AuxHashMap<A>* exceptions, uint8_t offset) {
+uint8_t HllArray<A>::const_iterator::get_value(const uint8_t* array, uint32_t index, target_hll_type hll_type, const AuxHashMap<A>* exceptions, uint8_t offset) {
   if (hll_type == target_hll_type::HLL_4) {
     uint8_t value = array[index >> 1];
     if ((index & 1) > 0) { // odd
         value >>= 4;
     } else {
-      value &= HllUtil<A>::loNibbleMask;
+      value &= hll_constants::loNibbleMask;
     }
-    if (value == HllUtil<A>::AUX_TOKEN) { // exception
+    if (value == hll_constants::AUX_TOKEN) { // exception
       return exceptions->mustFindValueFor(index);
     }
     return value + offset;
   } else if (hll_type == target_hll_type::HLL_6) {
-    const int start_bit = index * 6;
-    const int shift = start_bit & 0x7;
-    const int byte_idx = start_bit >> 3;
+    const size_t start_bit = index * 6;
+    const uint8_t shift = start_bit & 0x7;
+    const size_t byte_idx = start_bit >> 3;
     const uint16_t two_byte_val = (array[byte_idx + 1] << 8) | array[byte_idx];
-    return (two_byte_val >> shift) & HllUtil<A>::VAL_MASK_6;
+    return (two_byte_val >> shift) & hll_constants::VAL_MASK_6;
   }
   // HLL_8
   return array[index];
@@ -669,7 +667,7 @@
 
 template<typename A>
 A HllArray<A>::getAllocator() const {
-  return hllByteArr.get_allocator();
+  return hllByteArr_.get_allocator();
 }
 
 }
diff --git a/hll/include/HllArray.hpp b/hll/include/HllArray.hpp
index e7be8c1..60aee76 100644
--- a/hll/include/HllArray.hpp
+++ b/hll/include/HllArray.hpp
@@ -31,7 +31,7 @@
 template<typename A>
 class HllArray : public HllSketchImpl<A> {
   public:
-    HllArray(int lgConfigK, target_hll_type tgtHllType, bool startFullSize, const A& allocator);
+    HllArray(uint8_t lgConfigK, target_hll_type tgtHllType, bool startFullSize, const A& allocator);
 
     static HllArray* newHll(const void* bytes, size_t len, const A& allocator);
     static HllArray* newHll(std::istream& is, const A& allocator);
@@ -45,25 +45,25 @@
     virtual HllArray* copy() const = 0;
     virtual HllArray* copyAs(target_hll_type tgtHllType) const;
 
-    virtual HllSketchImpl<A>* couponUpdate(int coupon) = 0;
+    virtual HllSketchImpl<A>* couponUpdate(uint32_t coupon) = 0;
 
     virtual double getEstimate() const;
     virtual double getCompositeEstimate() const;
-    virtual double getLowerBound(int numStdDev) const;
-    virtual double getUpperBound(int numStdDev) const;
+    virtual double getLowerBound(uint8_t numStdDev) const;
+    virtual double getUpperBound(uint8_t numStdDev) const;
 
     inline void addToHipAccum(double delta);
 
     inline void decNumAtCurMin();
 
-    inline int getCurMin() const;
-    inline int getNumAtCurMin() const;
+    inline uint8_t getCurMin() const;
+    inline uint32_t getNumAtCurMin() const;
     inline double getHipAccum() const;
 
-    virtual int getHllByteArrBytes() const = 0;
+    virtual uint32_t getHllByteArrBytes() const = 0;
 
-    virtual int getUpdatableSerializationBytes() const;
-    virtual int getCompactSerializationBytes() const;
+    virtual uint32_t getUpdatableSerializationBytes() const;
+    virtual uint32_t getCompactSerializationBytes() const;
 
     virtual bool isOutOfOrderFlag() const;
     virtual bool isEmpty() const;
@@ -74,19 +74,19 @@
     inline double getKxQ0() const;
     inline double getKxQ1() const;
 
-    virtual int getMemDataStart() const;
-    virtual int getPreInts() const;
+    virtual uint32_t getMemDataStart() const;
+    virtual uint8_t getPreInts() const;
 
-    void putCurMin(int curMin);
+    void putCurMin(uint8_t curMin);
     void putHipAccum(double hipAccum);
     inline void putKxQ0(double kxq0);
     inline void putKxQ1(double kxq1);
-    void putNumAtCurMin(int numAtCurMin);
+    void putNumAtCurMin(uint32_t numAtCurMin);
 
-    static int hllArrBytes(target_hll_type tgtHllType, int lgConfigK);
-    static int hll4ArrBytes(int lgConfigK);
-    static int hll6ArrBytes(int lgConfigK);
-    static int hll8ArrBytes(int lgConfigK);
+    static uint32_t hllArrBytes(target_hll_type tgtHllType, uint8_t lgConfigK);
+    static uint32_t hll4ArrBytes(uint8_t lgConfigK);
+    static uint32_t hll6ArrBytes(uint8_t lgConfigK);
+    static uint32_t hll8ArrBytes(uint8_t lgConfigK);
 
     virtual AuxHashMap<A>* getAuxHashMap() const;
 
@@ -98,16 +98,16 @@
 
   protected:
     void hipAndKxQIncrementalUpdate(uint8_t oldValue, uint8_t newValue);
-    double getHllBitMapEstimate(int lgConfigK, int curMin, int numAtCurMin) const;
-    double getHllRawEstimate(int lgConfigK, double kxqSum) const;
+    double getHllBitMapEstimate() const;
+    double getHllRawEstimate() const;
 
-    double hipAccum;
-    double kxq0;
-    double kxq1;
-    vector_u8<A> hllByteArr; //init by sub-classes
-    int curMin; //always zero for Hll6 and Hll8, only tracked by Hll4Array
-    int numAtCurMin; //interpreted as num zeros when curMin == 0
-    bool oooFlag; //Out-Of-Order Flag
+    double hipAccum_;
+    double kxq0_;
+    double kxq1_;
+    vector_u8<A> hllByteArr_; //init by sub-classes
+    uint8_t curMin_; //always zero for Hll6 and Hll8, only tracked by Hll4Array
+    uint32_t numAtCurMin_; //interpreted as num zeros when curMin == 0
+    bool oooFlag_; //Out-Of-Order Flag
 
     friend class HllSketchImplFactory<A>;
 };
@@ -115,20 +115,20 @@
 template<typename A>
 class HllArray<A>::const_iterator: public std::iterator<std::input_iterator_tag, uint32_t> {
 public:
-  const_iterator(const uint8_t* array, size_t array_slze, size_t index, target_hll_type hll_type, const AuxHashMap<A>* exceptions, uint8_t offset, bool all);
+  const_iterator(const uint8_t* array, uint32_t array_slze, uint32_t index, target_hll_type hll_type, const AuxHashMap<A>* exceptions, uint8_t offset, bool all);
   const_iterator& operator++();
   bool operator!=(const const_iterator& other) const;
   uint32_t operator*() const;
 private:
-  const uint8_t* array;
-  size_t array_size;
-  size_t index;
-  target_hll_type hll_type;
-  const AuxHashMap<A>* exceptions;
-  uint8_t offset;
-  bool all;
-  uint8_t value; // cached value to avoid computing in operator++ and in operator*()
-  static inline uint8_t get_value(const uint8_t* array, size_t index, target_hll_type hll_type, const AuxHashMap<A>* exceptions, uint8_t offset);
+  const uint8_t* array_;
+  uint32_t array_size_;
+  uint32_t index_;
+  target_hll_type hll_type_;
+  const AuxHashMap<A>* exceptions_;
+  uint8_t offset_;
+  bool all_;
+  uint8_t value_; // cached value to avoid computing in operator++ and in operator*()
+  static inline uint8_t get_value(const uint8_t* array, uint32_t index, target_hll_type hll_type, const AuxHashMap<A>* exceptions, uint8_t offset);
 };
 
 }
diff --git a/hll/include/HllSketch-internal.hpp b/hll/include/HllSketch-internal.hpp
index 8f7d1f4..80e6887 100644
--- a/hll/include/HllSketch-internal.hpp
+++ b/hll/include/HllSketch-internal.hpp
@@ -42,7 +42,7 @@
 } longDoubleUnion;
 
 template<typename A>
-hll_sketch_alloc<A>::hll_sketch_alloc(int lg_config_k, target_hll_type tgt_type, bool start_full_size, const A& allocator) {
+hll_sketch_alloc<A>::hll_sketch_alloc(uint8_t lg_config_k, target_hll_type tgt_type, bool start_full_size, const A& allocator) {
   HllUtil<A>::checkLgK(lg_config_k);
   if (start_full_size) {
     sketch_impl = HllSketchImplFactory<A>::newHll(lg_config_k, tgt_type, start_full_size, allocator);
@@ -122,7 +122,7 @@
 }
 
 template<typename A>
-void hll_sketch_alloc<A>::update(const uint64_t datum) {
+void hll_sketch_alloc<A>::update(uint64_t datum) {
   // no sign extension with 64 bits so no need to cast to signed value
   HashState hashResult;
   HllUtil<A>::hash(&datum, sizeof(uint64_t), DEFAULT_SEED, hashResult);
@@ -130,53 +130,53 @@
 }
 
 template<typename A>
-void hll_sketch_alloc<A>::update(const uint32_t datum) {
+void hll_sketch_alloc<A>::update(uint32_t datum) {
   update(static_cast<int32_t>(datum));
 }
 
 template<typename A>
-void hll_sketch_alloc<A>::update(const uint16_t datum) {
+void hll_sketch_alloc<A>::update(uint16_t datum) {
   update(static_cast<int16_t>(datum));
 }
 
 template<typename A>
-void hll_sketch_alloc<A>::update(const uint8_t datum) {
+void hll_sketch_alloc<A>::update(uint8_t datum) {
   update(static_cast<int8_t>(datum));
 }
 
 template<typename A>
-void hll_sketch_alloc<A>::update(const int64_t datum) {
+void hll_sketch_alloc<A>::update(int64_t datum) {
   HashState hashResult;
   HllUtil<A>::hash(&datum, sizeof(int64_t), DEFAULT_SEED, hashResult);
   coupon_update(HllUtil<A>::coupon(hashResult));
 }
 
 template<typename A>
-void hll_sketch_alloc<A>::update(const int32_t datum) {
-  int64_t val = static_cast<int64_t>(datum);
+void hll_sketch_alloc<A>::update(int32_t datum) {
+  const int64_t val = static_cast<int64_t>(datum);
   HashState hashResult;
   HllUtil<A>::hash(&val, sizeof(int64_t), DEFAULT_SEED, hashResult);
   coupon_update(HllUtil<A>::coupon(hashResult));
 }
 
 template<typename A>
-void hll_sketch_alloc<A>::update(const int16_t datum) {
-  int64_t val = static_cast<int64_t>(datum);
+void hll_sketch_alloc<A>::update(int16_t datum) {
+  const int64_t val = static_cast<int64_t>(datum);
   HashState hashResult;
   HllUtil<A>::hash(&val, sizeof(int64_t), DEFAULT_SEED, hashResult);
   coupon_update(HllUtil<A>::coupon(hashResult));
 }
 
 template<typename A>
-void hll_sketch_alloc<A>::update(const int8_t datum) {
-  int64_t val = static_cast<int64_t>(datum);
+void hll_sketch_alloc<A>::update(int8_t datum) {
+  const int64_t val = static_cast<int64_t>(datum);
   HashState hashResult;
   HllUtil<A>::hash(&val, sizeof(int64_t), DEFAULT_SEED, hashResult);
   coupon_update(HllUtil<A>::coupon(hashResult));
 }
 
 template<typename A>
-void hll_sketch_alloc<A>::update(const double datum) {
+void hll_sketch_alloc<A>::update(double datum) {
   longDoubleUnion d;
   d.doubleBytes = static_cast<double>(datum);
   if (datum == 0.0) {
@@ -190,7 +190,7 @@
 }
 
 template<typename A>
-void hll_sketch_alloc<A>::update(const float datum) {
+void hll_sketch_alloc<A>::update(float datum) {
   longDoubleUnion d;
   d.doubleBytes = static_cast<double>(datum);
   if (datum == 0.0) {
@@ -204,7 +204,7 @@
 }
 
 template<typename A>
-void hll_sketch_alloc<A>::update(const void* data, const size_t lengthBytes) {
+void hll_sketch_alloc<A>::update(const void* data, size_t lengthBytes) {
   if (data == nullptr) { return; }
   HashState hashResult;
   HllUtil<A>::hash(data, lengthBytes, DEFAULT_SEED, hashResult);
@@ -212,8 +212,8 @@
 }
 
 template<typename A>
-void hll_sketch_alloc<A>::coupon_update(int coupon) {
-  if (coupon == HllUtil<A>::EMPTY) { return; }
+void hll_sketch_alloc<A>::coupon_update(uint32_t coupon) {
+  if (coupon == hll_constants::EMPTY) { return; }
   HllSketchImpl<A>* result = this->sketch_impl->couponUpdate(coupon);
   if (result != this->sketch_impl) {
     this->sketch_impl->get_deleter()(this->sketch_impl);
@@ -352,12 +352,12 @@
 }
 
 template<typename A>
-double hll_sketch_alloc<A>::get_lower_bound(int numStdDev) const {
+double hll_sketch_alloc<A>::get_lower_bound(uint8_t numStdDev) const {
   return sketch_impl->getLowerBound(numStdDev);
 }
 
 template<typename A>
-double hll_sketch_alloc<A>::get_upper_bound(int numStdDev) const {
+double hll_sketch_alloc<A>::get_upper_bound(uint8_t numStdDev) const {
   return sketch_impl->getUpperBound(numStdDev);
 }
 
@@ -367,7 +367,7 @@
 }
 
 template<typename A>
-int hll_sketch_alloc<A>::get_lg_config_k() const {
+uint8_t hll_sketch_alloc<A>::get_lg_config_k() const {
   return sketch_impl->getLgConfigK();
 }
 
@@ -387,12 +387,12 @@
 }
 
 template<typename A>
-int hll_sketch_alloc<A>::get_updatable_serialization_bytes() const {
+uint32_t hll_sketch_alloc<A>::get_updatable_serialization_bytes() const {
   return sketch_impl->getUpdatableSerializationBytes();
 }
 
 template<typename A>
-int hll_sketch_alloc<A>::get_compact_serialization_bytes() const {
+uint32_t hll_sketch_alloc<A>::get_compact_serialization_bytes() const {
   return sketch_impl->getCompactSerializationBytes();
 }
 
@@ -435,23 +435,23 @@
 }
 
 template<typename A>
-int hll_sketch_alloc<A>::get_max_updatable_serialization_bytes(const int lg_config_k,
+uint32_t hll_sketch_alloc<A>::get_max_updatable_serialization_bytes(uint8_t lg_config_k,
     const target_hll_type tgtHllType) {
-  int arrBytes;
+  uint32_t arrBytes;
   if (tgtHllType == target_hll_type::HLL_4) {
-    const int auxBytes = 4 << HllUtil<A>::LG_AUX_ARR_INTS[lg_config_k];
+    const uint32_t auxBytes = 4 << hll_constants::LG_AUX_ARR_INTS[lg_config_k];
     arrBytes = HllArray<A>::hll4ArrBytes(lg_config_k) + auxBytes;
   } else if (tgtHllType == target_hll_type::HLL_6) {
     arrBytes = HllArray<A>::hll6ArrBytes(lg_config_k);
   } else { //HLL_8
     arrBytes = HllArray<A>::hll8ArrBytes(lg_config_k);
   }
-  return HllUtil<A>::HLL_BYTE_ARR_START + arrBytes;
+  return hll_constants::HLL_BYTE_ARR_START + arrBytes;
 }
 
 template<typename A>
-double hll_sketch_alloc<A>::get_rel_err(const bool upperBound, const bool unioned,
-                           const int lg_config_k, const int numStdDev) {
+double hll_sketch_alloc<A>::get_rel_err(bool upperBound, bool unioned,
+                           uint8_t lg_config_k, uint8_t numStdDev) {
   return HllUtil<A>::getRelErr(upperBound, unioned, lg_config_k, numStdDev);
 }
 
diff --git a/hll/include/HllSketchImpl-internal.hpp b/hll/include/HllSketchImpl-internal.hpp
index a280fd0..89ae4e6 100644
--- a/hll/include/HllSketchImpl-internal.hpp
+++ b/hll/include/HllSketchImpl-internal.hpp
@@ -26,12 +26,12 @@
 namespace datasketches {
 
 template<typename A>
-HllSketchImpl<A>::HllSketchImpl(const int lgConfigK, const target_hll_type tgtHllType,
-                                const hll_mode mode, const bool startFullSize)
-  : lgConfigK(lgConfigK),
-    tgtHllType(tgtHllType),
-    mode(mode),
-    startFullSize(startFullSize)
+HllSketchImpl<A>::HllSketchImpl(uint8_t lgConfigK, target_hll_type tgtHllType,
+                                hll_mode mode, bool startFullSize)
+  : lgConfigK_(lgConfigK),
+    tgtHllType_(tgtHllType),
+    mode_(mode),
+    startFullSize_(startFullSize)
 {
 }
 
@@ -40,7 +40,7 @@
 }
 
 template<typename A>
-target_hll_type HllSketchImpl<A>::extractTgtHllType(const uint8_t modeByte) {
+target_hll_type HllSketchImpl<A>::extractTgtHllType(uint8_t modeByte) {
   switch ((modeByte >> 2) & 0x3) {
   case 0:
     return target_hll_type::HLL_4;
@@ -54,7 +54,7 @@
 }
 
 template<typename A>
-hll_mode HllSketchImpl<A>::extractCurMode(const uint8_t modeByte) {
+hll_mode HllSketchImpl<A>::extractCurMode(uint8_t modeByte) {
   switch (modeByte & 0x3) {
   case 0:
     return hll_mode::LIST;
@@ -68,12 +68,12 @@
 }
 
 template<typename A>
-uint8_t HllSketchImpl<A>::makeFlagsByte(const bool compact) const {
-  uint8_t flags(0);
-  flags |= (isEmpty() ? HllUtil<A>::EMPTY_FLAG_MASK : 0);
-  flags |= (compact ? HllUtil<A>::COMPACT_FLAG_MASK : 0);
-  flags |= (isOutOfOrderFlag() ? HllUtil<A>::OUT_OF_ORDER_FLAG_MASK : 0);
-  flags |= (startFullSize ? HllUtil<A>::FULL_SIZE_FLAG_MASK : 0);
+uint8_t HllSketchImpl<A>::makeFlagsByte(bool compact) const {
+  uint8_t flags = 0;
+  flags |= (isEmpty() ? hll_constants::EMPTY_FLAG_MASK : 0);
+  flags |= (compact ? hll_constants::COMPACT_FLAG_MASK : 0);
+  flags |= (isOutOfOrderFlag() ? hll_constants::OUT_OF_ORDER_FLAG_MASK : 0);
+  flags |= (startFullSize_ ? hll_constants::FULL_SIZE_FLAG_MASK : 0);
   return flags;
 }
 
@@ -92,7 +92,7 @@
 uint8_t HllSketchImpl<A>::makeModeByte() const {
   uint8_t byte = 0;
 
-  switch (mode) {
+  switch (mode_) {
   case LIST:
     byte = 0;
     break;
@@ -104,7 +104,7 @@
     break;
   }
 
-  switch (tgtHllType) {
+  switch (tgtHllType_) {
   case HLL_4:
     byte |= (0 << 2);  // for completeness
     break;
@@ -121,27 +121,27 @@
 
 template<typename A>
 HllSketchImpl<A>* HllSketchImpl<A>::reset() {
-  return HllSketchImplFactory<A>::reset(this, startFullSize);
+  return HllSketchImplFactory<A>::reset(this, startFullSize_);
 }
 
 template<typename A>
 target_hll_type HllSketchImpl<A>::getTgtHllType() const {
-  return tgtHllType;
+  return tgtHllType_;
 }
 
 template<typename A>
-int HllSketchImpl<A>::getLgConfigK() const {
-  return lgConfigK;
+uint8_t HllSketchImpl<A>::getLgConfigK() const {
+  return lgConfigK_;
 }
 
 template<typename A>
 hll_mode HllSketchImpl<A>::getCurMode() const {
-  return mode;
+  return mode_;
 }
 
 template<typename A>
 bool HllSketchImpl<A>::isStartFullSize() const {
-  return startFullSize;
+  return startFullSize_;
 }
 
 }
diff --git a/hll/include/HllSketchImpl.hpp b/hll/include/HllSketchImpl.hpp
index 9f53705..e437c21 100644
--- a/hll/include/HllSketchImpl.hpp
+++ b/hll/include/HllSketchImpl.hpp
@@ -30,7 +30,7 @@
 template<typename A>
 class HllSketchImpl {
   public:
-    HllSketchImpl(int lgConfigK, target_hll_type tgtHllType, hll_mode mode, bool startFullSize);
+    HllSketchImpl(uint8_t lgConfigK, target_hll_type tgtHllType, hll_mode mode, bool startFullSize);
     virtual ~HllSketchImpl();
 
     virtual void serialize(std::ostream& os, bool compact) const = 0;
@@ -42,25 +42,25 @@
 
     virtual std::function<void(HllSketchImpl<A>*)> get_deleter() const = 0;
 
-    virtual HllSketchImpl* couponUpdate(int coupon) = 0;
+    virtual HllSketchImpl* couponUpdate(uint32_t coupon) = 0;
 
     hll_mode getCurMode() const;
 
     virtual double getEstimate() const = 0;
     virtual double getCompositeEstimate() const = 0;
-    virtual double getUpperBound(int numStdDev) const = 0;
-    virtual double getLowerBound(int numStdDev) const = 0;
+    virtual double getUpperBound(uint8_t numStdDev) const = 0;
+    virtual double getLowerBound(uint8_t numStdDev) const = 0;
 
-    inline int getLgConfigK() const;
+    inline uint8_t getLgConfigK() const;
 
-    virtual int getMemDataStart() const = 0;
+    virtual uint32_t getMemDataStart() const = 0;
 
-    virtual int getPreInts() const = 0;
+    virtual uint8_t getPreInts() const = 0;
 
     target_hll_type getTgtHllType() const;
 
-    virtual int getUpdatableSerializationBytes() const = 0;
-    virtual int getCompactSerializationBytes() const = 0;
+    virtual uint32_t getUpdatableSerializationBytes() const = 0;
+    virtual uint32_t getCompactSerializationBytes() const = 0;
 
     virtual bool isCompact() const = 0;
     virtual bool isEmpty() const = 0;
@@ -75,10 +75,10 @@
     uint8_t makeFlagsByte(bool compact) const;
     uint8_t makeModeByte() const;
 
-    const int lgConfigK;
-    const target_hll_type tgtHllType;
-    const hll_mode mode;
-    const bool startFullSize;
+    const uint8_t lgConfigK_;
+    const target_hll_type tgtHllType_;
+    const hll_mode mode_;
+    const bool startFullSize_;
 };
 
 }
diff --git a/hll/include/HllSketchImplFactory.hpp b/hll/include/HllSketchImplFactory.hpp
index 85f9618..446d712 100644
--- a/hll/include/HllSketchImplFactory.hpp
+++ b/hll/include/HllSketchImplFactory.hpp
@@ -39,7 +39,7 @@
 
   static CouponHashSet<A>* promoteListToSet(const CouponList<A>& list);
   static HllArray<A>* promoteListOrSetToHll(const CouponList<A>& list);
-  static HllArray<A>* newHll(int lgConfigK, target_hll_type tgtHllType, bool startFullSize, const A& allocator);
+  static HllArray<A>* newHll(uint8_t lgConfigK, target_hll_type tgtHllType, bool startFullSize, const A& allocator);
   
   // resets the input impl, deleting the input pointer and returning a new pointer
   static HllSketchImpl<A>* reset(HllSketchImpl<A>* impl, bool startFullSize);
@@ -53,7 +53,7 @@
 CouponHashSet<A>* HllSketchImplFactory<A>::promoteListToSet(const CouponList<A>& list) {
   using ChsAlloc = typename std::allocator_traits<A>::template rebind_alloc<CouponHashSet<A>>;
   CouponHashSet<A>* chSet = new (ChsAlloc(list.getAllocator()).allocate(1)) CouponHashSet<A>(list.getLgConfigK(), list.getTgtHllType(), list.getAllocator());
-  for (auto coupon: list) {
+  for (const auto coupon: list) {
     chSet->couponUpdate(coupon);
   }
   return chSet;
@@ -63,7 +63,7 @@
 HllArray<A>* HllSketchImplFactory<A>::promoteListOrSetToHll(const CouponList<A>& src) {
   HllArray<A>* tgtHllArr = HllSketchImplFactory<A>::newHll(src.getLgConfigK(), src.getTgtHllType(), false, src.getAllocator());
   tgtHllArr->putKxQ0(1 << src.getLgConfigK());
-  for (auto coupon: src) {
+  for (const auto coupon: src) {
     tgtHllArr->couponUpdate(coupon);
   }
   tgtHllArr->putHipAccum(src.getEstimate());
@@ -75,12 +75,12 @@
 HllSketchImpl<A>* HllSketchImplFactory<A>::deserialize(std::istream& is, const A& allocator) {
   // we'll hand off the sketch based on PreInts so we don't need
   // to move the stream pointer back and forth -- perhaps somewhat fragile?
-  const int preInts = is.peek();
-  if (preInts == HllUtil<A>::HLL_PREINTS) {
+  const uint8_t preInts = static_cast<uint8_t>(is.peek());
+  if (preInts == hll_constants::HLL_PREINTS) {
     return HllArray<A>::newHll(is, allocator);
-  } else if (preInts == HllUtil<A>::HASH_SET_PREINTS) {
+  } else if (preInts == hll_constants::HASH_SET_PREINTS) {
     return CouponHashSet<A>::newSet(is, allocator);
-  } else if (preInts == HllUtil<A>::LIST_PREINTS) {
+  } else if (preInts == hll_constants::LIST_PREINTS) {
     return CouponList<A>::newList(is, allocator);
   } else {
     throw std::invalid_argument("Attempt to deserialize unknown object type");
@@ -90,12 +90,12 @@
 template<typename A>
 HllSketchImpl<A>* HllSketchImplFactory<A>::deserialize(const void* bytes, size_t len, const A& allocator) {
   // read current mode directly
-  const int preInts = static_cast<const uint8_t*>(bytes)[0];
-  if (preInts == HllUtil<A>::HLL_PREINTS) {
+  const uint8_t preInts = static_cast<const uint8_t*>(bytes)[0];
+  if (preInts == hll_constants::HLL_PREINTS) {
     return HllArray<A>::newHll(bytes, len, allocator);
-  } else if (preInts == HllUtil<A>::HASH_SET_PREINTS) {
+  } else if (preInts == hll_constants::HASH_SET_PREINTS) {
     return CouponHashSet<A>::newSet(bytes, len, allocator);
-  } else if (preInts == HllUtil<A>::LIST_PREINTS) {
+  } else if (preInts == hll_constants::LIST_PREINTS) {
     return CouponList<A>::newList(bytes, len, allocator);
   } else {
     throw std::invalid_argument("Attempt to deserialize unknown object type");
@@ -103,7 +103,7 @@
 }
 
 template<typename A>
-HllArray<A>* HllSketchImplFactory<A>::newHll(int lgConfigK, target_hll_type tgtHllType, bool startFullSize, const A& allocator) {
+HllArray<A>* HllSketchImplFactory<A>::newHll(uint8_t lgConfigK, target_hll_type tgtHllType, bool startFullSize, const A& allocator) {
   switch (tgtHllType) {
     case HLL_8:
       using Hll8Alloc = typename std::allocator_traits<A>::template rebind_alloc<Hll8Array<A>>;
@@ -134,7 +134,7 @@
 
 template<typename A>
 Hll4Array<A>* HllSketchImplFactory<A>::convertToHll4(const HllArray<A>& srcHllArr) {
-  const int lgConfigK = srcHllArr.getLgConfigK();
+  const uint8_t lgConfigK = srcHllArr.getLgConfigK();
   using Hll4Alloc = typename std::allocator_traits<A>::template rebind_alloc<Hll4Array<A>>;
   Hll4Array<A>* hll4Array = new (Hll4Alloc(srcHllArr.getAllocator()).allocate(1))
       Hll4Array<A>(lgConfigK, srcHllArr.isStartFullSize(), srcHllArr.getAllocator());
@@ -146,7 +146,7 @@
 
 template<typename A>
 Hll6Array<A>* HllSketchImplFactory<A>::convertToHll6(const HllArray<A>& srcHllArr) {
-  const int lgConfigK = srcHllArr.getLgConfigK();
+  const uint8_t lgConfigK = srcHllArr.getLgConfigK();
   using Hll6Alloc = typename std::allocator_traits<A>::template rebind_alloc<Hll6Array<A>>;
   Hll6Array<A>* hll6Array = new (Hll6Alloc(srcHllArr.getAllocator()).allocate(1))
       Hll6Array<A>(lgConfigK, srcHllArr.isStartFullSize(), srcHllArr.getAllocator());
@@ -158,7 +158,7 @@
 
 template<typename A>
 Hll8Array<A>* HllSketchImplFactory<A>::convertToHll8(const HllArray<A>& srcHllArr) {
-  const int lgConfigK = srcHllArr.getLgConfigK();
+  const uint8_t lgConfigK = srcHllArr.getLgConfigK();
   using Hll8Alloc = typename std::allocator_traits<A>::template rebind_alloc<Hll8Array<A>>;
   Hll8Array<A>* hll8Array = new (Hll8Alloc(srcHllArr.getAllocator()).allocate(1))
       Hll8Array<A>(lgConfigK, srcHllArr.isStartFullSize(), srcHllArr.getAllocator());
diff --git a/hll/include/HllUnion-internal.hpp b/hll/include/HllUnion-internal.hpp
index 716fab6..743dfb2 100644
--- a/hll/include/HllUnion-internal.hpp
+++ b/hll/include/HllUnion-internal.hpp
@@ -32,151 +32,151 @@
 namespace datasketches {
 
 template<typename A>
-hll_union_alloc<A>::hll_union_alloc(const int lg_max_k, const A& allocator):
-  lg_max_k(HllUtil<A>::checkLgK(lg_max_k)),
-  gadget(lg_max_k, target_hll_type::HLL_8, false, allocator)
+hll_union_alloc<A>::hll_union_alloc(uint8_t lg_max_k, const A& allocator):
+  lg_max_k_(HllUtil<A>::checkLgK(lg_max_k)),
+  gadget_(lg_max_k, target_hll_type::HLL_8, false, allocator)
 {}
 
 template<typename A>
 hll_sketch_alloc<A> hll_union_alloc<A>::get_result(target_hll_type target_type) const {
-  return hll_sketch_alloc<A>(gadget, target_type);
+  return hll_sketch_alloc<A>(gadget_, target_type);
 }
 
 template<typename A>
 void hll_union_alloc<A>::update(const hll_sketch_alloc<A>& sketch) {
   if (sketch.is_empty()) return;
-  union_impl(sketch, lg_max_k);
+  union_impl(sketch, lg_max_k_);
 }
 
 template<typename A>
 void hll_union_alloc<A>::update(hll_sketch_alloc<A>&& sketch) {
   if (sketch.is_empty()) return;
-  if (gadget.is_empty() && sketch.get_target_type() == HLL_8 && sketch.get_lg_config_k() <= lg_max_k) {
-    if (sketch.get_current_mode() == HLL || sketch.get_lg_config_k() == lg_max_k) {
-      gadget = std::move(sketch);
+  if (gadget_.is_empty() && sketch.get_target_type() == HLL_8 && sketch.get_lg_config_k() <= lg_max_k_) {
+    if (sketch.get_current_mode() == HLL || sketch.get_lg_config_k() == lg_max_k_) {
+      gadget_ = std::move(sketch);
     }
   }
-  union_impl(sketch, lg_max_k);
+  union_impl(sketch, lg_max_k_);
 }
 
 template<typename A>
 void hll_union_alloc<A>::update(const std::string& datum) {
-  gadget.update(datum);
+  gadget_.update(datum);
 }
 
 template<typename A>
-void hll_union_alloc<A>::update(const uint64_t datum) {
-  gadget.update(datum);
+void hll_union_alloc<A>::update(uint64_t datum) {
+  gadget_.update(datum);
 }
 
 template<typename A>
-void hll_union_alloc<A>::update(const uint32_t datum) {
-  gadget.update(datum);
+void hll_union_alloc<A>::update(uint32_t datum) {
+  gadget_.update(datum);
 }
 
 template<typename A>
-void hll_union_alloc<A>::update(const uint16_t datum) {
-  gadget.update(datum);
+void hll_union_alloc<A>::update(uint16_t datum) {
+  gadget_.update(datum);
 }
 
 template<typename A>
-void hll_union_alloc<A>::update(const uint8_t datum) {
-  gadget.update(datum);
+void hll_union_alloc<A>::update(uint8_t datum) {
+  gadget_.update(datum);
 }
 
 template<typename A>
-void hll_union_alloc<A>::update(const int64_t datum) {
-  gadget.update(datum);
+void hll_union_alloc<A>::update(int64_t datum) {
+  gadget_.update(datum);
 }
 
 template<typename A>
-void hll_union_alloc<A>::update(const int32_t datum) {
-  gadget.update(datum);
+void hll_union_alloc<A>::update(int32_t datum) {
+  gadget_.update(datum);
 }
 
 template<typename A>
-void hll_union_alloc<A>::update(const int16_t datum) {
-  gadget.update(datum);
+void hll_union_alloc<A>::update(int16_t datum) {
+  gadget_.update(datum);
 }
 
 template<typename A>
-void hll_union_alloc<A>::update(const int8_t datum) {
-  gadget.update(datum);
+void hll_union_alloc<A>::update(int8_t datum) {
+  gadget_.update(datum);
 }
 
 template<typename A>
-void hll_union_alloc<A>::update(const double datum) {
-  gadget.update(datum);
+void hll_union_alloc<A>::update(double datum) {
+  gadget_.update(datum);
 }
 
 template<typename A>
-void hll_union_alloc<A>::update(const float datum) {
-  gadget.update(datum);
+void hll_union_alloc<A>::update(float datum) {
+  gadget_.update(datum);
 }
 
 template<typename A>
-void hll_union_alloc<A>::update(const void* data, const size_t length_bytes) {
-  gadget.update(data, length_bytes);
+void hll_union_alloc<A>::update(const void* data, size_t length_bytes) {
+  gadget_.update(data, length_bytes);
 }
 
 template<typename A>
-void hll_union_alloc<A>::coupon_update(const int coupon) {
+void hll_union_alloc<A>::coupon_update(uint32_t coupon) {
   if (coupon == HllUtil<A>::EMPTY) { return; }
-  HllSketchImpl<A>* result = gadget.sketch_impl->coupon_update(coupon);
-  if (result != gadget.sketch_impl) {
-    if (gadget.sketch_impl != nullptr) { gadget.sketch_impl->get_deleter()(gadget.sketch_impl); }
-    gadget.sketch_impl = result;
+  HllSketchImpl<A>* result = gadget_.sketch_impl->coupon_update(coupon);
+  if (result != gadget_.sketch_impl) {
+    if (gadget_.sketch_impl != nullptr) { gadget_.sketch_impl->get_deleter()(gadget_.sketch_impl); }
+    gadget_.sketch_impl = result;
   }
 }
 
 template<typename A>
 double hll_union_alloc<A>::get_estimate() const {
-  return gadget.get_estimate();
+  return gadget_.get_estimate();
 }
 
 template<typename A>
 double hll_union_alloc<A>::get_composite_estimate() const {
-  return gadget.get_composite_estimate();
+  return gadget_.get_composite_estimate();
 }
 
 template<typename A>
-double hll_union_alloc<A>::get_lower_bound(const int num_std_dev) const {
-  return gadget.get_lower_bound(num_std_dev);
+double hll_union_alloc<A>::get_lower_bound(uint8_t num_std_dev) const {
+  return gadget_.get_lower_bound(num_std_dev);
 }
 
 template<typename A>
-double hll_union_alloc<A>::get_upper_bound(const int num_std_dev) const {
-  return gadget.get_upper_bound(num_std_dev);
+double hll_union_alloc<A>::get_upper_bound(uint8_t num_std_dev) const {
+  return gadget_.get_upper_bound(num_std_dev);
 }
 
 template<typename A>
-int hll_union_alloc<A>::get_lg_config_k() const {
-  return gadget.get_lg_config_k();
+uint8_t hll_union_alloc<A>::get_lg_config_k() const {
+  return gadget_.get_lg_config_k();
 }
 
 template<typename A>
 void hll_union_alloc<A>::reset() {
-  gadget.reset();
+  gadget_.reset();
 }
 
 template<typename A>
 bool hll_union_alloc<A>::is_empty() const {
-  return gadget.is_empty();
+  return gadget_.is_empty();
 }
 
 template<typename A>
 bool hll_union_alloc<A>::is_out_of_order_flag() const {
-  return gadget.is_out_of_order_flag();
+  return gadget_.is_out_of_order_flag();
 }
 
 template<typename A>
 hll_mode hll_union_alloc<A>::get_current_mode() const {
-  return gadget.get_current_mode();
+  return gadget_.get_current_mode();
 }
 
 template<typename A>
 bool hll_union_alloc<A>::is_estimation_mode() const {
-  return gadget.is_estimation_mode();
+  return gadget_.is_estimation_mode();
 }
 
 template<typename A>
@@ -185,13 +185,13 @@
 }
 
 template<typename A>
-double hll_union_alloc<A>::get_rel_err(const bool upper_bound, const bool unioned,
-                           const int lg_config_k, const int num_std_dev) {
+double hll_union_alloc<A>::get_rel_err(bool upper_bound, bool unioned,
+                           uint8_t lg_config_k, uint8_t num_std_dev) {
   return HllUtil<A>::getRelErr(upper_bound, unioned, lg_config_k, num_std_dev);
 }
 
 template<typename A>
-HllSketchImpl<A>* hll_union_alloc<A>::copy_or_downsample(const HllSketchImpl<A>* src_impl, const int tgt_lg_k) {
+HllSketchImpl<A>* hll_union_alloc<A>::copy_or_downsample(const HllSketchImpl<A>* src_impl, uint8_t tgt_lg_k) {
   if (src_impl->getCurMode() != HLL) {
     throw std::logic_error("Attempt to downsample non-HLL sketch");
   }
@@ -210,7 +210,7 @@
 }
 
 template<typename A>
-inline HllSketchImpl<A>* hll_union_alloc<A>::leak_free_coupon_update(HllSketchImpl<A>* impl, const int coupon) {
+inline HllSketchImpl<A>* hll_union_alloc<A>::leak_free_coupon_update(HllSketchImpl<A>* impl, uint32_t coupon) {
   HllSketchImpl<A>* result = impl->couponUpdate(coupon);
   if (result != impl) {
     impl->get_deleter()(impl);
@@ -219,13 +219,13 @@
 }
 
 template<typename A>
-void hll_union_alloc<A>::union_impl(const hll_sketch_alloc<A>& sketch, const int lg_max_k) {
+void hll_union_alloc<A>::union_impl(const hll_sketch_alloc<A>& sketch, uint8_t lg_max_k) {
   const HllSketchImpl<A>* src_impl = sketch.sketch_impl; //default
-  HllSketchImpl<A>* dst_impl = gadget.sketch_impl; //default
+  HllSketchImpl<A>* dst_impl = gadget_.sketch_impl; //default
   if (src_impl->getCurMode() == LIST || src_impl->getCurMode() == SET) {
     if (dst_impl->isEmpty() && src_impl->getLgConfigK() == dst_impl->getLgConfigK()) {
       dst_impl = src_impl->copyAs(HLL_8);
-      gadget.sketch_impl->get_deleter()(gadget.sketch_impl); // gadget to be replaced
+      gadget_.sketch_impl->get_deleter()(gadget_.sketch_impl); // gadget to be replaced
     } else {
       const CouponList<A>* src = static_cast<const CouponList<A>*>(src_impl);
       for (auto coupon: *src) {
@@ -239,11 +239,11 @@
       const CouponList<A>* src = static_cast<const CouponList<A>*>(dst_impl);
       dst_impl = copy_or_downsample(src_impl, lg_max_k);
       static_cast<Hll8Array<A>*>(dst_impl)->mergeList(*src);
-      gadget.sketch_impl->get_deleter()(gadget.sketch_impl); // gadget to be replaced
+      gadget_.sketch_impl->get_deleter()(gadget_.sketch_impl); // gadget to be replaced
     } else { // gadget is HLL
       if (src_impl->getLgConfigK() < dst_impl->getLgConfigK()) {
         dst_impl = copy_or_downsample(dst_impl, sketch.get_lg_config_k());
-        gadget.sketch_impl->get_deleter()(gadget.sketch_impl); // gadget to be replaced
+        gadget_.sketch_impl->get_deleter()(gadget_.sketch_impl); // gadget to be replaced
       }
       const HllArray<A>* src = static_cast<const HllArray<A>*>(src_impl);
       static_cast<Hll8Array<A>*>(dst_impl)->mergeHll(*src);
@@ -252,9 +252,9 @@
     }
   } else { // src is HLL, gadget is empty
     dst_impl = copy_or_downsample(src_impl, lg_max_k);
-    gadget.sketch_impl->get_deleter()(gadget.sketch_impl); // gadget to be replaced
+    gadget_.sketch_impl->get_deleter()(gadget_.sketch_impl); // gadget to be replaced
   }
-  gadget.sketch_impl = dst_impl; // gadget replaced
+  gadget_.sketch_impl = dst_impl; // gadget replaced
 }
 
 }
diff --git a/hll/include/HllUtil.hpp b/hll/include/HllUtil.hpp
index 3a1ebe2..a78dd83 100644
--- a/hll/include/HllUtil.hpp
+++ b/hll/include/HllUtil.hpp
@@ -34,140 +34,133 @@
 
 enum hll_mode { LIST = 0, SET, HLL };
 
+namespace hll_constants {
+
+// preamble stuff
+static const uint8_t SER_VER = 1;
+static const uint8_t FAMILY_ID = 7;
+
+static const uint8_t EMPTY_FLAG_MASK          = 4;
+static const uint8_t COMPACT_FLAG_MASK        = 8;
+static const uint8_t OUT_OF_ORDER_FLAG_MASK   = 16;
+static const uint8_t FULL_SIZE_FLAG_MASK      = 32;
+
+static const uint32_t PREAMBLE_INTS_BYTE = 0;
+static const uint32_t SER_VER_BYTE       = 1;
+static const uint32_t FAMILY_BYTE        = 2;
+static const uint32_t LG_K_BYTE          = 3;
+static const uint32_t LG_ARR_BYTE        = 4;
+static const uint32_t FLAGS_BYTE         = 5;
+static const uint32_t LIST_COUNT_BYTE    = 6;
+static const uint32_t HLL_CUR_MIN_BYTE   = 6;
+static const uint32_t MODE_BYTE          = 7; // lo2bits = curMode, next 2 bits = tgtHllMode
+
+// Coupon List
+static const uint32_t LIST_INT_ARR_START = 8;
+static const uint8_t LIST_PREINTS = 2;
+// Coupon Hash Set
+static const uint32_t HASH_SET_COUNT_INT             = 8;
+static const uint32_t HASH_SET_INT_ARR_START         = 12;
+static const uint8_t HASH_SET_PREINTS         = 3;
+// HLL
+static const uint8_t HLL_PREINTS = 10;
+static const uint32_t HLL_BYTE_ARR_START = 40;
+static const uint32_t HIP_ACCUM_DOUBLE = 8;
+static const uint32_t KXQ0_DOUBLE = 16;
+static const uint32_t KXQ1_DOUBLE = 24;
+static const uint32_t CUR_MIN_COUNT_INT = 32;
+static const uint32_t AUX_COUNT_INT = 36;
+
+static const uint32_t EMPTY_SKETCH_SIZE_BYTES = 8;
+
+// other HllUtil stuff
+static const uint8_t KEY_BITS_26 = 26;
+static const uint8_t VAL_BITS_6 = 6;
+static const uint32_t KEY_MASK_26 = (1 << KEY_BITS_26) - 1;
+static const uint32_t VAL_MASK_6 = (1 << VAL_BITS_6) - 1;
+static const uint32_t EMPTY = 0;
+static const uint8_t MIN_LOG_K = 4;
+static const uint8_t MAX_LOG_K = 21;
+
+static const double HLL_HIP_RSE_FACTOR = 0.8325546; // sqrt(ln(2))
+static const double HLL_NON_HIP_RSE_FACTOR = 1.03896; // sqrt((3 * ln(2)) - 1)
+static const double COUPON_RSE_FACTOR = 0.409; // at transition point not the asymptote
+static const double COUPON_RSE = COUPON_RSE_FACTOR / (1 << 13);
+
+static const uint8_t LG_INIT_LIST_SIZE = 3;
+static const uint8_t LG_INIT_SET_SIZE = 5;
+static const uint32_t RESIZE_NUMER = 3;
+static const uint32_t RESIZE_DENOM = 4;
+
+static const uint8_t loNibbleMask = 0x0f;
+static const uint8_t hiNibbleMask = 0xf0;
+static const uint8_t AUX_TOKEN = 0xf;
+
+/**
+* Log2 table sizes for exceptions based on lgK from 0 to 26.
+* However, only lgK from 4 to 21 are used.
+*/
+static const uint8_t LG_AUX_ARR_INTS[] = {
+  0, 2, 2, 2, 2, 2, 2, 3, 3, 3,   // 0 - 9
+  4, 4, 5, 5, 6, 7, 8, 9, 10, 11, // 10-19
+  12, 13, 14, 15, 16, 17, 18      // 20-26
+};
+
+} // namespace hll_constants
+
+
 // template provides internal consistency and allows static float values
 // but we don't use the template parameter anywhere
 template<typename A = std::allocator<uint8_t> >
 class HllUtil final {
 public:
-  // preamble stuff
-  static const int SER_VER = 1;
-  static const int FAMILY_ID = 7;
 
-  static const int EMPTY_FLAG_MASK          = 4;
-  static const int COMPACT_FLAG_MASK        = 8;
-  static const int OUT_OF_ORDER_FLAG_MASK   = 16;
-  static const int FULL_SIZE_FLAG_MASK      = 32;
-
-  static const int PREAMBLE_INTS_BYTE = 0;
-  static const int SER_VER_BYTE       = 1;
-  static const int FAMILY_BYTE        = 2;
-  static const int LG_K_BYTE          = 3;
-  static const int LG_ARR_BYTE        = 4;
-  static const int FLAGS_BYTE         = 5;
-  static const int LIST_COUNT_BYTE    = 6;
-  static const int HLL_CUR_MIN_BYTE   = 6;
-  static const int MODE_BYTE          = 7; // lo2bits = curMode, next 2 bits = tgtHllMode
-
-  // Coupon List
-  static const int LIST_INT_ARR_START = 8;
-  static const int LIST_PREINTS = 2;
-  // Coupon Hash Set
-  static const int HASH_SET_COUNT_INT             = 8;
-  static const int HASH_SET_INT_ARR_START         = 12;
-  static const int HASH_SET_PREINTS         = 3;
-  // HLL
-  static const int HLL_PREINTS = 10;
-  static const int HLL_BYTE_ARR_START = 40;
-  static const int HIP_ACCUM_DOUBLE = 8;
-  static const int KXQ0_DOUBLE = 16;
-  static const int KXQ1_DOUBLE = 24;
-  static const int CUR_MIN_COUNT_INT = 32;
-  static const int AUX_COUNT_INT = 36;
-  
-  static const int EMPTY_SKETCH_SIZE_BYTES = 8;
-
-  // other HllUtil stuff
-  static const int KEY_BITS_26 = 26;
-  static const int VAL_BITS_6 = 6;
-  static const int KEY_MASK_26 = (1 << KEY_BITS_26) - 1;
-  static const int VAL_MASK_6 = (1 << VAL_BITS_6) - 1;
-  static const int EMPTY = 0;
-  static const int MIN_LOG_K = 4;
-  static const int MAX_LOG_K = 21;
-
-  static const double HLL_HIP_RSE_FACTOR; // sqrt(log(2.0)) = 0.8325546
-  static const double HLL_NON_HIP_RSE_FACTOR; // sqrt((3.0 * log(2.0)) - 1.0) = 1.03896
-  static const double COUPON_RSE_FACTOR; // 0.409 at transition point not the asymptote
-  static const double COUPON_RSE; // COUPON_RSE_FACTOR / (1 << 13);
-
-  static const int LG_INIT_LIST_SIZE = 3;
-  static const int LG_INIT_SET_SIZE = 5;
-  static const int RESIZE_NUMER = 3;
-  static const int RESIZE_DENOM = 4;
-
-  static const int loNibbleMask = 0x0f;
-  static const int hiNibbleMask = 0xf0;
-  static const int AUX_TOKEN = 0xf;
-
-  /**
-  * Log2 table sizes for exceptions based on lgK from 0 to 26.
-  * However, only lgK from 4 to 21 are used.
-  */
-  static const int LG_AUX_ARR_INTS[];
-
-  static int coupon(const uint64_t hash[]);
-  static int coupon(const HashState& hashState);
-  static void hash(const void* key, int keyLen, uint64_t seed, HashState& result);
-  static int checkLgK(int lgK);
+  static uint32_t coupon(const uint64_t hash[]);
+  static uint32_t coupon(const HashState& hashState);
+  static void hash(const void* key, size_t keyLen, uint64_t seed, HashState& result);
+  static uint8_t checkLgK(uint8_t lgK);
   static void checkMemSize(uint64_t minBytes, uint64_t capBytes);
-  static inline void checkNumStdDev(int numStdDev);
-  static int pair(int slotNo, int value);
-  static int getLow26(unsigned int coupon);
-  static int getValue(unsigned int coupon);
-  static double invPow2(int e);
-  static unsigned int ceilingPowerOf2(unsigned int n);
-  static unsigned int simpleIntLog2(unsigned int n); // n must be power of 2
-  static int computeLgArrInts(hll_mode mode, int count, int lgConfigK);
-  static double getRelErr(bool upperBound, bool unioned,
-                          int lgConfigK, int numStdDev);
+  static inline void checkNumStdDev(uint8_t numStdDev);
+  static uint32_t pair(uint32_t slotNo, uint8_t value);
+  static uint32_t getLow26(uint32_t coupon);
+  static uint8_t getValue(uint32_t coupon);
+  static double invPow2(uint8_t e);
+  static uint8_t ceilingPowerOf2(uint32_t n);
+  static uint8_t simpleIntLog2(uint32_t n); // n must be power of 2
+  static uint8_t computeLgArrInts(hll_mode mode, uint32_t count, uint8_t lgConfigK);
+  static double getRelErr(bool upperBound, bool unioned, uint8_t lgConfigK, uint8_t numStdDev);
 };
 
 template<typename A>
-const double HllUtil<A>::HLL_HIP_RSE_FACTOR = sqrt(log(2.0)); // 0.8325546
-template<typename A>
-const double HllUtil<A>::HLL_NON_HIP_RSE_FACTOR = sqrt((3.0 * log(2.0)) - 1.0); // 1.03896
-template<typename A>
-const double HllUtil<A>::COUPON_RSE_FACTOR = 0.409;
-template<typename A>
-const double HllUtil<A>::COUPON_RSE = COUPON_RSE_FACTOR / (1 << 13);
-
-template<typename A>
-const int HllUtil<A>::LG_AUX_ARR_INTS[] = {
-      0, 2, 2, 2, 2, 2, 2, 3, 3, 3,   // 0 - 9
-      4, 4, 5, 5, 6, 7, 8, 9, 10, 11, // 10-19
-      12, 13, 14, 15, 16, 17, 18      // 20-26
-      };
-
-template<typename A>
-inline int HllUtil<A>::coupon(const uint64_t hash[]) {
-  int addr26 = (int) (hash[0] & KEY_MASK_26);
-  int lz = count_leading_zeros_in_u64(hash[1]);
-  int value = ((lz > 62 ? 62 : lz) + 1); 
-  return (value << KEY_BITS_26) | addr26;
+inline uint32_t HllUtil<A>::coupon(const uint64_t hash[]) {
+  uint32_t addr26 = hash[0] & hll_constants::KEY_MASK_26;
+  uint8_t lz = count_leading_zeros_in_u64(hash[1]);
+  uint8_t value = ((lz > 62 ? 62 : lz) + 1); 
+  return (value << hll_constants::KEY_BITS_26) | addr26;
 }
 
 template<typename A>
-inline int HllUtil<A>::coupon(const HashState& hashState) {
-  int addr26 = (int) (hashState.h1 & KEY_MASK_26);
-  int lz = count_leading_zeros_in_u64(hashState.h2);  
-  int value = ((lz > 62 ? 62 : lz) + 1); 
-  return (value << KEY_BITS_26) | addr26;
+inline uint32_t HllUtil<A>::coupon(const HashState& hashState) {
+  uint32_t addr26 = (int) (hashState.h1 & hll_constants::KEY_MASK_26);
+  uint8_t lz = count_leading_zeros_in_u64(hashState.h2);  
+  uint8_t value = ((lz > 62 ? 62 : lz) + 1); 
+  return (value << hll_constants::KEY_BITS_26) | addr26;
 }
 
 template<typename A>
-inline void HllUtil<A>::hash(const void* key, const int keyLen, const uint64_t seed, HashState& result) {
+inline void HllUtil<A>::hash(const void* key, size_t keyLen, uint64_t seed, HashState& result) {
   MurmurHash3_x64_128(key, keyLen, seed, result);
 }
 
 template<typename A>
-inline double HllUtil<A>::getRelErr(const bool upperBound, const bool unioned,
-                                    const int lgConfigK, const int numStdDev) {
+inline double HllUtil<A>::getRelErr(bool upperBound, bool unioned,
+                                    uint8_t lgConfigK, uint8_t numStdDev) {
   return RelativeErrorTables<A>::getRelErr(upperBound, unioned, lgConfigK, numStdDev);
 }
 
 template<typename A>
-inline int HllUtil<A>::checkLgK(const int lgK) {
-  if ((lgK >= HllUtil<A>::MIN_LOG_K) && (lgK <= HllUtil<A>::MAX_LOG_K)) {
+inline uint8_t HllUtil<A>::checkLgK(uint8_t lgK) {
+  if ((lgK >= hll_constants::MIN_LOG_K) && (lgK <= hll_constants::MAX_LOG_K)) {
     return lgK;
   } else {
     throw std::invalid_argument("Invalid value of k: " + std::to_string(lgK));
@@ -175,36 +168,36 @@
 }
 
 template<typename A>
-inline void HllUtil<A>::checkMemSize(const uint64_t minBytes, const uint64_t capBytes) {
+inline void HllUtil<A>::checkMemSize(uint64_t minBytes, uint64_t capBytes) {
   if (capBytes < minBytes) {
     throw std::invalid_argument("Given destination array is not large enough: " + std::to_string(capBytes));
   }
 }
 
 template<typename A>
-inline void HllUtil<A>::checkNumStdDev(const int numStdDev) {
+inline void HllUtil<A>::checkNumStdDev(uint8_t numStdDev) {
   if ((numStdDev < 1) || (numStdDev > 3)) {
     throw std::invalid_argument("NumStdDev may not be less than 1 or greater than 3.");
   }
 }
 
 template<typename A>
-inline int HllUtil<A>::pair(const int slotNo, const int value) {
-  return (value << HllUtil<A>::KEY_BITS_26) | (slotNo & HllUtil<A>::KEY_MASK_26);
+inline uint32_t HllUtil<A>::pair(uint32_t slotNo, uint8_t value) {
+  return (value << hll_constants::KEY_BITS_26) | (slotNo & hll_constants::KEY_MASK_26);
 }
 
 template<typename A>
-inline int HllUtil<A>::getLow26(const unsigned int coupon) {
-  return coupon & HllUtil<A>::KEY_MASK_26;
+inline uint32_t HllUtil<A>::getLow26(uint32_t coupon) {
+  return coupon & hll_constants::KEY_MASK_26;
 }
 
 template<typename A>
-inline int HllUtil<A>::getValue(const unsigned int coupon) {
-  return coupon >> HllUtil<A>::KEY_BITS_26;
+inline uint8_t HllUtil<A>::getValue(uint32_t coupon) {
+  return coupon >> hll_constants::KEY_BITS_26;
 }
 
 template<typename A>
-inline double HllUtil<A>::invPow2(const int e) {
+inline double HllUtil<A>::invPow2(uint8_t e) {
   union {
     long long longVal;
     double doubleVal;
@@ -214,7 +207,7 @@
 }
 
 template<typename A>
-inline uint32_t HllUtil<A>::simpleIntLog2(uint32_t n) {
+inline uint8_t HllUtil<A>::simpleIntLog2(uint32_t n) {
   if (n == 0) {
     throw std::logic_error("cannot take log of 0");
   }
@@ -222,16 +215,16 @@
 }
 
 template<typename A>
-inline int HllUtil<A>::computeLgArrInts(hll_mode mode, int count, int lgConfigK) {
+inline uint8_t HllUtil<A>::computeLgArrInts(hll_mode mode, uint32_t count, uint8_t lgConfigK) {
   // assume value missing and recompute
-  if (mode == LIST) { return HllUtil<A>::LG_INIT_LIST_SIZE; }
-  int ceilPwr2 = ceiling_power_of_2(count);
-  if ((HllUtil<A>::RESIZE_DENOM * count) > (HllUtil<A>::RESIZE_NUMER * ceilPwr2)) { ceilPwr2 <<= 1;}
+  if (mode == LIST) { return hll_constants::LG_INIT_LIST_SIZE; }
+  uint32_t ceilPwr2 = ceiling_power_of_2(count);
+  if ((hll_constants::RESIZE_DENOM * count) > (hll_constants::RESIZE_NUMER * ceilPwr2)) { ceilPwr2 <<= 1;}
   if (mode == SET) {
-    return fmax(HllUtil<A>::LG_INIT_SET_SIZE, HllUtil<A>::simpleIntLog2(ceilPwr2));
+    return std::max(hll_constants::LG_INIT_SET_SIZE, HllUtil<A>::simpleIntLog2(ceilPwr2));
   }
   //only used for HLL4
-  return fmax(HllUtil<A>::LG_AUX_ARR_INTS[lgConfigK], HllUtil<A>::simpleIntLog2(ceilPwr2));
+  return std::max(hll_constants::LG_AUX_ARR_INTS[lgConfigK], HllUtil<A>::simpleIntLog2(ceilPwr2));
 }
 
 }
diff --git a/hll/include/coupon_iterator-internal.hpp b/hll/include/coupon_iterator-internal.hpp
index 35d0e0b..67e912b 100644
--- a/hll/include/coupon_iterator-internal.hpp
+++ b/hll/include/coupon_iterator-internal.hpp
@@ -25,30 +25,30 @@
 namespace datasketches {
 
 template<typename A>
-coupon_iterator<A>::coupon_iterator(const int* array, size_t array_size, size_t index, bool all):
-array(array), array_size(array_size), index(index), all(all) {
-  while (this->index < array_size) {
-    if (all || array[this->index] != HllUtil<A>::EMPTY) break;
-    this->index++;
+coupon_iterator<A>::coupon_iterator(const uint32_t* array, size_t array_size, size_t index, bool all):
+array_(array), array_size_(array_size), index_(index), all_(all) {
+  while (index_ < array_size_) {
+    if (all_ || array_[index_] != hll_constants::EMPTY) break;
+    ++index_;
   }
 }
 
 template<typename A>
 coupon_iterator<A>& coupon_iterator<A>::operator++() {
-  while (++index < array_size) {
-    if (all || array[index] != HllUtil<A>::EMPTY) break;
+  while (++index_ < array_size_) {
+    if (all_ || array_[index_] != hll_constants::EMPTY) break;
   }
   return *this;
 }
 
 template<typename A>
 bool coupon_iterator<A>::operator!=(const coupon_iterator& other) const {
-  return index != other.index;
+  return index_ != other.index_;
 }
 
 template<typename A>
 uint32_t coupon_iterator<A>::operator*() const {
-  return array[index];
+  return array_[index_];
 }
 
 }
diff --git a/hll/include/coupon_iterator.hpp b/hll/include/coupon_iterator.hpp
index 9f373cf..896a2f7 100644
--- a/hll/include/coupon_iterator.hpp
+++ b/hll/include/coupon_iterator.hpp
@@ -25,15 +25,15 @@
 template<typename A>
 class coupon_iterator: public std::iterator<std::input_iterator_tag, uint32_t> {
 public:
-  coupon_iterator(const int* array, size_t array_slze, size_t index, bool all);
+  coupon_iterator(const uint32_t* array, size_t array_slze, size_t index, bool all);
   coupon_iterator& operator++();
   bool operator!=(const coupon_iterator& other) const;
   uint32_t operator*() const;
 private:
-  const int* array;
-  size_t array_size;
-  size_t index;
-  bool all;
+  const uint32_t* array_;
+  size_t array_size_;
+  size_t index_;
+  bool all_;
 };
 
 }
diff --git a/hll/include/hll.hpp b/hll/include/hll.hpp
index a65b945..34193e5 100644
--- a/hll/include/hll.hpp
+++ b/hll/include/hll.hpp
@@ -119,7 +119,7 @@
      *        keeping memory use constant (if HLL_6 or HLL_8) at the cost of
      *        starting out using much more memory
      */
-    explicit hll_sketch_alloc(int lg_config_k, target_hll_type tgt_type = HLL_4, bool start_full_size = false, const A& allocator = A());
+    explicit hll_sketch_alloc(uint8_t lg_config_k, target_hll_type tgt_type = HLL_4, bool start_full_size = false, const A& allocator = A());
 
     /**
      * Copy constructor
@@ -306,7 +306,7 @@
      * @param num_std_dev Number of standard deviations, an integer from the set  {1, 2, 3}.
      * @return The approximate lower bound.
      */
-    double get_lower_bound(int num_std_dev) const;
+    double get_lower_bound(uint8_t num_std_dev) const;
 
     /**
      * Returns the approximate upper error bound given the specified
@@ -314,13 +314,13 @@
      * @param num_std_dev Number of standard deviations, an integer from the set  {1, 2, 3}.
      * @return The approximate upper bound.
      */
-    double get_upper_bound(int num_std_dev) const;
+    double get_upper_bound(uint8_t num_std_dev) const;
 
     /**
      * Returns sketch's configured lg_k value.
      * @return Configured lg_k value.
      */
-    int get_lg_config_k() const;
+    uint8_t get_lg_config_k() const;
 
     /**
      * Returns the sketch's target HLL mode (from #target_hll_type).
@@ -344,13 +344,13 @@
      * Returns the size of the sketch serialized in compact form.
      * @return Size of the sketch serialized in compact form, in bytes.
      */
-    int get_compact_serialization_bytes() const;
+    uint32_t get_compact_serialization_bytes() const;
 
     /**
      * Returns the size of the sketch serialized without compaction.
      * @return Size of the sketch serialized without compaction, in bytes.
      */
-    int get_updatable_serialization_bytes() const;
+    uint32_t get_updatable_serialization_bytes() const;
 
     /**
      * Returns the maximum size in bytes that this sketch can grow to
@@ -363,7 +363,7 @@
      * @param tgt_type the desired Hll type
      * @return the maximum size in bytes that this sketch can grow to.
      */
-    static int get_max_updatable_serialization_bytes(int lg_k, target_hll_type tgt_type);
+    static uint32_t get_max_updatable_serialization_bytes(uint8_t lg_k, target_hll_type tgt_type);
   
     /**
      * Gets the current (approximate) Relative Error (RE) asymptotic values given several
@@ -376,18 +376,18 @@
      * @return the current (approximate) RelativeError
      */
     static double get_rel_err(bool upper_bound, bool unioned,
-                              int lg_config_k, int num_std_dev);
+                              uint8_t lg_config_k, uint8_t num_std_dev);
 
   private:
     explicit hll_sketch_alloc(HllSketchImpl<A>* that);
 
-    void coupon_update(int coupon);
+    void coupon_update(uint32_t coupon);
 
     std::string type_as_string() const;
     std::string mode_as_string() const;
 
     hll_mode get_current_mode() const;
-    int get_serialization_version() const;
+    uint8_t get_serialization_version() const;
     bool is_out_of_order_flag() const;
     bool is_estimation_mode() const;
 
@@ -431,7 +431,7 @@
      * @param lg_max_k The maximum size, in log2, of k. The value must
      * be between 7 and 21, inclusive.
      */
-    explicit hll_union_alloc(int lg_max_k, const A& allocator = A());
+    explicit hll_union_alloc(uint8_t lg_max_k, const A& allocator = A());
 
     /**
      * Returns the current cardinality estimate
@@ -458,7 +458,7 @@
      * @param num_std_dev Number of standard deviations, an integer from the set  {1, 2, 3}.
      * @return The approximate lower bound.
      */
-    double get_lower_bound(int num_std_dev) const;
+    double get_lower_bound(uint8_t num_std_dev) const;
 
     /**
      * Returns the approximate upper error bound given the specified
@@ -466,13 +466,13 @@
      * @param num_std_dev Number of standard deviations, an integer from the set  {1, 2, 3}.
      * @return The approximate upper bound.
      */
-    double get_upper_bound(int num_std_dev) const;
+    double get_upper_bound(uint8_t num_std_dev) const;
 
     /**
      * Returns union's configured lg_k value.
      * @return Configured lg_k value.
      */
-    int get_lg_config_k() const;
+    uint8_t get_lg_config_k() const;
 
     /**
      * Returns the union's target HLL mode (from #target_hll_type).
@@ -598,7 +598,7 @@
      * @return the current (approximate) RelativeError
      */
     static double get_rel_err(bool upper_bound, bool unioned,
-                              int lg_config_k, int num_std_dev);
+                              uint8_t lg_config_k, uint8_t num_std_dev);
 
   private:
 
@@ -611,21 +611,21 @@
     * @param incoming_impl the given incoming sketch, which may not be modified.
     * @param lg_max_k the maximum value of log2 K for this union.
     */
-    inline void union_impl(const hll_sketch_alloc<A>& sketch, int lg_max_k);
+    inline void union_impl(const hll_sketch_alloc<A>& sketch, uint8_t lg_max_k);
 
-    static HllSketchImpl<A>* copy_or_downsample(const HllSketchImpl<A>* src_impl, int tgt_lg_k);
+    static HllSketchImpl<A>* copy_or_downsample(const HllSketchImpl<A>* src_impl, uint8_t tgt_lg_k);
 
-    void coupon_update(int coupon);
+    void coupon_update(uint32_t coupon);
 
     hll_mode get_current_mode() const;
     bool is_out_of_order_flag() const;
     bool is_estimation_mode() const;
 
     // calls couponUpdate on sketch, freeing the old sketch upon changes in hll_mode
-    static HllSketchImpl<A>* leak_free_coupon_update(HllSketchImpl<A>* impl, int coupon);
+    static HllSketchImpl<A>* leak_free_coupon_update(HllSketchImpl<A>* impl, uint32_t coupon);
 
-    int lg_max_k;
-    hll_sketch_alloc<A> gadget;
+    uint8_t lg_max_k_;
+    hll_sketch_alloc<A> gadget_;
 };
 
 /// convenience alias for hll_sketch with default allocator
diff --git a/hll/test/AuxHashMapTest.cpp b/hll/test/AuxHashMapTest.cpp
index ed1b380..a653059 100644
--- a/hll/test/AuxHashMapTest.cpp
+++ b/hll/test/AuxHashMapTest.cpp
@@ -45,7 +45,7 @@
       AuxHashMap<std::allocator<uint8_t>>::make_deleter()
       );
   REQUIRE(map->getLgAuxArrInts() == 3);
-  for (int i = 1; i <= 7; ++i) {
+  for (uint8_t i = 1; i <= 7; ++i) {
     map->mustAdd(i, i);
   }
   REQUIRE(map->getLgAuxArrInts() == 4);
diff --git a/hll/test/CouponHashSetTest.cpp b/hll/test/CouponHashSetTest.cpp
index ebadd8f..aa832b5 100644
--- a/hll/test/CouponHashSetTest.cpp
+++ b/hll/test/CouponHashSetTest.cpp
@@ -30,7 +30,7 @@
 namespace datasketches {
 
 TEST_CASE("coupon hash set: check corrupt bytearray", "[coupon_hash_set]") {
-  int lgK = 8;
+  uint8_t lgK = 8;
   hll_sketch sk1(lgK);
   for (int i = 0; i < 24; ++i) {
     sk1.update(i);
@@ -39,42 +39,42 @@
   uint8_t* bytes = sketchBytes.data();
   const size_t size = sketchBytes.size();
 
-  bytes[HllUtil<>::PREAMBLE_INTS_BYTE] = 0;
+  bytes[hll_constants::PREAMBLE_INTS_BYTE] = 0;
   // fail in HllSketchImpl
   REQUIRE_THROWS_AS(hll_sketch::deserialize(bytes, size), std::invalid_argument);
   // fail in CouponHashSet
   REQUIRE_THROWS_AS(CouponHashSet<std::allocator<uint8_t>>::newSet(bytes, size, std::allocator<uint8_t>()), std::invalid_argument);
-  bytes[HllUtil<>::PREAMBLE_INTS_BYTE] = HllUtil<>::HASH_SET_PREINTS;
+  bytes[hll_constants::PREAMBLE_INTS_BYTE] = hll_constants::HASH_SET_PREINTS;
 
-  bytes[HllUtil<>::SER_VER_BYTE] = 0;
+  bytes[hll_constants::SER_VER_BYTE] = 0;
   REQUIRE_THROWS_AS(hll_sketch::deserialize(bytes, size), std::invalid_argument);
-  bytes[HllUtil<>::SER_VER_BYTE] = HllUtil<>::SER_VER;
+  bytes[hll_constants::SER_VER_BYTE] = hll_constants::SER_VER;
 
-  bytes[HllUtil<>::FAMILY_BYTE] = 0;
+  bytes[hll_constants::FAMILY_BYTE] = 0;
   REQUIRE_THROWS_AS(hll_sketch::deserialize(bytes, size), std::invalid_argument);
-  bytes[HllUtil<>::FAMILY_BYTE] = HllUtil<>::FAMILY_ID;
+  bytes[hll_constants::FAMILY_BYTE] = hll_constants::FAMILY_ID;
 
-  bytes[HllUtil<>::LG_K_BYTE] = 6;
+  bytes[hll_constants::LG_K_BYTE] = 6;
   REQUIRE_THROWS_AS(hll_sketch::deserialize(bytes, size), std::invalid_argument);
-  bytes[HllUtil<>::LG_K_BYTE] = lgK;
+  bytes[hll_constants::LG_K_BYTE] = lgK;
 
-  uint8_t tmp = bytes[HllUtil<>::MODE_BYTE];
-  bytes[HllUtil<>::MODE_BYTE] = 0x10; // HLL_6, LIST
+  uint8_t tmp = bytes[hll_constants::MODE_BYTE];
+  bytes[hll_constants::MODE_BYTE] = 0x10; // HLL_6, LIST
   REQUIRE_THROWS_AS(hll_sketch::deserialize(bytes, size), std::invalid_argument);
-  bytes[HllUtil<>::MODE_BYTE] = tmp;
+  bytes[hll_constants::MODE_BYTE] = tmp;
 
-  tmp = bytes[HllUtil<>::LG_ARR_BYTE];
-  bytes[HllUtil<>::LG_ARR_BYTE] = 0;
+  tmp = bytes[hll_constants::LG_ARR_BYTE];
+  bytes[hll_constants::LG_ARR_BYTE] = 0;
   hll_sketch::deserialize(bytes, size);
   // should work fine despite the corruption
-  bytes[HllUtil<>::LG_ARR_BYTE] = tmp;
+  bytes[hll_constants::LG_ARR_BYTE] = tmp;
 
   REQUIRE_THROWS_AS(hll_sketch::deserialize(bytes, size - 1), std::out_of_range);
   REQUIRE_THROWS_AS(hll_sketch::deserialize(bytes, 3), std::out_of_range);
 }
 
 TEST_CASE("coupon hash set: check corrupt stream", "[coupon_hash_set]") {
-  int lgK = 9;
+  uint8_t lgK = 9;
   hll_sketch sk1(lgK);
   for (int i = 0; i < 24; ++i) {
     sk1.update(i);
@@ -82,48 +82,48 @@
   std::stringstream ss;
   sk1.serialize_compact(ss);
 
-  ss.seekp(HllUtil<>::PREAMBLE_INTS_BYTE);
+  ss.seekp(hll_constants::PREAMBLE_INTS_BYTE);
   ss.put(0);
   ss.seekg(0);
   // fail in HllSketchImpl
   REQUIRE_THROWS_AS(hll_sketch::deserialize(ss), std::invalid_argument);
   // fail in CouponHashSet
   REQUIRE_THROWS_AS(CouponHashSet<std::allocator<uint8_t>>::newSet(ss, std::allocator<uint8_t>()), std::invalid_argument);
-  ss.seekp(HllUtil<>::PREAMBLE_INTS_BYTE);
-  ss.put(HllUtil<>::HASH_SET_PREINTS);
+  ss.seekp(hll_constants::PREAMBLE_INTS_BYTE);
+  ss.put(hll_constants::HASH_SET_PREINTS);
 
-  ss.seekp(HllUtil<>::SER_VER_BYTE);
+  ss.seekp(hll_constants::SER_VER_BYTE);
   ss.put(0);
   ss.seekg(0);
   REQUIRE_THROWS_AS(hll_sketch::deserialize(ss), std::invalid_argument);
-  ss.seekp(HllUtil<>::SER_VER_BYTE);
-  ss.put(HllUtil<>::SER_VER);
+  ss.seekp(hll_constants::SER_VER_BYTE);
+  ss.put(hll_constants::SER_VER);
 
-  ss.seekp(HllUtil<>::FAMILY_BYTE);
+  ss.seekp(hll_constants::FAMILY_BYTE);
   ss.put(0);
   ss.seekg(0);
   REQUIRE_THROWS_AS(hll_sketch::deserialize(ss), std::invalid_argument);
-  ss.seekp(HllUtil<>::FAMILY_BYTE);
-  ss.put(HllUtil<>::FAMILY_ID);
+  ss.seekp(hll_constants::FAMILY_BYTE);
+  ss.put(hll_constants::FAMILY_ID);
 
-  ss.seekg(HllUtil<>::MODE_BYTE);
-  uint8_t tmp = ss.get();
-  ss.seekp(HllUtil<>::MODE_BYTE);
+  ss.seekg(hll_constants::MODE_BYTE);
+  auto tmp = ss.get();
+  ss.seekp(hll_constants::MODE_BYTE);
   ss.put(0x22); // HLL_8, HLL
   ss.seekg(0);
   REQUIRE_THROWS_AS(hll_sketch::deserialize(ss), std::invalid_argument);
-  ss.seekp(HllUtil<>::MODE_BYTE);
-  ss.put(tmp);
+  ss.seekp(hll_constants::MODE_BYTE);
+  ss.put((char)tmp);
 
-  ss.seekg(HllUtil<>::LG_ARR_BYTE);
+  ss.seekg(hll_constants::LG_ARR_BYTE);
   tmp = ss.get();
-  ss.seekp(HllUtil<>::LG_ARR_BYTE);
+  ss.seekp(hll_constants::LG_ARR_BYTE);
   ss.put(0);
   ss.seekg(0);
   hll_sketch::deserialize(ss);
   // should work fine despite the corruption
-  ss.seekp(HllUtil<>::LG_ARR_BYTE);
-  ss.put(tmp);
+  ss.seekp(hll_constants::LG_ARR_BYTE);
+  ss.put((char)tmp);
 }
 
 
diff --git a/hll/test/CouponListTest.cpp b/hll/test/CouponListTest.cpp
index 380b60d..a6c9333 100644
--- a/hll/test/CouponListTest.cpp
+++ b/hll/test/CouponListTest.cpp
@@ -35,9 +35,9 @@
 }
 
 TEST_CASE("coupon list: check iterator", "[coupon_list]") {
-  int lgConfigK = 8;
+  uint8_t lgConfigK = 8;
   CouponList<std::allocator<uint8_t>> cl(lgConfigK, HLL_4, LIST, std::allocator<uint8_t>());
-  for (int i = 1; i <= 7; ++i) { cl.couponUpdate(HllUtil<>::pair(i, i)); } // not hashes but distinct values
+  for (uint8_t i = 1; i <= 7; ++i) { cl.couponUpdate(HllUtil<>::pair(i, i)); } // not hashes but distinct values
   const int mask = (1 << lgConfigK) - 1;
   int idx = 0;
   auto itr = cl.begin(false);
@@ -56,7 +56,7 @@
 }
 
 TEST_CASE("coupon list: check duplicates and misc", "[coupon_list]") {
-  int lgConfigK = 8;
+  uint8_t lgConfigK = 8;
   hll_sketch sk(lgConfigK);
 
   for (int i = 1; i <= 7; ++i) {
@@ -79,7 +79,7 @@
   REQUIRE(relErr < 0.0);
 }
 
-static void serializeDeserialize(const int lgK) {
+static void serializeDeserialize(uint8_t lgK) {
   hll_sketch sk1(lgK);
 
   int u = (lgK < 8) ? 7 : (((1 << (lgK - 3))/ 4) * 3);
@@ -110,7 +110,7 @@
 }
 
 TEST_CASE("coupon list: check corrupt bytearray data", "[coupon_list]") {
-  int lgK = 6;
+  uint8_t lgK = 6;
   hll_sketch sk1(lgK);
   sk1.update(1);
   sk1.update(2);
@@ -118,24 +118,24 @@
   uint8_t* bytes = sketchBytes.data();
   const size_t size = sketchBytes.size();
 
-  bytes[HllUtil<>::PREAMBLE_INTS_BYTE] = 0;
+  bytes[hll_constants::PREAMBLE_INTS_BYTE] = 0;
   REQUIRE_THROWS_AS(hll_sketch::deserialize(bytes, size), std::invalid_argument);
   REQUIRE_THROWS_AS(CouponList<std::allocator<uint8_t>>::newList(bytes, size, std::allocator<uint8_t>()), std::invalid_argument);
 
-  bytes[HllUtil<>::PREAMBLE_INTS_BYTE] = HllUtil<>::LIST_PREINTS;
+  bytes[hll_constants::PREAMBLE_INTS_BYTE] = hll_constants::LIST_PREINTS;
 
-  bytes[HllUtil<>::SER_VER_BYTE] = 0;
+  bytes[hll_constants::SER_VER_BYTE] = 0;
   REQUIRE_THROWS_AS(hll_sketch::deserialize(bytes, size), std::invalid_argument);
-  bytes[HllUtil<>::SER_VER_BYTE] = HllUtil<>::SER_VER;
+  bytes[hll_constants::SER_VER_BYTE] = hll_constants::SER_VER;
 
-  bytes[HllUtil<>::FAMILY_BYTE] = 0;
+  bytes[hll_constants::FAMILY_BYTE] = 0;
   REQUIRE_THROWS_AS(hll_sketch::deserialize(bytes, size), std::invalid_argument);
-  bytes[HllUtil<>::FAMILY_BYTE] = HllUtil<>::FAMILY_ID;
+  bytes[hll_constants::FAMILY_BYTE] = hll_constants::FAMILY_ID;
 
-  uint8_t tmp = bytes[HllUtil<>::MODE_BYTE];
-  bytes[HllUtil<>::MODE_BYTE] = 0x01; // HLL_4, SET
+  uint8_t tmp = bytes[hll_constants::MODE_BYTE];
+  bytes[hll_constants::MODE_BYTE] = 0x01; // HLL_4, SET
   REQUIRE_THROWS_AS(hll_sketch::deserialize(bytes, size), std::invalid_argument);
-  bytes[HllUtil<>::MODE_BYTE] = tmp;
+  bytes[hll_constants::MODE_BYTE] = tmp;
 
   REQUIRE_THROWS_AS(hll_sketch::deserialize(bytes, size - 1), std::out_of_range);
 
@@ -143,36 +143,36 @@
 }
 
 TEST_CASE("coupon list: check corrupt stream data", "[coupon_list]") {
-  int lgK = 6;
+  uint8_t lgK = 6;
   hll_sketch sk1(lgK);
   sk1.update(1);
   sk1.update(2);
   std::stringstream ss;
   sk1.serialize_compact(ss);
 
-  ss.seekp(HllUtil<>::PREAMBLE_INTS_BYTE);
+  ss.seekp(hll_constants::PREAMBLE_INTS_BYTE);
   ss.put(0);
   ss.seekg(0);
   REQUIRE_THROWS_AS(hll_sketch::deserialize(ss), std::invalid_argument);
   REQUIRE_THROWS_AS(CouponList<std::allocator<uint8_t>>::newList(ss, std::allocator<uint8_t>()), std::invalid_argument);
-  ss.seekp(HllUtil<>::PREAMBLE_INTS_BYTE);
-  ss.put(HllUtil<>::LIST_PREINTS);
+  ss.seekp(hll_constants::PREAMBLE_INTS_BYTE);
+  ss.put(hll_constants::LIST_PREINTS);
 
-  ss.seekp(HllUtil<>::SER_VER_BYTE);
+  ss.seekp(hll_constants::SER_VER_BYTE);
   ss.put(0);
   ss.seekg(0);
   REQUIRE_THROWS_AS(hll_sketch::deserialize(ss), std::invalid_argument);
-  ss.seekp(HllUtil<>::SER_VER_BYTE);
-  ss.put(HllUtil<>::SER_VER);
+  ss.seekp(hll_constants::SER_VER_BYTE);
+  ss.put(hll_constants::SER_VER);
 
-  ss.seekp(HllUtil<>::FAMILY_BYTE);
+  ss.seekp(hll_constants::FAMILY_BYTE);
   ss.put(0);
   ss.seekg(0);
   REQUIRE_THROWS_AS(hll_sketch::deserialize(ss), std::invalid_argument);
-  ss.seekp(HllUtil<>::FAMILY_BYTE);
-  ss.put(HllUtil<>::FAMILY_ID);
+  ss.seekp(hll_constants::FAMILY_BYTE);
+  ss.put(hll_constants::FAMILY_ID);
 
-  ss.seekp(HllUtil<>::MODE_BYTE);
+  ss.seekp(hll_constants::MODE_BYTE);
   ss.put(0x22); // HLL_8, HLL
   ss.seekg(0);
   REQUIRE_THROWS_AS(hll_sketch::deserialize(ss), std::invalid_argument);
diff --git a/hll/test/CrossCountingTest.cpp b/hll/test/CrossCountingTest.cpp
index 21eb919..aabe741 100644
--- a/hll/test/CrossCountingTest.cpp
+++ b/hll/test/CrossCountingTest.cpp
@@ -26,7 +26,7 @@
 
 namespace datasketches {
 
-static hll_sketch buildSketch(const int n, const int lgK, const target_hll_type tgtHllType) {
+static hll_sketch buildSketch(const int n, const uint8_t lgK, const target_hll_type tgtHllType) {
   hll_sketch sketch(lgK, tgtHllType);
   for (int i = 0; i < n; ++i) {
     sketch.update(i);
@@ -34,7 +34,7 @@
   return sketch;
 }
 
-static void crossCountingCheck(const int lgK, const int n) {
+static void crossCountingCheck(const uint8_t lgK, const int n) {
   hll_sketch sk4 = buildSketch(n, lgK, HLL_4);
   const double est = sk4.get_estimate();
   const double lb = sk4.get_lower_bound(1);
diff --git a/hll/test/HllArrayTest.cpp b/hll/test/HllArrayTest.cpp
index f067dbb..ce39791 100644
--- a/hll/test/HllArrayTest.cpp
+++ b/hll/test/HllArrayTest.cpp
@@ -25,7 +25,7 @@
 
 namespace datasketches {
 
-static void testComposite(const int lgK, const target_hll_type tgtHllType, const int n) {
+static void testComposite(uint8_t lgK, const target_hll_type tgtHllType, const int n) {
   hll_union u(lgK);
   hll_sketch sk(lgK, tgtHllType);
   for (int i = 0; i < n; ++i) {
@@ -45,7 +45,7 @@
   testComposite(13, target_hll_type::HLL_8, 10000);
 }
 
-static void serializeDeserialize(const int lgK, target_hll_type tgtHllType, const int n) {
+static void serializeDeserialize(uint8_t lgK, target_hll_type tgtHllType, const int n) {
   hll_sketch sk1(lgK, tgtHllType);
 
   for (int i = 0; i < n; ++i) {
@@ -72,7 +72,7 @@
 }
 
 TEST_CASE("hll array: check serialize deserialize", "[hll_array]") {
-  int lgK = 4;
+  uint8_t lgK = 4;
   int n = 8;
   serializeDeserialize(lgK, HLL_4, n);
   serializeDeserialize(lgK, HLL_6, n);
@@ -100,7 +100,7 @@
 }
 
 TEST_CASE("hll array: check corrupt bytearray", "[hll_array]") {
-  int lgK = 8;
+  uint8_t lgK = 8;
   hll_sketch sk1(lgK, HLL_8);
   for (int i = 0; i < 50; ++i) {
     sk1.update(i);
@@ -109,36 +109,36 @@
   uint8_t* bytes = sketchBytes.data();
   const size_t size = sketchBytes.size();
 
-  bytes[HllUtil<>::PREAMBLE_INTS_BYTE] = 0;
+  bytes[hll_constants::PREAMBLE_INTS_BYTE] = 0;
   REQUIRE_THROWS_AS(hll_sketch::deserialize(bytes, size), std::invalid_argument);
   REQUIRE_THROWS_AS(HllArray<std::allocator<uint8_t>>::newHll(bytes, size, std::allocator<uint8_t>()), std::invalid_argument);
-  bytes[HllUtil<>::PREAMBLE_INTS_BYTE] = HllUtil<>::HLL_PREINTS;
+  bytes[hll_constants::PREAMBLE_INTS_BYTE] = hll_constants::HLL_PREINTS;
 
-  bytes[HllUtil<>::SER_VER_BYTE] = 0;
+  bytes[hll_constants::SER_VER_BYTE] = 0;
   REQUIRE_THROWS_AS(hll_sketch::deserialize(bytes, size), std::invalid_argument);
-  bytes[HllUtil<>::SER_VER_BYTE] = HllUtil<>::SER_VER;
+  bytes[hll_constants::SER_VER_BYTE] = hll_constants::SER_VER;
 
-  bytes[HllUtil<>::FAMILY_BYTE] = 0;
+  bytes[hll_constants::FAMILY_BYTE] = 0;
   REQUIRE_THROWS_AS(hll_sketch::deserialize(bytes, size), std::invalid_argument);
-  bytes[HllUtil<>::FAMILY_BYTE] = HllUtil<>::FAMILY_ID;
+  bytes[hll_constants::FAMILY_BYTE] = hll_constants::FAMILY_ID;
 
-  uint8_t tmp = bytes[HllUtil<>::MODE_BYTE];
-  bytes[HllUtil<>::MODE_BYTE] = 0x10; // HLL_6, LIST
+  uint8_t tmp = bytes[hll_constants::MODE_BYTE];
+  bytes[hll_constants::MODE_BYTE] = 0x10; // HLL_6, LIST
   REQUIRE_THROWS_AS(hll_sketch::deserialize(bytes, size), std::invalid_argument);
-  bytes[HllUtil<>::MODE_BYTE] = tmp;
+  bytes[hll_constants::MODE_BYTE] = tmp;
 
-  tmp = bytes[HllUtil<>::LG_ARR_BYTE];
-  bytes[HllUtil<>::LG_ARR_BYTE] = 0;
+  tmp = bytes[hll_constants::LG_ARR_BYTE];
+  bytes[hll_constants::LG_ARR_BYTE] = 0;
   hll_sketch::deserialize(bytes, size);
   // should work fine despite the corruption
-  bytes[HllUtil<>::LG_ARR_BYTE] = tmp;
+  bytes[hll_constants::LG_ARR_BYTE] = tmp;
 
   REQUIRE_THROWS_AS(hll_sketch::deserialize(bytes, size - 1), std::out_of_range);
   REQUIRE_THROWS_AS(hll_sketch::deserialize(bytes, 3), std::out_of_range);
 }
 
 TEST_CASE("hll array: check corrupt stream", "[hll_array]") {
-  int lgK = 6;
+  uint8_t lgK = 6;
   hll_sketch sk1(lgK);
   for (int i = 0; i < 50; ++i) {
     sk1.update(i);
@@ -146,46 +146,46 @@
   std::stringstream ss;
   sk1.serialize_compact(ss);
 
-  ss.seekp(HllUtil<>::PREAMBLE_INTS_BYTE);
+  ss.seekp(hll_constants::PREAMBLE_INTS_BYTE);
   ss.put(0);
   ss.seekg(0);
   REQUIRE_THROWS_AS(hll_sketch::deserialize(ss), std::invalid_argument);
   REQUIRE_THROWS_AS(HllArray<std::allocator<uint8_t>>::newHll(ss, std::allocator<uint8_t>()), std::invalid_argument);
-  ss.seekp(HllUtil<>::PREAMBLE_INTS_BYTE);
-  ss.put(HllUtil<>::HLL_PREINTS);
+  ss.seekp(hll_constants::PREAMBLE_INTS_BYTE);
+  ss.put(hll_constants::HLL_PREINTS);
 
-  ss.seekp(HllUtil<>::SER_VER_BYTE);
+  ss.seekp(hll_constants::SER_VER_BYTE);
   ss.put(0);
   ss.seekg(0);
   REQUIRE_THROWS_AS(hll_sketch::deserialize(ss), std::invalid_argument);
-  ss.seekp(HllUtil<>::SER_VER_BYTE);
-  ss.put(HllUtil<>::SER_VER);
+  ss.seekp(hll_constants::SER_VER_BYTE);
+  ss.put(hll_constants::SER_VER);
 
-  ss.seekp(HllUtil<>::FAMILY_BYTE);
+  ss.seekp(hll_constants::FAMILY_BYTE);
   ss.put(0);
   ss.seekg(0);
   REQUIRE_THROWS_AS(hll_sketch::deserialize(ss), std::invalid_argument);
-  ss.seekp(HllUtil<>::FAMILY_BYTE);
-  ss.put(HllUtil<>::FAMILY_ID);
+  ss.seekp(hll_constants::FAMILY_BYTE);
+  ss.put(hll_constants::FAMILY_ID);
 
-  ss.seekg(HllUtil<>::MODE_BYTE);
-  uint8_t tmp = ss.get();
-  ss.seekp(HllUtil<>::MODE_BYTE);
+  ss.seekg(hll_constants::MODE_BYTE);
+  auto tmp = ss.get();
+  ss.seekp(hll_constants::MODE_BYTE);
   ss.put(0x11); // HLL_6, SET
   ss.seekg(0);
   REQUIRE_THROWS_AS(hll_sketch::deserialize(ss), std::invalid_argument);
-  ss.seekp(HllUtil<>::MODE_BYTE);
-  ss.put(tmp);
+  ss.seekp(hll_constants::MODE_BYTE);
+  ss.put((char)tmp);
 
-  ss.seekg(HllUtil<>::LG_ARR_BYTE);
+  ss.seekg(hll_constants::LG_ARR_BYTE);
   tmp = ss.get();
-  ss.seekp(HllUtil<>::LG_ARR_BYTE);
+  ss.seekp(hll_constants::LG_ARR_BYTE);
   ss.put(0);
   ss.seekg(0);
   hll_sketch::deserialize(ss);
   // should work fine despite the corruption
-  ss.seekp(HllUtil<>::LG_ARR_BYTE);
-  ss.put(tmp);
+  ss.seekp(hll_constants::LG_ARR_BYTE);
+  ss.put((char)tmp);
 }
 
 } /* namespace datasketches */
diff --git a/hll/test/HllSketchTest.cpp b/hll/test/HllSketchTest.cpp
index 541a70a..b0635d8 100644
--- a/hll/test/HllSketchTest.cpp
+++ b/hll/test/HllSketchTest.cpp
@@ -27,7 +27,7 @@
 using hll_sketch_test_alloc = hll_sketch_alloc<test_allocator<uint8_t>>;
 using alloc = test_allocator<uint8_t>;
 
-static void runCheckCopy(int lgConfigK, target_hll_type tgtHllType) {
+static void runCheckCopy(uint8_t lgConfigK, target_hll_type tgtHllType) {
   hll_sketch_test_alloc sk(lgConfigK, tgtHllType, false, 0);
 
   for (int i = 0; i < 7; ++i) {
@@ -66,7 +66,7 @@
 }
 
 static void copyAs(target_hll_type srcType, target_hll_type dstType) {
-  int lgK = 8;
+  uint8_t lgK = 8;
   int n1 = 7;
   int n2 = 24;
   int n3 = 1000;
@@ -109,7 +109,7 @@
 TEST_CASE("hll sketch: check misc1", "[hll_sketch]") {
   test_allocator_total_bytes = 0;
   {
-    int lgConfigK = 8;
+    uint8_t lgConfigK = 8;
     target_hll_type srcType = target_hll_type::HLL_8;
     hll_sketch_test_alloc sk(lgConfigK, srcType, false, 0);
 
@@ -124,7 +124,7 @@
     sk.update(24); // HLL
     REQUIRE(sk.get_updatable_serialization_bytes() == 40 + 256);
 
-    const int hllBytes = HllUtil<>::HLL_BYTE_ARR_START + (1 << lgConfigK);
+    const auto hllBytes = hll_constants::HLL_BYTE_ARR_START + (1 << lgConfigK);
     REQUIRE(sk.get_compact_serialization_bytes() == hllBytes);
     REQUIRE(hll_sketch::get_max_updatable_serialization_bytes(lgConfigK, HLL_8) == hllBytes);
   }
@@ -135,22 +135,22 @@
   REQUIRE_THROWS_AS(HllUtil<>::checkNumStdDev(0), std::invalid_argument);
 }
 
-void checkSerializationSizes(const int lgConfigK, target_hll_type tgtHllType) {
+void checkSerializationSizes(uint8_t lgConfigK, target_hll_type tgtHllType) {
   hll_sketch_test_alloc sk(lgConfigK, tgtHllType, false, 0);
   int i;
 
   // LIST
   for (i = 0; i < 7; ++i) { sk.update(i); }
-  int expected = HllUtil<>::LIST_INT_ARR_START + (i << 2);
+  auto expected = hll_constants::LIST_INT_ARR_START + (i << 2);
   REQUIRE(sk.get_compact_serialization_bytes() == expected);
-  expected = HllUtil<>::LIST_INT_ARR_START + (4 << HllUtil<>::LG_INIT_LIST_SIZE);
+  expected = hll_constants::LIST_INT_ARR_START + (4 << hll_constants::LG_INIT_LIST_SIZE);
   REQUIRE(sk.get_updatable_serialization_bytes() == expected);
 
   // SET
   for (i = 7; i < 24; ++i) { sk.update(i); }
-  expected = HllUtil<>::HASH_SET_INT_ARR_START + (i << 2);
+  expected = hll_constants::HASH_SET_INT_ARR_START + (i << 2);
   REQUIRE(sk.get_compact_serialization_bytes() == expected);
-  expected = HllUtil<>::HASH_SET_INT_ARR_START + (4 << HllUtil<>::LG_INIT_SET_SIZE);
+  expected = hll_constants::HASH_SET_INT_ARR_START + (4 << hll_constants::LG_INIT_SET_SIZE);
   REQUIRE(sk.get_updatable_serialization_bytes() == expected);
 }
 
@@ -178,7 +178,7 @@
 
 // Creates and serializes then deserializes sketch.
 // Returns true if deserialized sketch is compact.
-static bool checkCompact(const int lgK, const int n, const target_hll_type type, bool compact) {
+static bool checkCompact(uint8_t lgK, const int n, const target_hll_type type, bool compact) {
   hll_sketch_test_alloc sk(lgK, type, false, 0);
   for (int i = 0; i < n; ++i) { sk.update(i); }
   
@@ -201,7 +201,7 @@
 TEST_CASE("hll sketch: check compact flag", "[hll_sketch]") {
   test_allocator_total_bytes = 0;
   {
-    int lgK = 8;
+    uint8_t lgK = 8;
     // unless/until we create non-updatable "direct" versions,
     // deserialized image should never be compact
     // LIST: follows serialization request
@@ -230,10 +230,10 @@
 TEST_CASE("hll sketch: check k limits", "[hll_sketch]") {
   test_allocator_total_bytes = 0;
   {
-    hll_sketch_test_alloc sketch1(HllUtil<>::MIN_LOG_K, target_hll_type::HLL_8, false, 0);
-    hll_sketch_test_alloc sketch2(HllUtil<>::MAX_LOG_K, target_hll_type::HLL_4, false, 0);
-    REQUIRE_THROWS_AS(hll_sketch_test_alloc(HllUtil<>::MIN_LOG_K - 1, target_hll_type::HLL_4, false, 0), std::invalid_argument);
-    REQUIRE_THROWS_AS(hll_sketch_test_alloc(HllUtil<>::MAX_LOG_K + 1, target_hll_type::HLL_4, false, 0), std::invalid_argument);
+    hll_sketch_test_alloc sketch1(hll_constants::MIN_LOG_K, target_hll_type::HLL_8, false, 0);
+    hll_sketch_test_alloc sketch2(hll_constants::MAX_LOG_K, target_hll_type::HLL_4, false, 0);
+    REQUIRE_THROWS_AS(hll_sketch_test_alloc(hll_constants::MIN_LOG_K - 1, target_hll_type::HLL_4, false, 0), std::invalid_argument);
+    REQUIRE_THROWS_AS(hll_sketch_test_alloc(hll_constants::MAX_LOG_K + 1, target_hll_type::HLL_4, false, 0), std::invalid_argument);
   }
   REQUIRE(test_allocator_total_bytes == 0);
 }
diff --git a/hll/test/HllUnionTest.cpp b/hll/test/HllUnionTest.cpp
index 3250901..e2f4448 100644
--- a/hll/test/HllUnionTest.cpp
+++ b/hll/test/HllUnionTest.cpp
@@ -24,23 +24,19 @@
 
 namespace datasketches {
 
-static int min(int a, int b) {
-  return (a < b) ? a : b;
-}
-
 static void println(std::string& str) {
   //std::cout << str << "\n";
 }
 
 static void basicUnion(uint64_t n1, uint64_t n2,
-		                   uint64_t lgk1, uint64_t lgk2, uint64_t lgMaxK,
+		                   uint8_t lgk1, uint8_t lgk2, uint8_t lgMaxK,
                        target_hll_type type1, target_hll_type type2, target_hll_type resultType) {
   uint64_t v = 0;
   //int tot = n1 + n2;
 
   hll_sketch h1(lgk1, type1);
   hll_sketch h2(lgk2, type2);
-  int lgControlK = min(min(lgk1, lgk2), lgMaxK);
+  uint8_t lgControlK = std::min(std::min(lgk1, lgk2), lgMaxK);
   hll_sketch control(lgControlK, resultType);
 
   for (uint64_t i = 0; i < n1; ++i) {
@@ -89,9 +85,9 @@
   target_hll_type type2 = HLL_8;
   target_hll_type resultType = HLL_8;
 
-  uint64_t lgK1 = 7;
-  uint64_t lgK2 = 7;
-  uint64_t lgMaxK = 7;
+  uint8_t lgK1 = 7;
+  uint8_t lgK2 = 7;
+  uint8_t lgMaxK = 7;
   uint64_t n1 = 7;
   uint64_t n2 = 7;
   basicUnion(n1, n2, lgK1, lgK2, lgMaxK, type1, type2, resultType);
@@ -108,7 +104,7 @@
   n2 = 14;
   basicUnion(n1, n2, lgK1, lgK2, lgMaxK, type1, type2, resultType);
 
-  int i = 0;
+  uint8_t i = 0;
   for (i = 7; i <= 13; ++i) {
     lgK1 = i;
     lgK2 = i;
@@ -184,9 +180,9 @@
 }
 
 TEST_CASE("hll union: check config k limits", "[hll_union]") {
-  REQUIRE_THROWS_AS(hll_union(HllUtil<>::MIN_LOG_K - 1), std::invalid_argument);
+  REQUIRE_THROWS_AS(hll_union(hll_constants::MIN_LOG_K - 1), std::invalid_argument);
 
-  REQUIRE_THROWS_AS(hll_union(HllUtil<>::MAX_LOG_K + 1), std::invalid_argument);
+  REQUIRE_THROWS_AS(hll_union(hll_constants::MAX_LOG_K + 1), std::invalid_argument);
 }
 
 static double getBound(int lgK, bool ub, bool oooFlag, int numStdDev, double est) {
@@ -195,7 +191,7 @@
 }
 
 TEST_CASE("hll union: check ub lb", "[hll_union]") {
-  int lgK = 4;
+  uint8_t lgK = 4;
   int n = 1 << 20;
   bool oooFlag = false;
   
@@ -223,7 +219,7 @@
 }
 
 TEST_CASE("hll union: check conversions", "[hll_union]") {
-  int lgK = 4;
+  uint8_t lgK = 4;
   hll_sketch sk1(lgK, HLL_8);
   hll_sketch sk2(lgK, HLL_8);
   int n = 1 << 20;
diff --git a/hll/test/IsomorphicTest.cpp b/hll/test/IsomorphicTest.cpp
index 509469b..df7a9e1 100644
--- a/hll/test/IsomorphicTest.cpp
+++ b/hll/test/IsomorphicTest.cpp
@@ -57,7 +57,7 @@
 
 static long v = 0;
 
-static hll_sketch build_sketch(int lg_k, target_hll_type hll_type, hll_mode mode) {
+static hll_sketch build_sketch(uint8_t lg_k, target_hll_type hll_type, hll_mode mode) {
   hll_sketch sk(lg_k, hll_type);
   int n = get_n(lg_k, mode);
   for (int i = 0; i < n; i++) sk.update(static_cast<uint64_t>(i + v));
@@ -67,7 +67,7 @@
 
 // merges a sketch to an empty union and gets result of the same type, checks binary equivalence
 static void union_one_update(bool compact) {
-  for (int lg_k = 4; lg_k <= 21; lg_k++) { // all lg_k
+  for (uint8_t lg_k = 4; lg_k <= 21; lg_k++) { // all lg_k
     for (int mode = 0; mode <= 2; mode++) { // List, Set, Hll
       if ((lg_k < 8) && (mode == 1)) continue; // lg_k < 8 list transitions directly to HLL
       for (int t = 0; t <= 2; t++) { // HLL_4, HLL_6, HLL_8
@@ -102,7 +102,7 @@
 
 // converts a sketch to a different type and converts back to the original type to check binary equivalence
 static void convert_back_and_forth(bool compact) {
-  for (int lg_k = 4; lg_k <= 21; lg_k++) { // all lg_k
+  for (uint8_t lg_k = 4; lg_k <= 21; lg_k++) { // all lg_k
     for (int mode = 0; mode <= 2; mode++) { // List, Set, Hll
       if ((lg_k < 8) && (mode == 1)) continue; // lg_k < 8 list transitions directly to HLL
       for (int t1 = 0; t1 <= 2; t1++) { // HLL_4, HLL_6, HLL_8
diff --git a/hll/test/ToFromByteArrayTest.cpp b/hll/test/ToFromByteArrayTest.cpp
index 48f49a2..3ea8113 100644
--- a/hll/test/ToFromByteArrayTest.cpp
+++ b/hll/test/ToFromByteArrayTest.cpp
@@ -44,11 +44,11 @@
   auto ser2 = sk.serialize_updatable();
 
   REQUIRE(ser1.size() == ser2.size());
-  int len = ser1.size();
+  size_t len = ser1.size();
   uint8_t* b1 = ser1.data();
   uint8_t* b2 = ser2.data();
 
-  for (int i = 0; i < len; ++i) {
+  for (size_t i = 0; i < len; ++i) {
     REQUIRE(b2[i] == b1[i]);
   }
 }
@@ -129,7 +129,7 @@
   REQUIRE(sk1.get_target_type() == sk2.get_target_type());
 }
 
-static void toFrom(const int lgConfigK, const target_hll_type tgtHllType, const int n) {
+static void toFrom(const uint8_t lgConfigK, const target_hll_type tgtHllType, const int n) {
   hll_sketch src(lgConfigK, tgtHllType);
   for (int i = 0; i < n; ++i) {
     src.update(i);
@@ -157,7 +157,7 @@
 TEST_CASE("hll to/from byte array: to from sketch", "[hll_byte_array]") {
   for (int i = 0; i < 10; ++i) {
     int n = nArr[i];
-    for (int lgK = 4; lgK <= 13; ++lgK) {
+    for (uint8_t lgK = 4; lgK <= 13; ++lgK) {
       toFrom(lgK, HLL_4, n);
       toFrom(lgK, HLL_6, n);
       toFrom(lgK, HLL_8, n);
diff --git a/kll/include/kll_helper.hpp b/kll/include/kll_helper.hpp
index 4857f51..c026538 100644
--- a/kll/include/kll_helper.hpp
+++ b/kll/include/kll_helper.hpp
@@ -26,7 +26,8 @@
 
 namespace datasketches {
 
-static std::independent_bits_engine<std::mt19937, 1, uint32_t> random_bit(std::chrono::system_clock::now().time_since_epoch().count());
+static std::independent_bits_engine<std::mt19937, 1, uint32_t>
+  random_bit(static_cast<uint32_t>(std::chrono::system_clock::now().time_since_epoch().count()));
 
 #ifdef KLL_VALIDATION
 extern uint32_t kll_next_offset;
@@ -46,9 +47,9 @@
     static inline uint8_t floor_of_log2_of_fraction(uint64_t numer, uint64_t denom);
     static inline uint8_t ub_on_num_levels(uint64_t n);
     static inline uint32_t compute_total_capacity(uint16_t k, uint8_t m, uint8_t num_levels);
-    static inline uint32_t level_capacity(uint16_t k, uint8_t numLevels, uint8_t height, uint8_t min_wid);
-    static inline uint32_t int_cap_aux(uint16_t k, uint8_t depth);
-    static inline uint32_t int_cap_aux_aux(uint16_t k, uint8_t depth);
+    static inline uint16_t level_capacity(uint16_t k, uint8_t numLevels, uint8_t height, uint8_t min_wid);
+    static inline uint16_t int_cap_aux(uint16_t k, uint8_t depth);
+    static inline uint16_t int_cap_aux_aux(uint16_t k, uint8_t depth);
     static inline uint64_t sum_the_sample_weights(uint8_t num_levels, const uint32_t* levels);
 
     /*
diff --git a/kll/include/kll_helper_impl.hpp b/kll/include/kll_helper_impl.hpp
index 011a78d..caa611b 100644
--- a/kll/include/kll_helper_impl.hpp
+++ b/kll/include/kll_helper_impl.hpp
@@ -55,28 +55,28 @@
   return total;
 }
 
-uint32_t kll_helper::level_capacity(uint16_t k, uint8_t numLevels, uint8_t height, uint8_t min_wid) {
+uint16_t kll_helper::level_capacity(uint16_t k, uint8_t numLevels, uint8_t height, uint8_t min_wid) {
   if (height >= numLevels) throw std::invalid_argument("height >= numLevels");
   const uint8_t depth = numLevels - height - 1;
-  return std::max((uint32_t) min_wid, int_cap_aux(k, depth));
+  return std::max<uint16_t>(min_wid, int_cap_aux(k, depth));
 }
 
-uint32_t kll_helper::int_cap_aux(uint16_t k, uint8_t depth) {
+uint16_t kll_helper::int_cap_aux(uint16_t k, uint8_t depth) {
   if (depth > 60) throw std::invalid_argument("depth > 60");
   if (depth <= 30) return int_cap_aux_aux(k, depth);
   const uint8_t half = depth / 2;
   const uint8_t rest = depth - half;
-  const uint32_t tmp = int_cap_aux_aux(k, half);
+  const uint16_t tmp = int_cap_aux_aux(k, half);
   return int_cap_aux_aux(tmp, rest);
 }
 
-uint32_t kll_helper::int_cap_aux_aux(uint16_t k, uint8_t depth) {
+uint16_t kll_helper::int_cap_aux_aux(uint16_t k, uint8_t depth) {
   if (depth > 30) throw std::invalid_argument("depth > 30");
   const uint64_t twok = k << 1; // for rounding, we pre-multiply by 2
   const uint64_t tmp = (uint64_t) (((uint64_t) twok << depth) / powers_of_three[depth]);
   const uint64_t result = (tmp + 1) >> 1; // then here we add 1 and divide by 2
   if (result > k) throw std::logic_error("result > k");
-  return result;
+  return static_cast<uint16_t>(result);
 }
 
 uint64_t kll_helper::sum_the_sample_weights(uint8_t num_levels, const uint32_t* levels) {
diff --git a/kll/include/kll_quantile_calculator.hpp b/kll/include/kll_quantile_calculator.hpp
index 5114399..86dfe98 100644
--- a/kll/include/kll_quantile_calculator.hpp
+++ b/kll/include/kll_quantile_calculator.hpp
@@ -45,7 +45,7 @@
     T approximately_answer_positional_query(uint64_t pos) const;
     void convert_to_preceding_cummulative();
     uint32_t chunk_containing_pos(uint64_t pos) const;
-    uint32_t search_for_chunk_containing_pos(uint64_t pos, uint32_t l, uint32_t r) const;
+    uint32_t search_for_chunk_containing_pos(uint64_t pos, uint64_t l, uint64_t r) const;
     static void merge_sorted_blocks(Container& entries, const uint32_t* levels, uint8_t num_levels, uint32_t num_items);
     static void merge_sorted_blocks_direct(Container& orig, Container& temp, const uint32_t* levels, uint8_t starting_level, uint8_t num_levels);
     static void merge_sorted_blocks_reversed(Container& orig, Container& temp, const uint32_t* levels, uint8_t starting_level, uint8_t num_levels);
diff --git a/kll/include/kll_quantile_calculator_impl.hpp b/kll/include/kll_quantile_calculator_impl.hpp
index ff6e547..5bd4294 100644
--- a/kll/include/kll_quantile_calculator_impl.hpp
+++ b/kll/include/kll_quantile_calculator_impl.hpp
@@ -35,7 +35,7 @@
   const uint32_t num_items = levels[num_levels] - levels[0];
   entries_.reserve(num_items);
   populate_from_sketch(items, levels, num_levels);
-  merge_sorted_blocks(entries_, levels_.data(), levels_.size() - 1, num_items);
+  merge_sorted_blocks(entries_, levels_.data(), static_cast<uint8_t>(levels_.size()) - 1, num_items);
   if (!is_sorted(entries_.begin(), entries_.end(), compare_pair_by_first<C>())) throw std::logic_error("entries must be sorted");
   convert_to_preceding_cummulative();
 }
@@ -89,7 +89,7 @@
 
 template <typename T, typename C, typename A>
 uint64_t kll_quantile_calculator<T, C, A>::pos_of_phi(double phi, uint64_t n) {
-  const uint64_t pos = std::floor(phi * n);
+  const uint64_t pos = static_cast<uint64_t>(std::floor(phi * n));
   return (pos == n) ? n - 1 : pos;
 }
 
@@ -102,11 +102,11 @@
 }
 
 template <typename T, typename C, typename A>
-uint32_t kll_quantile_calculator<T, C, A>::search_for_chunk_containing_pos(uint64_t pos, uint32_t l, uint32_t r) const {
+uint32_t kll_quantile_calculator<T, C, A>::search_for_chunk_containing_pos(uint64_t pos, uint64_t l, uint64_t r) const {
   if (l + 1 == r) {
-    return l;
+    return static_cast<uint32_t>(l);
   }
-  const uint32_t m(l + (r - l) / 2);
+  const uint64_t m = l + (r - l) / 2;
   if (entries_[m].second <= pos) {
     return search_for_chunk_containing_pos(pos, m, r);
   }
diff --git a/kll/include/kll_sketch.hpp b/kll/include/kll_sketch.hpp
index bbca76f..6447a26 100644
--- a/kll/include/kll_sketch.hpp
+++ b/kll/include/kll_sketch.hpp
@@ -296,7 +296,7 @@
      *
      * @return array of approximations to the given number of evenly-spaced fractional ranks.
      */
-    std::vector<T, A> get_quantiles(size_t num) const;
+    std::vector<T, A> get_quantiles(uint32_t num) const;
 
     /**
      * Returns an approximation to the normalized (fractional) rank of the given value from 0 to 1,
diff --git a/kll/include/kll_sketch_impl.hpp b/kll/include/kll_sketch_impl.hpp
index 8109403..0115d75 100644
--- a/kll/include/kll_sketch_impl.hpp
+++ b/kll/include/kll_sketch_impl.hpp
@@ -303,7 +303,7 @@
 }
 
 template<typename T, typename C, typename S, typename A>
-std::vector<T, A> kll_sketch<T, C, S, A>::get_quantiles(size_t num) const {
+std::vector<T, A> kll_sketch<T, C, S, A>::get_quantiles(uint32_t num) const {
   if (is_empty()) return std::vector<T, A>(allocator_);
   if (num == 0) {
     throw std::invalid_argument("num must be > 0");
@@ -380,7 +380,7 @@
   size_t size = DATA_START + num_levels_ * sizeof(uint32_t);
   size += S().size_of_item(*min_value_);
   size += S().size_of_item(*max_value_);
-  for (auto& it: *this) size += S().size_of_item(it.first);
+  for (auto it: *this) size += S().size_of_item(it.first);
   return size;
 }
 
@@ -555,7 +555,7 @@
   check_preamble_ints(preamble_ints, flags_byte);
   check_serial_version(serial_version);
   check_family_id(family_id);
-  ensure_minimum_memory(size, 1 << preamble_ints);
+  ensure_minimum_memory(size, 1ULL << preamble_ints);
 
   const bool is_empty(flags_byte & (1 << flags::IS_EMPTY));
   if (is_empty) return kll_sketch<T, C, S, A>(k, allocator);
diff --git a/kll/test/kll_sketch_test.cpp b/kll/test/kll_sketch_test.cpp
index f0c813e..f7afcbe 100644
--- a/kll/test/kll_sketch_test.cpp
+++ b/kll/test/kll_sketch_test.cpp
@@ -70,8 +70,7 @@
     REQUIRE(sketch.get_PMF(split_points, 1).size() == 0);
     REQUIRE(sketch.get_CDF(split_points, 1).size() == 0);
 
-    int count = 0;
-    for (auto& it: sketch) {
+    for (auto it: sketch) {
       (void) it; // to suppress "unused" warning
       FAIL("should be no iterations over an empty sketch");
     }
@@ -85,13 +84,13 @@
 
   SECTION("one item") {
     kll_float_sketch sketch(200, 0);
-    sketch.update(1);
+    sketch.update(1.0f);
     REQUIRE_FALSE(sketch.is_empty());
     REQUIRE_FALSE(sketch.is_estimation_mode());
     REQUIRE(sketch.get_n() == 1);
     REQUIRE(sketch.get_num_retained() == 1);
-    REQUIRE(sketch.get_rank(1) == 0.0);
-    REQUIRE(sketch.get_rank(2) == 1.0);
+    REQUIRE(sketch.get_rank(1.0f) == 0.0);
+    REQUIRE(sketch.get_rank(2.0f) == 1.0);
     REQUIRE(sketch.get_min_value() == 1.0);
     REQUIRE(sketch.get_max_value() == 1.0);
     REQUIRE(sketch.get_quantile(0.5) == 1.0);
@@ -103,7 +102,7 @@
     REQUIRE(quantiles[2] == 1.0);
 
     int count = 0;
-    for (auto& it: sketch) {
+    for (auto it: sketch) {
       REQUIRE(it.second == 1);
       ++count;
     }
@@ -115,7 +114,7 @@
     sketch.update(std::numeric_limits<float>::quiet_NaN());
     REQUIRE(sketch.is_empty());
 
-    sketch.update(0.0);
+    sketch.update(0);
     sketch.update(std::numeric_limits<float>::quiet_NaN());
     REQUIRE(sketch.get_n() == 1);
   }
@@ -124,7 +123,7 @@
     kll_float_sketch sketch(200, 0);
     const uint32_t n = 200;
     for (uint32_t i = 0; i < n; i++) {
-      sketch.update(i);
+      sketch.update(static_cast<float>(i));
       REQUIRE(sketch.get_n() == i + 1);
     }
     REQUIRE_FALSE(sketch.is_empty());
@@ -144,7 +143,7 @@
 
     for (uint32_t i = 0; i < n; i++) {
       const double trueRank = (double) i / n;
-      REQUIRE(sketch.get_rank(i) == trueRank);
+      REQUIRE(sketch.get_rank(static_cast<float>(i)) == trueRank);
     }
 
     // the alternative method must produce the same result
@@ -157,16 +156,16 @@
 
   SECTION("10 items") {
     kll_float_sketch sketch(200, 0);
-    sketch.update(1);
-    sketch.update(2);
-    sketch.update(3);
-    sketch.update(4);
-    sketch.update(5);
-    sketch.update(6);
-    sketch.update(7);
-    sketch.update(8);
-    sketch.update(9);
-    sketch.update(10);
+    sketch.update(1.0f);
+    sketch.update(2.0f);
+    sketch.update(3.0f);
+    sketch.update(4.0f);
+    sketch.update(5.0f);
+    sketch.update(6.0f);
+    sketch.update(7.0f);
+    sketch.update(8.0f);
+    sketch.update(9.0f);
+    sketch.update(10.0f);
     REQUIRE(sketch.get_quantile(0) == 1.0);
     REQUIRE(sketch.get_quantile(0.5) == 6.0);
     REQUIRE(sketch.get_quantile(0.99) == 10.0);
@@ -175,7 +174,7 @@
 
   SECTION("100 items") {
     kll_float_sketch sketch(200, 0);
-    for (int i = 0; i < 100; ++i) sketch.update(i);
+    for (int i = 0; i < 100; ++i) sketch.update(static_cast<float>(i));
     REQUIRE(sketch.get_quantile(0) == 0);
     REQUIRE(sketch.get_quantile(0.01) == 1);
     REQUIRE(sketch.get_quantile(0.5) == 50);
@@ -185,9 +184,9 @@
 
   SECTION("many items, estimation mode") {
     kll_float_sketch sketch(200, 0);
-    const int n(1000000);
+    const int n = 1000000;
     for (int i = 0; i < n; i++) {
-      sketch.update(i);
+      sketch.update(static_cast<float>(i));
       REQUIRE(sketch.get_n() == static_cast<uint64_t>(i + 1));
     }
     REQUIRE_FALSE(sketch.is_empty());
@@ -200,7 +199,7 @@
     // test rank
     for (int i = 0; i < n; i++) {
       const double trueRank = (double) i / n;
-      REQUIRE(sketch.get_rank(i) == Approx(trueRank).margin(RANK_EPS_FOR_K_200));
+      REQUIRE(sketch.get_rank(static_cast<float>(i)) == Approx(trueRank).margin(RANK_EPS_FOR_K_200));
     }
 
     // test quantiles at every 0.1 percentage point
@@ -239,8 +238,8 @@
     const int n = 1000;
     float values[n];
     for (int i = 0; i < n; i++) {
-      sketch.update(i);
-      values[i] = i;
+      sketch.update(static_cast<float>(i));
+      values[i] = static_cast<float>(i);
     }
 
     const auto ranks(sketch.get_CDF(values, n));
@@ -307,7 +306,7 @@
 
   SECTION("serialize deserialize one item") {
     kll_float_sketch sketch(200, 0);
-    sketch.update(1);
+    sketch.update(1.0f);
     std::stringstream s(std::ios::in | std::ios::out | std::ios::binary);
     sketch.serialize(s);
     REQUIRE(static_cast<size_t>(s.tellp()) == sketch.get_serialized_size_bytes());
@@ -340,8 +339,8 @@
 
   SECTION("stream serialize deserialize many floats") {
     kll_float_sketch sketch(200, 0);
-    const int n(1000);
-    for (int i = 0; i < n; i++) sketch.update(i);
+    const int n = 1000;
+    for (int i = 0; i < n; i++) sketch.update(static_cast<float>(i));
     std::stringstream s(std::ios::in | std::ios::out | std::ios::binary);
     sketch.serialize(s);
     REQUIRE(static_cast<size_t>(s.tellp()) == sketch.get_serialized_size_bytes());
@@ -358,13 +357,13 @@
     REQUIRE(sketch2.get_normalized_rank_error(true) == sketch.get_normalized_rank_error(true));
     REQUIRE(sketch2.get_quantile(0.5) == sketch.get_quantile(0.5));
     REQUIRE(sketch2.get_rank(0) == sketch.get_rank(0));
-    REQUIRE(sketch2.get_rank(n) == sketch.get_rank(n));
+    REQUIRE(sketch2.get_rank(static_cast<float>(n)) == sketch.get_rank(static_cast<float>(n)));
   }
 
   SECTION("bytes serialize deserialize many floats") {
     kll_float_sketch sketch(200, 0);
-    const int n(1000);
-    for (int i = 0; i < n; i++) sketch.update(i);
+    const int n = 1000;
+    for (int i = 0; i < n; i++) sketch.update(static_cast<float>(i));
     auto bytes = sketch.serialize();
     REQUIRE(bytes.size() == sketch.get_serialized_size_bytes());
     auto sketch2 = kll_float_sketch::deserialize(bytes.data(), bytes.size(), 0);
@@ -379,7 +378,7 @@
     REQUIRE(sketch2.get_normalized_rank_error(true) == sketch.get_normalized_rank_error(true));
     REQUIRE(sketch2.get_quantile(0.5) == sketch.get_quantile(0.5));
     REQUIRE(sketch2.get_rank(0) == sketch.get_rank(0));
-    REQUIRE(sketch2.get_rank(n) == sketch.get_rank(n));
+    REQUIRE(sketch2.get_rank(static_cast<float>(n)) == sketch.get_rank(static_cast<float>(n)));
     REQUIRE_THROWS_AS(kll_sketch<int>::deserialize(bytes.data(), 7), std::out_of_range);
     REQUIRE_THROWS_AS(kll_sketch<int>::deserialize(bytes.data(), 15), std::out_of_range);
     REQUIRE_THROWS_AS(kll_sketch<int>::deserialize(bytes.data(), bytes.size() - 1), std::out_of_range);
@@ -387,7 +386,7 @@
 
   SECTION("bytes serialize deserialize many ints") {
     kll_sketch<int> sketch;
-    const int n(1000);
+    const int n = 1000;
     for (int i = 0; i < n; i++) sketch.update(i);
     auto bytes = sketch.serialize();
     REQUIRE(bytes.size() == sketch.get_serialized_size_bytes());
@@ -447,8 +446,8 @@
     kll_float_sketch sketch2(200, 0);
     const int n = 10000;
     for (int i = 0; i < n; i++) {
-      sketch1.update(i);
-      sketch2.update((2 * n) - i - 1);
+      sketch1.update(static_cast<float>(i));
+      sketch2.update(static_cast<float>((2 * n) - i - 1));
     }
 
     REQUIRE(sketch1.get_min_value() == 0.0f);
@@ -470,8 +469,8 @@
     kll_float_sketch sketch2(128, 0);
     const int n = 10000;
     for (int i = 0; i < n; i++) {
-      sketch1.update(i);
-      sketch2.update((2 * n) - i - 1);
+      sketch1.update(static_cast<float>(i));
+      sketch2.update(static_cast<float>((2 * n) - i - 1));
     }
 
     REQUIRE(sketch1.get_min_value() == 0.0f);
@@ -503,7 +502,7 @@
     kll_float_sketch sketch2(128, 0);
     const int n = 10000;
     for (int i = 0; i < n; i++) {
-      sketch1.update(i);
+      sketch1.update(static_cast<float>(i));
     }
 
     // rank error should not be affected by a merge with an empty sketch with lower k
@@ -526,8 +525,8 @@
   SECTION("merge min value from other") {
     kll_float_sketch sketch1(200, 0);
     kll_float_sketch sketch2(200, 0);
-    sketch1.update(1);
-    sketch2.update(2);
+    sketch1.update(1.0f);
+    sketch2.update(2.0f);
     sketch2.merge(sketch1);
     REQUIRE(sketch2.get_min_value() == 1.0f);
     REQUIRE(sketch2.get_max_value() == 2.0f);
@@ -535,7 +534,7 @@
 
   SECTION("merge min and max values from other") {
     kll_float_sketch sketch1(200, 0);
-    for (int i = 0; i < 1000000; i++) sketch1.update(i);
+    for (int i = 0; i < 1000000; i++) sketch1.update(static_cast<float>(i));
     kll_float_sketch sketch2(200, 0);
     sketch2.merge(sketch1);
     REQUIRE(sketch2.get_min_value() == 0.0f);
@@ -548,7 +547,7 @@
     REQUIRE_THROWS_AS(sketch.get_min_value(), std::runtime_error);
     REQUIRE_THROWS_AS(sketch.get_max_value(), std::runtime_error);
 
-    const int n(1000);
+    const int n = 1000;
     for (int i = 0; i < n; i++) sketch.update(i);
 
     std::stringstream s(std::ios::in | std::ios::out | std::ios::binary);
diff --git a/python/src/hll_wrapper.cpp b/python/src/hll_wrapper.cpp
index de00be5..0491074 100644
--- a/python/src/hll_wrapper.cpp
+++ b/python/src/hll_wrapper.cpp
@@ -56,9 +56,9 @@
     .export_values();
 
   py::class_<hll_sketch>(m, "hll_sketch")
-    .def(py::init<int>(), py::arg("lg_k"))
-    .def(py::init<int, target_hll_type>(), py::arg("lg_k"), py::arg("tgt_type"))
-    .def(py::init<int, target_hll_type, bool>(), py::arg("lg_k"), py::arg("tgt_type"), py::arg("start_max_size")=false)
+    .def(py::init<uint8_t>(), py::arg("lg_k"))
+    .def(py::init<uint8_t, target_hll_type>(), py::arg("lg_k"), py::arg("tgt_type"))
+    .def(py::init<uint8_t, target_hll_type, bool>(), py::arg("lg_k"), py::arg("tgt_type"), py::arg("start_max_size")=false)
     .def_static("deserialize", &dspy::hll_sketch_deserialize,
          "Reads a bytes object and returns the corresponding hll_sketch")
     .def("serialize_compact", &dspy::hll_sketch_serialize_compact,
@@ -104,7 +104,7 @@
     ;
 
   py::class_<hll_union>(m, "hll_union")
-    .def(py::init<int>(), py::arg("lg_max_k"))
+    .def(py::init<uint8_t>(), py::arg("lg_max_k"))
     .def_property_readonly("lg_config_k", &hll_union::get_lg_config_k, "Configured lg_k value for the union")
     .def_property_readonly("tgt_type", &hll_union::get_target_type, "Returns the HLL type (4, 6, or 8) when in estimation mode")
     .def("get_estimate", &hll_union::get_estimate,
diff --git a/python/tests/hll_test.py b/python/tests/hll_test.py
index a7c085d..9573626 100644
--- a/python/tests/hll_test.py
+++ b/python/tests/hll_test.py
@@ -58,7 +58,7 @@
         self.assertEqual(len(sk_bytes), result.get_compact_serialization_bytes())
         new_hll = hll_sketch.deserialize(sk_bytes)
 
-        # the sketch can self-report its configuation and status
+        # the sketch can self-report its configuration and status
         self.assertEqual(new_hll.lg_config_k, k)
         self.assertEqual(new_hll.tgt_type, tgt_hll_type.HLL_4)
         self.assertFalse(new_hll.is_empty())
diff --git a/python/tests/vo_test.py b/python/tests/vo_test.py
index f30e45d..1cc3e3a 100644
--- a/python/tests/vo_test.py
+++ b/python/tests/vo_test.py
@@ -46,7 +46,7 @@
     self.assertEqual(len(items), k)
 
     # we can also apply a predicate to the sketch to get an estimate
-    # (with optimially minimal variance) of the subset sum of items
+    # (with optimally minimal variance) of the subset sum of items
     # matching that predicate among the entire population
 
     # we'll use a lambda here, but any function operating on a single
@@ -89,11 +89,11 @@
     # the union and a sketch.
     print(union)
 
-    # if we want to print the list of itmes, there must be a
+    # if we want to print the list of items, there must be a
     # __str__() method for each item (which need not be the same
     # type; they're all generic python objects when used from
     # python), otherwise you may trigger an exception.
-    # to_string() is provided as a convenince to avoid direct
+    # to_string() is provided as a convenience to avoid direct
     # calls to __str__() with parameters.
     print(result.to_string(True))
 
diff --git a/req/include/req_common.hpp b/req/include/req_common.hpp
index d2dc518..0e5b87a 100755
--- a/req/include/req_common.hpp
+++ b/req/include/req_common.hpp
@@ -29,7 +29,8 @@
 namespace datasketches {
 
 // TODO: have a common random bit with KLL
-static std::independent_bits_engine<std::mt19937, 1, unsigned> req_random_bit(std::chrono::system_clock::now().time_since_epoch().count());
+static std::independent_bits_engine<std::mt19937, 1, unsigned>
+  req_random_bit(static_cast<unsigned>(std::chrono::system_clock::now().time_since_epoch().count()));
 
 namespace req_constants {
   static const uint16_t MIN_K = 4;
diff --git a/req/include/req_compactor.hpp b/req/include/req_compactor.hpp
index 2ca768b..682aa49 100755
--- a/req/include/req_compactor.hpp
+++ b/req/include/req_compactor.hpp
@@ -110,8 +110,8 @@
 
   bool ensure_enough_sections();
   std::pair<uint32_t, uint32_t> compute_compaction_range(uint32_t secs_to_compact) const;
-  void grow(size_t new_capacity);
-  void ensure_space(size_t num);
+  void grow(uint32_t new_capacity);
+  void ensure_space(uint32_t num);
 
   static uint32_t nearest_even(float value);
 
@@ -123,10 +123,10 @@
   req_compactor(bool hra, uint8_t lg_weight, bool sorted, float section_size_raw, uint8_t num_sections, uint64_t state, std::unique_ptr<T, items_deleter> items, uint32_t num_items, const Allocator& allocator);
 
   template<typename S>
-  static std::unique_ptr<T, items_deleter> deserialize_items(std::istream& is, const S& serde, const Allocator& allocator, size_t num);
+  static std::unique_ptr<T, items_deleter> deserialize_items(std::istream& is, const S& serde, const Allocator& allocator, uint32_t num);
 
   template<typename S>
-  static std::pair<std::unique_ptr<T, items_deleter>, size_t> deserialize_items(const void* bytes, size_t size, const S& serde, const Allocator& allocator, size_t num);
+  static std::pair<std::unique_ptr<T, items_deleter>, size_t> deserialize_items(const void* bytes, size_t size, const S& serde, const Allocator& allocator, uint32_t num);
 
 };
 
diff --git a/req/include/req_compactor_impl.hpp b/req/include/req_compactor_impl.hpp
index 3d5cce0..221768c 100755
--- a/req/include/req_compactor_impl.hpp
+++ b/req/include/req_compactor_impl.hpp
@@ -38,7 +38,7 @@
 hra_(hra),
 coin_(false),
 sorted_(sorted),
-section_size_raw_(section_size),
+section_size_raw_(static_cast<float>(section_size)),
 section_size_(section_size),
 num_sections_(req_constants::INIT_NUM_SECTIONS),
 state_(0),
@@ -72,9 +72,9 @@
 {
   if (other.items_ != nullptr) {
     items_ = allocator_.allocate(capacity_);
-    const size_t from = hra_ ? capacity_ - num_items_ : 0;
-    const size_t to = hra_ ? capacity_ : num_items_;
-    for (size_t i = from; i < to; ++i) new (items_ + i) T(other.items_[i]);
+    const uint32_t from = hra_ ? capacity_ - num_items_ : 0;
+    const uint32_t to = hra_ ? capacity_ : num_items_;
+    for (uint32_t i = from; i < to; ++i) new (items_ + i) T(other.items_[i]);
   }
 }
 
@@ -165,16 +165,16 @@
 template<typename FwdT>
 void req_compactor<T, C, A>::append(FwdT&& item) {
   if (num_items_ == capacity_) grow(capacity_ + get_nom_capacity());
-  const size_t i = hra_ ? capacity_ - num_items_ - 1 : num_items_;
+  const uint32_t i = hra_ ? capacity_ - num_items_ - 1 : num_items_;
   new (items_ + i) T(std::forward<FwdT>(item));
   ++num_items_;
   if (num_items_ > 1) sorted_ = false;
 }
 
 template<typename T, typename C, typename A>
-void req_compactor<T, C, A>::grow(size_t new_capacity) {
+void req_compactor<T, C, A>::grow(uint32_t new_capacity) {
   T* new_items = allocator_.allocate(new_capacity);
-  size_t new_i = hra_ ? new_capacity - num_items_ : 0;
+  uint32_t new_i = hra_ ? new_capacity - num_items_ : 0;
   for (auto it = begin(); it != end(); ++it, ++new_i) {
     new (new_items + new_i) T(std::move(*it));
     (*it).~T();
@@ -185,7 +185,7 @@
 }
 
 template<typename T, typename C, typename A>
-void req_compactor<T, C, A>::ensure_space(size_t num) {
+void req_compactor<T, C, A>::ensure_space(uint32_t num) {
   if (num_items_ + num > capacity_) grow(num_items_ + num + get_nom_capacity());
 }
 
@@ -218,13 +218,13 @@
   while (ensure_enough_sections()) {}
   ensure_space(other.get_num_items());
   sort();
-  auto middle = hra_ ? begin() : end();
+  auto offset = hra_ ? capacity_ - num_items_ : num_items_;
   auto from = hra_ ? begin() - other.get_num_items() : end();
   auto to = from + other.get_num_items();
   auto other_it = other.begin();
   for (auto it = from; it != to; ++it, ++other_it) new (it) T(conditional_forward<FwdC>(*other_it));
   if (!other.sorted_) std::sort(from, to, C());
-  if (num_items_ > 0) std::inplace_merge(hra_ ? from : begin(), middle, hra_ ? end() : to, C());
+  if (num_items_ > 0) std::inplace_merge(hra_ ? from : begin(), items_ + offset, hra_ ? end() : to, C());
   num_items_ += other.get_num_items();
 }
 
@@ -240,7 +240,7 @@
 std::pair<uint32_t, uint32_t> req_compactor<T, C, A>::compact(req_compactor& next) {
   const uint32_t starting_nom_capacity = get_nom_capacity();
   // choose a part of the buffer to compact
-  const uint32_t secs_to_compact = std::min(static_cast<uint32_t>(count_trailing_zeros_in_u32(~state_) + 1), static_cast<uint32_t>(num_sections_));
+  const uint32_t secs_to_compact = std::min<uint32_t>(count_trailing_zeros_in_u64(~state_) + 1, num_sections_);
   auto compaction_range = compute_compaction_range(secs_to_compact);
   if (compaction_range.second - compaction_range.first < 2) throw std::logic_error("compaction range error");
 
@@ -267,9 +267,9 @@
 
 template<typename T, typename C, typename A>
 bool req_compactor<T, C, A>::ensure_enough_sections() {
-  const float ssr = section_size_raw_ / sqrt(2);
+  const float ssr = section_size_raw_ / sqrtf(2);
   const uint32_t ne = nearest_even(ssr);
-  if (state_ >= static_cast<uint64_t>(1 << (num_sections_ - 1)) && ne >= req_constants::MIN_K) {
+  if (state_ >= static_cast<uint64_t>(1ULL << (num_sections_ - 1)) && ne >= req_constants::MIN_K) {
     section_size_raw_ = ssr;
     section_size_ = ne;
     num_sections_ <<= 1;
@@ -284,8 +284,8 @@
   uint32_t non_compact = get_nom_capacity() / 2 + (num_sections_ - secs_to_compact) * section_size_;
   // make compacted region even
   if (((num_items_ - non_compact) & 1) == 1) ++non_compact;
-  const size_t low = hra_ ? 0 : non_compact;
-  const size_t high = hra_ ? num_items_ - non_compact : num_items_;
+  const uint32_t low = hra_ ? 0 : non_compact;
+  const uint32_t high = hra_ ? num_items_ - non_compact : num_items_;
   return std::pair<uint32_t, uint32_t>(low, high);
 }
 
@@ -381,7 +381,7 @@
 
 template<typename T, typename C, typename A>
 template<typename S>
-auto req_compactor<T, C, A>::deserialize_items(std::istream& is, const S& serde, const A& allocator, size_t num)
+auto req_compactor<T, C, A>::deserialize_items(std::istream& is, const S& serde, const A& allocator, uint32_t num)
 -> std::unique_ptr<T, items_deleter> {
   A alloc(allocator);
   std::unique_ptr<T, items_deleter> items(alloc.allocate(num), items_deleter(allocator, false, num));
@@ -389,7 +389,7 @@
   // serde did not throw, enable destructors
   items.get_deleter().set_destroy(true);
   if (!is.good()) throw std::runtime_error("error reading from std::istream");
-  return std::move(items);
+  return items;
 }
 
 template<typename T, typename C, typename A>
@@ -430,7 +430,7 @@
 
 template<typename T, typename C, typename A>
 template<typename S>
-auto req_compactor<T, C, A>::deserialize_items(const void* bytes, size_t size, const S& serde, const A& allocator, size_t num)
+auto req_compactor<T, C, A>::deserialize_items(const void* bytes, size_t size, const S& serde, const A& allocator, uint32_t num)
 -> std::pair<std::unique_ptr<T, items_deleter>, size_t> {
   const char* ptr = static_cast<const char*>(bytes);
   const char* end_ptr = static_cast<const char*>(bytes) + size;
@@ -465,22 +465,22 @@
 template<typename T, typename C, typename A>
 class req_compactor<T, C, A>::items_deleter {
   public:
-  items_deleter(const A& allocator, bool destroy, uint32_t num): allocator(allocator), destroy(destroy), num(num) {}
+  items_deleter(const A& allocator, bool destroy, size_t num): allocator_(allocator), destroy_(destroy), num_(num) {}
   void operator() (T* ptr) {
     if (ptr != nullptr) {
-      if (destroy) {
-        for (uint32_t i = 0; i < num; ++i) {
+      if (destroy_) {
+        for (size_t i = 0; i < num_; ++i) {
           ptr[i].~T();
         }
       }
-      allocator.deallocate(ptr, num);
+      allocator_.deallocate(ptr, num_);
     }
   }
-  void set_destroy(bool destroy) { this->destroy = destroy; }
+  void set_destroy(bool destroy) { destroy_ = destroy; }
   private:
-  A allocator;
-  bool destroy;
-  uint32_t num;
+  A allocator_;
+  bool destroy_;
+  size_t num_;
 };
 
 } /* namespace datasketches */
diff --git a/req/include/req_sketch.hpp b/req/include/req_sketch.hpp
index ca806cc..779caba 100755
--- a/req/include/req_sketch.hpp
+++ b/req/include/req_sketch.hpp
@@ -319,7 +319,7 @@
 
   // for deserialization
   class item_deleter;
-  req_sketch(uint32_t k, bool hra, uint64_t n, std::unique_ptr<T, item_deleter> min_value, std::unique_ptr<T, item_deleter> max_value, std::vector<Compactor, AllocCompactor>&& compactors);
+  req_sketch(uint16_t k, bool hra, uint64_t n, std::unique_ptr<T, item_deleter> min_value, std::unique_ptr<T, item_deleter> max_value, std::vector<Compactor, AllocCompactor>&& compactors);
 
   static void check_preamble_ints(uint8_t preamble_ints, uint8_t num_levels);
   static void check_serial_version(uint8_t serial_version);
diff --git a/req/include/req_sketch_impl.hpp b/req/include/req_sketch_impl.hpp
index 3c90908..ee6d9e1 100755
--- a/req/include/req_sketch_impl.hpp
+++ b/req/include/req_sketch_impl.hpp
@@ -28,7 +28,7 @@
 template<typename T, typename C, typename S, typename A>
 req_sketch<T, C, S, A>::req_sketch(uint16_t k, bool hra, const A& allocator):
 allocator_(allocator),
-k_(std::max(static_cast<int>(k) & -2, static_cast<int>(req_constants::MIN_K))), //rounds down one if odd
+k_(std::max<uint8_t>(static_cast<int>(k) & -2, static_cast<int>(req_constants::MIN_K))), //rounds down one if odd
 hra_(hra),
 max_nom_size_(0),
 num_retained_(0),
@@ -401,7 +401,7 @@
   write(os, k_);
   const uint8_t num_levels = is_empty() ? 0 : get_num_levels();
   write(os, num_levels);
-  const uint8_t num_raw_items = raw_items ? n_ : 0;
+  const uint8_t num_raw_items = raw_items ? static_cast<uint8_t>(n_) : 0;
   write(os, num_raw_items);
   if (is_empty()) return;
   if (is_estimation_mode()) {
@@ -440,7 +440,7 @@
   ptr += copy_to_mem(k_, ptr);
   const uint8_t num_levels = is_empty() ? 0 : get_num_levels();
   ptr += copy_to_mem(num_levels, ptr);
-  const uint8_t num_raw_items = raw_items ? n_ : 0;
+  const uint8_t num_raw_items = raw_items ? static_cast<uint8_t>(n_) : 0;
   ptr += copy_to_mem(num_raw_items, ptr);
   if (!is_empty()) {
     if (is_estimation_mode()) {
@@ -620,7 +620,7 @@
 
 template<typename T, typename C, typename S, typename A>
 uint8_t req_sketch<T, C, S, A>::get_num_levels() const {
-  return compactors_.size();
+  return static_cast<uint8_t>(compactors_.size());
 }
 
 template<typename T, typename C, typename S, typename A>
@@ -711,7 +711,7 @@
 };
 
 template<typename T, typename C, typename S, typename A>
-req_sketch<T, C, S, A>::req_sketch(uint32_t k, bool hra, uint64_t n, std::unique_ptr<T, item_deleter> min_value, std::unique_ptr<T, item_deleter> max_value, std::vector<Compactor, AllocCompactor>&& compactors):
+req_sketch<T, C, S, A>::req_sketch(uint16_t k, bool hra, uint64_t n, std::unique_ptr<T, item_deleter> min_value, std::unique_ptr<T, item_deleter> max_value, std::vector<Compactor, AllocCompactor>&& compactors):
 allocator_(compactors.get_allocator()),
 k_(k),
 hra_(hra),
@@ -766,9 +766,9 @@
 
 template<typename T, typename C, typename S, typename A>
 req_sketch<T, C, S, A>::const_iterator::const_iterator(LevelsIterator begin, LevelsIterator end):
-levels_it_(begin),
-levels_end_(end),
-compactor_it_((*levels_it_).begin())
+    levels_it_(begin),
+    levels_end_(end),
+    compactor_it_(begin == end ? nullptr : (*levels_it_).begin())
 {}
 
 template<typename T, typename C, typename S, typename A>
@@ -802,7 +802,7 @@
 
 template<typename T, typename C, typename S, typename A>
 std::pair<const T&, const uint64_t> req_sketch<T, C, S, A>::const_iterator::operator*() const {
-  return std::pair<const T&, const uint64_t>(*compactor_it_, 1 << (*levels_it_).get_lg_weight());
+  return std::pair<const T&, const uint64_t>(*compactor_it_, 1ULL << (*levels_it_).get_lg_weight());
 }
 
 } /* namespace datasketches */
diff --git a/req/test/req_sketch_test.cpp b/req/test/req_sketch_test.cpp
index 0be4aa5..a301a04 100755
--- a/req/test/req_sketch_test.cpp
+++ b/req/test/req_sketch_test.cpp
@@ -55,15 +55,15 @@
 
 TEST_CASE("req sketch: single value, lra", "[req_sketch]") {
   req_sketch<float> sketch(12, false);
-  sketch.update(1);
+  sketch.update(1.0f);
   REQUIRE_FALSE(sketch.is_HRA());
   REQUIRE_FALSE(sketch.is_empty());
   REQUIRE_FALSE(sketch.is_estimation_mode());
   REQUIRE(sketch.get_n() == 1);
   REQUIRE(sketch.get_num_retained() == 1);
-  REQUIRE(sketch.get_rank(1) == 0);
-  REQUIRE(sketch.get_rank<true>(1) == 1);
-  REQUIRE(sketch.get_rank(1.1) == 1);
+  REQUIRE(sketch.get_rank(1.0f) == 0);
+  REQUIRE(sketch.get_rank<true>(1.0f) == 1);
+  REQUIRE(sketch.get_rank(1.1f) == 1);
   REQUIRE(sketch.get_rank(std::numeric_limits<float>::infinity()) == 1);
   REQUIRE(sketch.get_quantile(0) == 1);
   REQUIRE(sketch.get_quantile(0.5) == 1);
@@ -86,43 +86,43 @@
 
 TEST_CASE("req sketch: repeated values", "[req_sketch]") {
   req_sketch<float> sketch(12);
-  sketch.update(1);
-  sketch.update(1);
-  sketch.update(1);
-  sketch.update(2);
-  sketch.update(2);
-  sketch.update(2);
+  sketch.update(1.0f);
+  sketch.update(1.0f);
+  sketch.update(1.0f);
+  sketch.update(2.0f);
+  sketch.update(2.0f);
+  sketch.update(2.0f);
   REQUIRE_FALSE(sketch.is_empty());
   REQUIRE_FALSE(sketch.is_estimation_mode());
   REQUIRE(sketch.get_n() == 6);
   REQUIRE(sketch.get_num_retained() == 6);
-  REQUIRE(sketch.get_rank(1) == 0);
-  REQUIRE(sketch.get_rank<true>(1) == 0.5);
-  REQUIRE(sketch.get_rank(2) == 0.5);
-  REQUIRE(sketch.get_rank<true>(2) == 1);
+  REQUIRE(sketch.get_rank(1.0f) == 0);
+  REQUIRE(sketch.get_rank<true>(1.0f) == 0.5);
+  REQUIRE(sketch.get_rank(2.0f) == 0.5);
+  REQUIRE(sketch.get_rank<true>(2.0f) == 1);
 }
 
 TEST_CASE("req sketch: exact mode", "[req_sketch]") {
   req_sketch<float> sketch(12);
-  for (size_t i = 1; i <= 10; ++i) sketch.update(i);
+  for (size_t i = 1; i <= 10; ++i) sketch.update(static_cast<float>(i));
   REQUIRE_FALSE(sketch.is_empty());
   REQUIRE_FALSE(sketch.is_estimation_mode());
   REQUIRE(sketch.get_n() == 10);
   REQUIRE(sketch.get_num_retained() == 10);
 
   // like KLL
-  REQUIRE(sketch.get_rank(1) == 0);
-  REQUIRE(sketch.get_rank(2) == 0.1);
-  REQUIRE(sketch.get_rank(6) == 0.5);
-  REQUIRE(sketch.get_rank(9) == 0.8);
-  REQUIRE(sketch.get_rank(10) == 0.9);
+  REQUIRE(sketch.get_rank(1.0f) == 0);
+  REQUIRE(sketch.get_rank(2.0f) == 0.1);
+  REQUIRE(sketch.get_rank(6.0f) == 0.5);
+  REQUIRE(sketch.get_rank(9.0f) == 0.8);
+  REQUIRE(sketch.get_rank(10.0f) == 0.9);
 
   // inclusive
-  REQUIRE(sketch.get_rank<true>(1) == 0.1);
-  REQUIRE(sketch.get_rank<true>(2) == 0.2);
-  REQUIRE(sketch.get_rank<true>(5) == 0.5);
-  REQUIRE(sketch.get_rank<true>(9) == 0.9);
-  REQUIRE(sketch.get_rank<true>(10) == 1);
+  REQUIRE(sketch.get_rank<true>(1.0f) == 0.1);
+  REQUIRE(sketch.get_rank<true>(2.0f) == 0.2);
+  REQUIRE(sketch.get_rank<true>(5.0f) == 0.5);
+  REQUIRE(sketch.get_rank<true>(9.0f) == 0.9);
+  REQUIRE(sketch.get_rank<true>(10.0f) == 1);
 
   // like KLL
   REQUIRE(sketch.get_quantile(0) == 1);
@@ -164,16 +164,16 @@
 TEST_CASE("req sketch: estimation mode", "[req_sketch]") {
   req_sketch<float> sketch(12);
   const size_t n = 100000;
-  for (size_t i = 0; i < n; ++i) sketch.update(i);
+  for (size_t i = 0; i < n; ++i) sketch.update(static_cast<float>(i));
   REQUIRE_FALSE(sketch.is_empty());
   REQUIRE(sketch.is_estimation_mode());
   REQUIRE(sketch.get_n() == n);
 //  std::cout << sketch.to_string(true);
   REQUIRE(sketch.get_num_retained() < n);
   REQUIRE(sketch.get_rank(0) == 0);
-  REQUIRE(sketch.get_rank(n) == 1);
-  REQUIRE(sketch.get_rank(n / 2) == Approx(0.5).margin(0.01));
-  REQUIRE(sketch.get_rank(n - 1) == Approx(1).margin(0.01));
+  REQUIRE(sketch.get_rank(static_cast<float>(n)) == 1);
+  REQUIRE(sketch.get_rank(n / 2.0f) == Approx(0.5).margin(0.01));
+  REQUIRE(sketch.get_rank(n - 1.0f) == Approx(1).margin(0.01));
   REQUIRE(sketch.get_min_value() == 0);
   REQUIRE(sketch.get_max_value() == n - 1);
   REQUIRE(sketch.get_rank_lower_bound(0.5, 1) < 0.5);
@@ -219,7 +219,7 @@
 
 TEST_CASE("req sketch: stream serialize-deserialize single item", "[req_sketch]") {
   req_sketch<float> sketch(12);
-  sketch.update(1);
+  sketch.update(1.0f);
 
   std::stringstream s(std::ios::in | std::ios::out | std::ios::binary);
   sketch.serialize(s);
@@ -235,7 +235,7 @@
 
 TEST_CASE("req sketch: byte serialize-deserialize single item", "[req_sketch]") {
   req_sketch<float> sketch(12);
-  sketch.update(1);
+  sketch.update(1.0f);
 
   auto bytes = sketch.serialize();
   REQUIRE(bytes.size() == sketch.get_serialized_size_bytes());
@@ -253,7 +253,7 @@
 TEST_CASE("req sketch: stream serialize-deserialize exact mode", "[req_sketch]") {
   req_sketch<float> sketch(12);
   const size_t n = 50;
-  for (size_t i = 0; i < n; ++i) sketch.update(i);
+  for (size_t i = 0; i < n; ++i) sketch.update(static_cast<float>(i));
   REQUIRE_FALSE(sketch.is_estimation_mode());
 
   std::stringstream s(std::ios::in | std::ios::out | std::ios::binary);
@@ -271,7 +271,7 @@
 TEST_CASE("req sketch: byte serialize-deserialize exact mode", "[req_sketch]") {
   req_sketch<float> sketch(12);
   const size_t n = 50;
-  for (size_t i = 0; i < n; ++i) sketch.update(i);
+  for (size_t i = 0; i < n; ++i) sketch.update(static_cast<float>(i));
   REQUIRE_FALSE(sketch.is_estimation_mode());
 
   auto bytes = sketch.serialize();
@@ -290,7 +290,7 @@
 TEST_CASE("req sketch: stream serialize-deserialize estimation mode", "[req_sketch]") {
   req_sketch<float> sketch(12);
   const size_t n = 100000;
-  for (size_t i = 0; i < n; ++i) sketch.update(i);
+  for (size_t i = 0; i < n; ++i) sketch.update(static_cast<float>(i));
   REQUIRE(sketch.is_estimation_mode());
 
   std::stringstream s(std::ios::in | std::ios::out | std::ios::binary);
@@ -308,7 +308,7 @@
 TEST_CASE("req sketch: byte serialize-deserialize estimation mode", "[req_sketch]") {
   req_sketch<float> sketch(12);
   const size_t n = 100000;
-  for (size_t i = 0; i < n; ++i) sketch.update(i);
+  for (size_t i = 0; i < n; ++i) sketch.update(static_cast<float>(i));
   REQUIRE(sketch.is_estimation_mode());
 
   auto bytes = sketch.serialize();
@@ -326,7 +326,7 @@
 TEST_CASE("req sketch: serialize deserialize stream and bytes equivalence", "[req_sketch]") {
   req_sketch<float> sketch(12);
   const size_t n = 100000;
-  for (size_t i = 0; i < n; ++i) sketch.update(i);
+  for (size_t i = 0; i < n; ++i) sketch.update(static_cast<float>(i));
   REQUIRE(sketch.is_estimation_mode());
 
   std::stringstream s(std::ios::in | std::ios::out | std::ios::binary);
@@ -373,8 +373,8 @@
   REQUIRE(sketch.get_num_retained() == 1);
   REQUIRE(sketch.get_min_value() == 1);
   REQUIRE(sketch.get_max_value() == 1);
-  REQUIRE(sketch.get_rank(1) == 0);
-  REQUIRE(sketch.get_rank<true>(1) == 1);
+  REQUIRE(sketch.get_rank(1.0f) == 0);
+  REQUIRE(sketch.get_rank<true>(1.0f) == 1);
 }
 
 TEST_CASE("req sketch: stream deserialize from Java - raw items", "[req_sketch]") {
@@ -388,7 +388,7 @@
   REQUIRE(sketch.get_num_retained() == 4);
   REQUIRE(sketch.get_min_value() == 0);
   REQUIRE(sketch.get_max_value() == 3);
-  REQUIRE(sketch.get_rank(2) == 0.5);
+  REQUIRE(sketch.get_rank(2.0f) == 0.5);
 }
 
 TEST_CASE("req sketch: stream deserialize from Java - exact mode", "[req_sketch]") {
@@ -402,7 +402,7 @@
   REQUIRE(sketch.get_num_retained() == 100);
   REQUIRE(sketch.get_min_value() == 0);
   REQUIRE(sketch.get_max_value() == 99);
-  REQUIRE(sketch.get_rank(50) == 0.5);
+  REQUIRE(sketch.get_rank(50.0f) == 0.5);
 }
 
 TEST_CASE("req sketch: stream deserialize from Java - estimation mode", "[req_sketch]") {
@@ -416,14 +416,14 @@
   REQUIRE(sketch.get_num_retained() == 2942);
   REQUIRE(sketch.get_min_value() == 0);
   REQUIRE(sketch.get_max_value() == 9999);
-  REQUIRE(sketch.get_rank(5000) == 0.5);
+  REQUIRE(sketch.get_rank(5000.0f) == 0.5);
 }
 
 TEST_CASE("req sketch: merge into empty", "[req_sketch]") {
   req_sketch<float> sketch1(40);
 
   req_sketch<float> sketch2(40);
-  for (size_t i = 0; i < 1000; ++i) sketch2.update(i);
+  for (size_t i = 0; i < 1000; ++i) sketch2.update(static_cast<float>(i));
 
   sketch1.merge(sketch2);
   REQUIRE(sketch1.get_min_value() == 0);
@@ -431,15 +431,15 @@
   REQUIRE(sketch1.get_quantile(0.25) == Approx(250).margin(3));
   REQUIRE(sketch1.get_quantile(0.5) == Approx(500).margin(3));
   REQUIRE(sketch1.get_quantile(0.75) == Approx(750).margin(3));
-  REQUIRE(sketch1.get_rank(500) == Approx(0.5).margin(0.01));
+  REQUIRE(sketch1.get_rank(500.0f) == Approx(0.5).margin(0.01));
 }
 
 TEST_CASE("req sketch: merge", "[req_sketch]") {
   req_sketch<float> sketch1(100);
-  for (size_t i = 0; i < 1000; ++i) sketch1.update(i);
+  for (size_t i = 0; i < 1000; ++i) sketch1.update(static_cast<float>(i));
 
   req_sketch<float> sketch2(100);
-  for (size_t i = 1000; i < 2000; ++i) sketch2.update(i);
+  for (size_t i = 1000; i < 2000; ++i) sketch2.update(static_cast<float>(i));
 
   sketch1.merge(sketch2);
   REQUIRE(sketch1.get_min_value() == 0);
@@ -447,18 +447,18 @@
   REQUIRE(sketch1.get_quantile(0.25) == Approx(500).margin(3));
   REQUIRE(sketch1.get_quantile(0.5) == Approx(1000).margin(1));
   REQUIRE(sketch1.get_quantile(0.75) == Approx(1500).margin(1));
-  REQUIRE(sketch1.get_rank(1000) == Approx(0.5).margin(0.01));
+  REQUIRE(sketch1.get_rank(1000.0f) == Approx(0.5).margin(0.01));
 }
 
 TEST_CASE("req sketch: merge multiple", "[req_sketch]") {
   req_sketch<float> sketch1(12);
-  for (size_t i = 0; i < 40; ++i) sketch1.update(i);
+  for (size_t i = 0; i < 40; ++i) sketch1.update(static_cast<float>(i));
 
   req_sketch<float> sketch2(12);
-  for (size_t i = 40; i < 80; ++i) sketch2.update(i);
+  for (size_t i = 40; i < 80; ++i) sketch2.update(static_cast<float>(i));
 
   req_sketch<float> sketch3(12);
-  for (size_t i = 80; i < 120; ++i) sketch3.update(i);
+  for (size_t i = 80; i < 120; ++i) sketch3.update(static_cast<float>(i));
 
   req_sketch<float> sketch(12);
   sketch.merge(sketch1);
@@ -467,15 +467,15 @@
   REQUIRE(sketch.get_min_value() == 0);
   REQUIRE(sketch.get_max_value() == 119);
   REQUIRE(sketch.get_quantile(0.5) == Approx(60).margin(3));
-  REQUIRE(sketch.get_rank(60) == Approx(0.5).margin(0.01));
+  REQUIRE(sketch.get_rank(60.0f) == Approx(0.5).margin(0.01));
 }
 
 TEST_CASE("req sketch: merge incompatible HRA and LRA", "[req_sketch]") {
   req_sketch<float> sketch1(12);
-  sketch1.update(1);
+  sketch1.update(1.0f);
 
   req_sketch<float> sketch2(12, false);
-  sketch2.update(1);
+  sketch2.update(1.0f);
 
   REQUIRE_THROWS_AS(sketch1.merge(sketch2), std::invalid_argument);
 }
diff --git a/sampling/include/var_opt_sketch_impl.hpp b/sampling/include/var_opt_sketch_impl.hpp
index 16f8216..dbfe5a4 100644
--- a/sampling/include/var_opt_sketch_impl.hpp
+++ b/sampling/include/var_opt_sketch_impl.hpp
@@ -334,7 +334,7 @@
     num_bytes += (h_ / 8) + (h_ % 8 > 0);
   }
   // must iterate over the items
-  for (auto& it: *this)
+  for (auto it: *this)
     num_bytes += S().size_of_item(it.first);
   return num_bytes;
 }
@@ -1411,7 +1411,7 @@
   if (effective_sampling_rate < 0.0 || effective_sampling_rate > 1.0)
     throw std::logic_error("invalid sampling rate outside [0.0, 1.0]");
 
-  size_t r_true_count = 0;
+  uint32_t r_true_count = 0;
   ++idx; // skip the gap
   for (; idx < (k_ + 1); ++idx) {
     if (predicate(data_[idx])) {
diff --git a/sampling/include/var_opt_union_impl.hpp b/sampling/include/var_opt_union_impl.hpp
index 3752016..fe1ee49 100644
--- a/sampling/include/var_opt_union_impl.hpp
+++ b/sampling/include/var_opt_union_impl.hpp
@@ -30,8 +30,8 @@
 template<typename T, typename S, typename A>
 var_opt_union<T,S,A>::var_opt_union(uint32_t max_k, const A& allocator) :
   n_(0),
-  outer_tau_numer_(0),
-  outer_tau_denom_(0.0),
+  outer_tau_numer_(0.0),
+  outer_tau_denom_(0),
   max_k_(max_k),
   gadget_(max_k, var_opt_sketch<T,S,A>::DEFAULT_RESIZE_FACTOR, true, allocator)
 {}
diff --git a/sampling/test/var_opt_sketch_test.cpp b/sampling/test/var_opt_sketch_test.cpp
index c1121c5..af1cf8c 100644
--- a/sampling/test/var_opt_sketch_test.cpp
+++ b/sampling/test/var_opt_sketch_test.cpp
@@ -41,7 +41,7 @@
 static var_opt_sketch<int> create_unweighted_sketch(uint32_t k, uint64_t n) {
   var_opt_sketch<int> sk(k);
   for (uint64_t i = 0; i < n; ++i) {
-    sk.update(i, 1.0);
+    sk.update(static_cast<int>(i), 1.0);
   }
   return sk;
 }
@@ -71,7 +71,7 @@
 
 TEST_CASE("varopt sketch: invalid k", "[var_opt_sketch]") {
   REQUIRE_THROWS_AS(var_opt_sketch<int>(0), std::invalid_argument);
-  REQUIRE_THROWS_AS(var_opt_sketch<int>(1 << 31), std::invalid_argument); // aka k < 0
+  REQUIRE_THROWS_AS(var_opt_sketch<int>(1U << 31), std::invalid_argument); // aka k < 0
 }
 
 TEST_CASE("varopt sketch: bad serialization version", "[var_opt_sketch]") {
@@ -216,11 +216,11 @@
     // which covers about 10 orders of magnitude
     double w = std::exp(5 * N(rand));
     input_sum += w;
-    sk.update(i, w);
+    sk.update(static_cast<int>(i), w);
   }
 
   double output_sum = 0.0;
-  for (auto& it : sk) { // std::pair<int, weight>
+  for (auto it : sk) { // std::pair<int, weight>
     output_sum += it.second;
   }
     
@@ -350,7 +350,7 @@
   // Last one should call update_pseudo_heavy_r_eq_1(), since we'll have
   // added k-1 heavy items, leaving only 1 item left in R
   for (uint32_t i = 1; i <= k; ++i) {
-    sk.update(-i, k + (i * wt_scale));
+    sk.update(-1 * static_cast<int>(i), k + (i * wt_scale));
   }
 
   auto it = sk.begin();
@@ -442,7 +442,7 @@
   // finally, a non-degenerate predicate
   // insert negative items with identical weights, filter for negative weights only
   for (uint32_t i = 1; i <= (k + 1); ++i) {
-    sk.update(static_cast<int32_t>(-i), 1.0 * i);
+    sk.update(-1 * static_cast<int32_t>(i), static_cast<double>(i));
     total_weight += 1.0 * i;
   }
 
diff --git a/sampling/test/var_opt_union_test.cpp b/sampling/test/var_opt_union_test.cpp
index e3343d9..f9b653b 100644
--- a/sampling/test/var_opt_union_test.cpp
+++ b/sampling/test/var_opt_union_test.cpp
@@ -40,7 +40,7 @@
 
 static var_opt_sketch<int> create_unweighted_sketch(uint32_t k, uint64_t n) {
   var_opt_sketch<int> sk(k);
-  for (uint64_t i = 0; i < n; ++i) {
+  for (int i = 0; i < n; ++i) {
     sk.update(i, 1.0);
   }
   return sk;
@@ -147,7 +147,7 @@
 
 TEST_CASE("varopt union: invalid k", "[var_opt_union]") {
   REQUIRE_THROWS_AS(var_opt_union<int>(0), std::invalid_argument);
-  REQUIRE_THROWS_AS(var_opt_union<int>(1<<31), std::invalid_argument);
+  REQUIRE_THROWS_AS(var_opt_union<int>(1U << 31), std::invalid_argument);
 }
 
 TEST_CASE("varopt union: bad family", "[var_opt_union]") {
@@ -179,13 +179,13 @@
 }
 
 TEST_CASE("varopt union: two exact sketches", "[var_opt_union]") {
-  uint64_t n = 4; // 2n < k
+  int n = 4; // 2n < k
   uint32_t k = 10;
   var_opt_sketch<int> sk1(k), sk2(k);
 
-  for (uint64_t i = 1; i <= n; ++i) {
-    sk1.update(i, i);
-    sk2.update(static_cast<int64_t>(-i), i);
+  for (int i = 1; i <= n; ++i) {
+    sk1.update(i, static_cast<double>(i));
+    sk2.update(-i, static_cast<double>(i));
   }
 
   var_opt_union<int> u(k);
@@ -204,13 +204,13 @@
   uint32_t k2 = 5;
   var_opt_sketch<int64_t> sk1(k1), sk2(k2);
   for (uint64_t i = 1; i <= n1; ++i) {
-    sk1.update(i, i);
+    sk1.update(i, static_cast<double>(i));
   }
 
   for (uint64_t i = 1; i < n2; ++i) { // we'll add a very heavy one later
-    sk2.update(static_cast<int64_t>(-i), i + 1000.0);
+    sk2.update(-1 * static_cast<int64_t>(i), i + 1000.0);
   }
-  sk2.update(-n2, 1000000.0);
+  sk2.update(-1 * static_cast<int64_t>(n2), 1000000.0);
 
   var_opt_union<int64_t> u(k1);
   u.update(sk1);
@@ -258,15 +258,15 @@
   uint64_t n2 = 64;
 
   var_opt_sketch<float> sk(k_small);
-  for (uint64_t i = 0; i < n1; ++i) { sk.update(i); }
-  sk.update(-1, n1 * n1); // add a heavy item
+  for (uint64_t i = 0; i < n1; ++i) { sk.update(static_cast<float>(i)); }
+  sk.update(-1.0f, static_cast<double>(n1 * n1)); // add a heavy item
 
   var_opt_union<float> u(k_max);
   u.update(sk);
 
   // another one, but different n to get a different per-item weight
   var_opt_sketch<float> sk2(k_small);
-  for (uint64_t i = 0; i < n2; ++i) { sk2.update(i); }
+  for (uint64_t i = 0; i < n2; ++i) { sk2.update(static_cast<float>(i)); }
   u.update(sk2);
 
   // should trigger migrate_marked_items_by_decreasing_k()
diff --git a/theta/include/bounds_on_ratios_in_sampled_sets.hpp b/theta/include/bounds_on_ratios_in_sampled_sets.hpp
index e2c5433..341319a 100644
--- a/theta/include/bounds_on_ratios_in_sampled_sets.hpp
+++ b/theta/include/bounds_on_ratios_in_sampled_sets.hpp
@@ -90,7 +90,7 @@
    * @param f the inclusion probability used to produce the set with size <i>a</i>.
    * @return the approximate lower bound
    */
-  static double estimate_of_a(uint64_t a, uint64_t f) {
+  static double estimate_of_a(uint64_t a, double f) {
     check_inputs(a, 1, f);
     return a / f;
   }
diff --git a/theta/include/theta_jaccard_similarity_base.hpp b/theta/include/theta_jaccard_similarity_base.hpp
index cb18601..f6248e6 100644
--- a/theta/include/theta_jaccard_similarity_base.hpp
+++ b/theta/include/theta_jaccard_similarity_base.hpp
@@ -131,9 +131,9 @@
 
   template<typename SketchA, typename SketchB>
   static typename Union::CompactSketch compute_union(const SketchA& sketch_a, const SketchB& sketch_b) {
-    const unsigned count_a = sketch_a.get_num_retained();
-    const unsigned count_b = sketch_b.get_num_retained();
-    const unsigned lg_k = std::min(std::max(log2(ceiling_power_of_2(count_a + count_b)), theta_constants::MIN_LG_K), theta_constants::MAX_LG_K);
+    const auto count_a = sketch_a.get_num_retained();
+    const auto count_b = sketch_b.get_num_retained();
+    const uint8_t lg_k = std::min(std::max(log2(ceiling_power_of_2(count_a + count_b)), theta_constants::MIN_LG_K), theta_constants::MAX_LG_K);
     auto u = typename Union::builder().set_lg_k(lg_k).build();
     u.update(sketch_a);
     u.update(sketch_b);
diff --git a/theta/include/theta_sketch_impl.hpp b/theta/include/theta_sketch_impl.hpp
index 774f715..0653a70 100644
--- a/theta/include/theta_sketch_impl.hpp
+++ b/theta/include/theta_sketch_impl.hpp
@@ -290,7 +290,7 @@
 
 template<typename A>
 uint32_t compact_theta_sketch_alloc<A>::get_num_retained() const {
-  return entries_.size();
+  return static_cast<uint32_t>(entries_.size());
 }
 
 template<typename A>
@@ -300,22 +300,22 @@
 
 template<typename A>
 auto compact_theta_sketch_alloc<A>::begin() -> iterator {
-  return iterator(entries_.data(), entries_.size(), 0);
+  return iterator(entries_.data(), static_cast<uint32_t>(entries_.size()), 0);
 }
 
 template<typename A>
 auto compact_theta_sketch_alloc<A>::end() -> iterator {
-  return iterator(nullptr, 0, entries_.size());
+  return iterator(nullptr, 0, static_cast<uint32_t>(entries_.size()));
 }
 
 template<typename A>
 auto compact_theta_sketch_alloc<A>::begin() const -> const_iterator {
-  return const_iterator(entries_.data(), entries_.size(), 0);
+  return const_iterator(entries_.data(), static_cast<uint32_t>(entries_.size()), 0);
 }
 
 template<typename A>
 auto compact_theta_sketch_alloc<A>::end() const -> const_iterator {
-  return const_iterator(nullptr, 0, entries_.size());
+  return const_iterator(nullptr, 0, static_cast<uint32_t>(entries_.size()));
 }
 
 template<typename A>
@@ -343,7 +343,7 @@
   write(os, seed_hash);
   if (!this->is_empty()) {
     if (!is_single_item) {
-      const uint32_t num_entries = entries_.size();
+      const uint32_t num_entries = static_cast<uint32_t>(entries_.size());
       write(os, num_entries);
       const uint32_t unused32 = 0;
       write(os, unused32);
@@ -381,7 +381,7 @@
   ptr += copy_to_mem(seed_hash, ptr);
   if (!this->is_empty()) {
     if (!is_single_item) {
-      const uint32_t num_entries = entries_.size();
+      const uint32_t num_entries = static_cast<uint32_t>(entries_.size());
       ptr += copy_to_mem(num_entries, ptr);
       ptr += sizeof(uint32_t);
       if (this->is_estimation_mode()) {
diff --git a/theta/include/theta_update_sketch_base_impl.hpp b/theta/include/theta_update_sketch_base_impl.hpp
index a343c78..ce577e6 100644
--- a/theta/include/theta_update_sketch_base_impl.hpp
+++ b/theta/include/theta_update_sketch_base_impl.hpp
@@ -39,7 +39,7 @@
 entries_(nullptr)
 {
   if (lg_cur_size > 0) {
-    const size_t size = 1 << lg_cur_size;
+    const size_t size = 1ULL << lg_cur_size;
     entries_ = allocator_.allocate(size);
     for (size_t i = 0; i < size; ++i) EK()(entries_[i]) = 0;
   }
@@ -58,7 +58,7 @@
 entries_(nullptr)
 {
   if (other.entries_ != nullptr) {
-    const size_t size = 1 << lg_cur_size_;
+    const size_t size = 1ULL << lg_cur_size_;
     entries_ = allocator_.allocate(size);
     for (size_t i = 0; i < size; ++i) {
       if (EK()(other.entries_[i]) != 0) {
@@ -89,7 +89,7 @@
 theta_update_sketch_base<EN, EK, A>::~theta_update_sketch_base()
 {
   if (entries_ != nullptr) {
-    const size_t size = 1 << lg_cur_size_;
+    const size_t size = 1ULL << lg_cur_size_;
     for (size_t i = 0; i < size; ++i) {
       if (EK()(entries_[i]) != 0) entries_[i].~EN();
     }
@@ -136,7 +136,7 @@
 
 template<typename EN, typename EK, typename A>
 auto theta_update_sketch_base<EN, EK, A>::find(uint64_t key) const -> std::pair<iterator, bool> {
-  const size_t size = 1 << lg_cur_size_;
+  const size_t size = 1ULL << lg_cur_size_;
   const size_t mask = size - 1;
   const uint32_t stride = get_stride(key, lg_cur_size_);
   uint32_t index = static_cast<uint32_t>(key) & mask;
@@ -175,13 +175,13 @@
 
 template<typename EN, typename EK, typename A>
 auto theta_update_sketch_base<EN, EK, A>::end() const -> iterator {
-  return &entries_[1 << lg_cur_size_];
+  return &entries_[1ULL << lg_cur_size_];
 }
 
 template<typename EN, typename EK, typename A>
 uint32_t theta_update_sketch_base<EN, EK, A>::get_capacity(uint8_t lg_cur_size, uint8_t lg_nom_size) {
   const double fraction = (lg_cur_size <= lg_nom_size) ? RESIZE_THRESHOLD : REBUILD_THRESHOLD;
-  return std::floor(fraction * (1 << lg_cur_size));
+  return static_cast<uint32_t>(std::floor(fraction * (1 << lg_cur_size)));
 }
 
 template<typename EN, typename EK, typename A>
@@ -192,11 +192,11 @@
 
 template<typename EN, typename EK, typename A>
 void theta_update_sketch_base<EN, EK, A>::resize() {
-  const size_t old_size = 1 << lg_cur_size_;
+  const size_t old_size = 1ULL << lg_cur_size_;
   const uint8_t lg_tgt_size = lg_nom_size_ + 1;
-  const uint8_t factor = std::max(1, std::min(static_cast<int>(rf_), lg_tgt_size - lg_cur_size_));
+  const uint8_t factor = std::max<uint8_t>(1, std::min<uint8_t>(static_cast<uint8_t>(rf_), static_cast<uint8_t>(lg_tgt_size - lg_cur_size_)));
   lg_cur_size_ += factor;
-  const size_t new_size = 1 << lg_cur_size_;
+  const size_t new_size = 1ULL << lg_cur_size_;
   EN* old_entries = entries_;
   entries_ = allocator_.allocate(new_size);
   for (size_t i = 0; i < new_size; ++i) EK()(entries_[i]) = 0;
@@ -214,7 +214,7 @@
 // assumes number of entries > nominal size
 template<typename EN, typename EK, typename A>
 void theta_update_sketch_base<EN, EK, A>::rebuild() {
-  const size_t size = 1 << lg_cur_size_;
+  const size_t size = 1ULL << lg_cur_size_;
   const uint32_t nominal_size = 1 << lg_nom_size_;
 
   // empty entries have uninitialized payloads
@@ -301,7 +301,7 @@
 
 template<typename Derived, typename Allocator>
 uint64_t theta_base_builder<Derived, Allocator>::starting_theta() const {
-  if (p_ < 1) return theta_constants::MAX_THETA * p_;
+  if (p_ < 1) return static_cast<uint64_t>(theta_constants::MAX_THETA * p_);
   return theta_constants::MAX_THETA;
 }
 
diff --git a/theta/test/theta_a_not_b_test.cpp b/theta/test/theta_a_not_b_test.cpp
index 1ef5255..4e6ff26 100644
--- a/theta/test/theta_a_not_b_test.cpp
+++ b/theta/test/theta_a_not_b_test.cpp
@@ -37,7 +37,7 @@
 TEST_CASE("theta a-not-b: non empty no retained keys", "[theta_a_not_b]") {
   update_theta_sketch a = update_theta_sketch::builder().build();
   a.update(1);
-  update_theta_sketch b = update_theta_sketch::builder().set_p(0.001).build();
+  update_theta_sketch b = update_theta_sketch::builder().set_p(0.001f).build();
   theta_a_not_b a_not_b;
 
   // B is still empty
diff --git a/theta/test/theta_intersection_test.cpp b/theta/test/theta_intersection_test.cpp
index 2c8d6c0..c8fb6e6 100644
--- a/theta/test/theta_intersection_test.cpp
+++ b/theta/test/theta_intersection_test.cpp
@@ -48,7 +48,7 @@
 }
 
 TEST_CASE("theta intersection: non empty no retained keys", "[theta_intersection]") {
-  update_theta_sketch sketch = update_theta_sketch::builder().set_p(0.001).build();
+  update_theta_sketch sketch = update_theta_sketch::builder().set_p(0.001f).build();
   sketch.update(1);
   theta_intersection intersection;
   intersection.update(sketch);
diff --git a/theta/test/theta_jaccard_similarity_test.cpp b/theta/test/theta_jaccard_similarity_test.cpp
index 9354d1c..d40a0ce 100644
--- a/theta/test/theta_jaccard_similarity_test.cpp
+++ b/theta/test/theta_jaccard_similarity_test.cpp
@@ -107,7 +107,7 @@
 TEST_CASE("theta jaccard: similarity test", "[theta_sketch]") {
   const int8_t min_lg_k = 12;
   const int u1 = 1 << 20;
-  const int u2 = u1 * 0.95;
+  const int u2 = static_cast<int>(u1 * 0.95);
   const double threshold = 0.943;
 
   auto expected = update_theta_sketch::builder().set_lg_k(min_lg_k).build();
@@ -127,7 +127,7 @@
 TEST_CASE("theta jaccard: dissimilarity test", "[theta_sketch]") {
   const int8_t min_lg_k = 12;
   const int u1 = 1 << 20;
-  const int u2 = u1 * 0.05;
+  const int u2 = static_cast<int>(u1 * 0.05);
   const double threshold = 0.061;
 
   auto expected = update_theta_sketch::builder().set_lg_k(min_lg_k).build();
diff --git a/theta/test/theta_sketch_test.cpp b/theta/test/theta_sketch_test.cpp
index f817a3e..eeb2a73 100644
--- a/theta/test/theta_sketch_test.cpp
+++ b/theta/test/theta_sketch_test.cpp
@@ -50,7 +50,7 @@
 }
 
 TEST_CASE("theta sketch: non empty no retained keys", "[theta_sketch]") {
-  update_theta_sketch update_sketch = update_theta_sketch::builder().set_p(0.001).build();
+  update_theta_sketch update_sketch = update_theta_sketch::builder().set_p(0.001f).build();
   update_sketch.update(1);
   //std::cerr << update_sketch.to_string();
   REQUIRE(update_sketch.get_num_retained() == 0);
diff --git a/theta/test/theta_union_test.cpp b/theta/test/theta_union_test.cpp
index e45862d..c170457 100644
--- a/theta/test/theta_union_test.cpp
+++ b/theta/test/theta_union_test.cpp
@@ -39,7 +39,7 @@
 }
 
 TEST_CASE("theta union: non empty no retained keys", "[theta_union]") {
-  update_theta_sketch update_sketch = update_theta_sketch::builder().set_p(0.001).build();
+  update_theta_sketch update_sketch = update_theta_sketch::builder().set_p(0.001f).build();
   update_sketch.update(1);
   theta_union u = theta_union::builder().build();
   u.update(update_sketch);
diff --git a/tuple/include/array_of_doubles_sketch_impl.hpp b/tuple/include/array_of_doubles_sketch_impl.hpp
index f81e544..b494d66 100644
--- a/tuple/include/array_of_doubles_sketch_impl.hpp
+++ b/tuple/include/array_of_doubles_sketch_impl.hpp
@@ -88,7 +88,7 @@
   write(os, seed_hash);
   write(os, this->theta_);
   if (this->get_num_retained() > 0) {
-    const uint32_t num_entries = this->entries_.size();
+    const uint32_t num_entries = static_cast<uint32_t>(this->entries_.size());
     write(os, num_entries);
     const uint32_t unused32 = 0;
     write(os, unused32);
@@ -128,7 +128,7 @@
   ptr += copy_to_mem(seed_hash, ptr);
   ptr += copy_to_mem((this->theta_), ptr);
   if (this->get_num_retained() > 0) {
-    const uint32_t num_entries = this->entries_.size();
+    const uint32_t num_entries = static_cast<uint32_t>(this->entries_.size());
     ptr += copy_to_mem(num_entries, ptr);
     ptr += sizeof(uint32_t); // unused
     for (const auto& it: this->entries_) {
diff --git a/tuple/include/tuple_sketch_impl.hpp b/tuple/include/tuple_sketch_impl.hpp
index 28e26e2..1eba1e6 100644
--- a/tuple/include/tuple_sketch_impl.hpp
+++ b/tuple/include/tuple_sketch_impl.hpp
@@ -315,7 +315,7 @@
 
 template<typename S, typename A>
 uint32_t compact_tuple_sketch<S, A>::get_num_retained() const {
-  return entries_.size();
+  return static_cast<uint32_t>(entries_.size());
 }
 
 template<typename S, typename A>
@@ -367,7 +367,7 @@
   write(os, seed_hash);
   if (!this->is_empty()) {
     if (!is_single_item) {
-      const uint32_t num_entries = entries_.size();
+      const uint32_t num_entries = static_cast<uint32_t>(entries_.size());
       write(os, num_entries);
       const uint32_t unused32 = 0;
       write(os, unused32);
@@ -412,7 +412,7 @@
   ptr += copy_to_mem(seed_hash, ptr);
   if (!this->is_empty()) {
     if (!is_single_item) {
-      const uint32_t num_entries = entries_.size();
+      const uint32_t num_entries = static_cast<uint32_t>(entries_.size());
       ptr += copy_to_mem(num_entries, ptr);
       ptr += sizeof(uint32_t); // unused
       if (this->is_estimation_mode()) {
@@ -535,22 +535,22 @@
 
 template<typename S, typename A>
 auto compact_tuple_sketch<S, A>::begin() -> iterator {
-  return iterator(entries_.data(), entries_.size(), 0);
+  return iterator(entries_.data(), static_cast<uint32_t>(entries_.size()), 0);
 }
 
 template<typename S, typename A>
 auto compact_tuple_sketch<S, A>::end() -> iterator {
-  return iterator(nullptr, 0, entries_.size());
+  return iterator(nullptr, 0, static_cast<uint32_t>(entries_.size()));
 }
 
 template<typename S, typename A>
 auto compact_tuple_sketch<S, A>::begin() const -> const_iterator {
-  return const_iterator(entries_.data(), entries_.size(), 0);
+  return const_iterator(entries_.data(), static_cast<uint32_t>(entries_.size()), 0);
 }
 
 template<typename S, typename A>
 auto compact_tuple_sketch<S, A>::end() const -> const_iterator {
-  return const_iterator(nullptr, 0, entries_.size());
+  return const_iterator(nullptr, 0, static_cast<uint32_t>(entries_.size()));
 }
 
 template<typename S, typename A>
diff --git a/tuple/test/array_of_doubles_sketch_test.cpp b/tuple/test/array_of_doubles_sketch_test.cpp
index 7a5e359..d40491f 100644
--- a/tuple/test/array_of_doubles_sketch_test.cpp
+++ b/tuple/test/array_of_doubles_sketch_test.cpp
@@ -75,7 +75,7 @@
 }
 
 TEST_CASE("aod sketch: serialization compatibility with java - non-empty no entries", "[tuple_sketch]") {
-  auto update_sketch = update_array_of_doubles_sketch::builder().set_p(0.01).build();
+  auto update_sketch = update_array_of_doubles_sketch::builder().set_p(0.01f).build();
   std::vector<double> a = {1};
   update_sketch.update(1, a);
   REQUIRE_FALSE(update_sketch.is_empty());
diff --git a/tuple/test/tuple_a_not_b_test.cpp b/tuple/test/tuple_a_not_b_test.cpp
index 7c9446c..84c1881 100644
--- a/tuple/test/tuple_a_not_b_test.cpp
+++ b/tuple/test/tuple_a_not_b_test.cpp
@@ -38,8 +38,8 @@
 
 TEST_CASE("tuple a-not-b: non empty no retained keys", "[tuple_a_not_b]") {
   auto a = update_tuple_sketch<float>::builder().build();
-  a.update(1, 1);
-  auto b = update_tuple_sketch<float>::builder().set_p(0.001).build();
+  a.update(1, 1.0f);
+  auto b = update_tuple_sketch<float>::builder().set_p(0.001f).build();
   tuple_a_not_b<float> a_not_b;
 
   // B is still empty
@@ -51,7 +51,7 @@
   REQUIRE(result.get_estimate() == 1.0);
 
   // B is not empty in estimation mode and no entries
-  b.update(1, 1);
+  b.update(1, 1.0f);
   REQUIRE(b.get_num_retained() == 0);
 
   result = a_not_b.compute(a, b);
@@ -65,11 +65,11 @@
 TEST_CASE("tuple a-not-b: exact mode half overlap", "[tuple_a_not_b]") {
   auto a = update_tuple_sketch<float>::builder().build();
   int value = 0;
-  for (int i = 0; i < 1000; i++) a.update(value++, 1);
+  for (int i = 0; i < 1000; i++) a.update(value++, 1.0f);
 
   auto b = update_tuple_sketch<float>::builder().build();
   value = 500;
-  for (int i = 0; i < 1000; i++) b.update(value++, 1);
+  for (int i = 0; i < 1000; i++) b.update(value++, 1.0f);
 
   tuple_a_not_b<float> a_not_b;
 
@@ -105,7 +105,7 @@
 TEST_CASE("mixed a-not-b: exact mode half overlap", "[tuple_a_not_b]") {
   auto a = update_tuple_sketch<float>::builder().build();
   int value = 0;
-  for (int i = 0; i < 1000; i++) a.update(value++, 1);
+  for (int i = 0; i < 1000; i++) a.update(value++, 1.0f);
 
   auto b = update_theta_sketch::builder().build();
   value = 500;
@@ -145,10 +145,10 @@
 TEST_CASE("tuple a-not-b: exact mode disjoint", "[tuple_a_not_b]") {
   auto a = update_tuple_sketch<float>::builder().build();
   int value = 0;
-  for (int i = 0; i < 1000; i++) a.update(value++, 1);
+  for (int i = 0; i < 1000; i++) a.update(value++, 1.0f);
 
   auto b = update_tuple_sketch<float>::builder().build();
-  for (int i = 0; i < 1000; i++) b.update(value++, 1);
+  for (int i = 0; i < 1000; i++) b.update(value++, 1.0f);
 
   tuple_a_not_b<float> a_not_b;
 
@@ -168,7 +168,7 @@
 TEST_CASE("tuple a-not-b: exact mode full overlap", "[tuple_a_not_b]") {
   auto sketch = update_tuple_sketch<float>::builder().build();
   int value = 0;
-  for (int i = 0; i < 1000; i++) sketch.update(value++, 1);
+  for (int i = 0; i < 1000; i++) sketch.update(value++, 1.0f);
 
   tuple_a_not_b<float> a_not_b;
 
@@ -188,11 +188,11 @@
 TEST_CASE("tuple a-not-b: estimation mode half overlap", "[tuple_a_not_b]") {
   auto a = update_tuple_sketch<float>::builder().build();
   int value = 0;
-  for (int i = 0; i < 10000; i++) a.update(value++, 1);
+  for (int i = 0; i < 10000; i++) a.update(value++, 1.0f);
 
   auto b = update_tuple_sketch<float>::builder().build();
   value = 5000;
-  for (int i = 0; i < 10000; i++) b.update(value++, 1);
+  for (int i = 0; i < 10000; i++) b.update(value++, 1.0f);
 
   tuple_a_not_b<float> a_not_b;
 
@@ -212,10 +212,10 @@
 TEST_CASE("tuple a-not-b: estimation mode disjoint", "[tuple_a_not_b]") {
   auto a = update_tuple_sketch<float>::builder().build();
   int value = 0;
-  for (int i = 0; i < 10000; i++) a.update(value++, 1);
+  for (int i = 0; i < 10000; i++) a.update(value++, 1.0f);
 
   auto b = update_tuple_sketch<float>::builder().build();
-  for (int i = 0; i < 10000; i++) b.update(value++, 1);
+  for (int i = 0; i < 10000; i++) b.update(value++, 1.0f);
 
   tuple_a_not_b<float> a_not_b;
 
@@ -235,7 +235,7 @@
 TEST_CASE("tuple a-not-b: estimation mode full overlap", "[tuple_a_not_b]") {
   auto sketch = update_tuple_sketch<float>::builder().build();
   int value = 0;
-  for (int i = 0; i < 10000; i++) sketch.update(value++, 1);
+  for (int i = 0; i < 10000; i++) sketch.update(value++, 1.0f);
 
   tuple_a_not_b<float> a_not_b;
 
@@ -254,7 +254,7 @@
 
 TEST_CASE("tuple a-not-b: seed mismatch", "[tuple_a_not_b]") {
   auto sketch = update_tuple_sketch<float>::builder().build();
-  sketch.update(1, 1); // non-empty should not be ignored
+  sketch.update(1, 1.0f); // non-empty should not be ignored
   tuple_a_not_b<float> a_not_b(123);
   REQUIRE_THROWS_AS(a_not_b.compute(sketch, sketch), std::invalid_argument);
 }
@@ -262,11 +262,11 @@
 TEST_CASE("tuple a-not-b: issue #152", "[tuple_a_not_b]") {
   auto a = update_tuple_sketch<float>::builder().build();
   int value = 0;
-  for (int i = 0; i < 10000; i++) a.update(value++, 1);
+  for (int i = 0; i < 10000; i++) a.update(value++, 1.0f);
 
   auto b = update_tuple_sketch<float>::builder().build();
   value = 5000;
-  for (int i = 0; i < 25000; i++) b.update(value++, 1);
+  for (int i = 0; i < 25000; i++) b.update(value++, 1.0f);
 
   tuple_a_not_b<float> a_not_b;
 
diff --git a/tuple/test/tuple_intersection_test.cpp b/tuple/test/tuple_intersection_test.cpp
index 06ccd76..d3a26b9 100644
--- a/tuple/test/tuple_intersection_test.cpp
+++ b/tuple/test/tuple_intersection_test.cpp
@@ -59,8 +59,8 @@
 }
 
 TEST_CASE("tuple intersection: non empty no retained keys", "[tuple_intersection]") {
-  auto sketch = update_tuple_sketch<float>::builder().set_p(0.001).build();
-  sketch.update(1, 1);
+  auto sketch = update_tuple_sketch<float>::builder().set_p(0.001f).build();
+  sketch.update(1, 1.0f);
   tuple_intersection_float intersection;
   intersection.update(sketch);
   auto result = intersection.get_result();
@@ -82,11 +82,11 @@
 TEST_CASE("tuple intersection: exact mode half overlap", "[tuple_intersection]") {
   auto sketch1 = update_tuple_sketch<float>::builder().build();
   int value = 0;
-  for (int i = 0; i < 1000; i++) sketch1.update(value++, 1);
+  for (int i = 0; i < 1000; i++) sketch1.update(value++, 1.0f);
 
   auto sketch2 = update_tuple_sketch<float>::builder().build();
   value = 500;
-  for (int i = 0; i < 1000; i++) sketch2.update(value++, 1);
+  for (int i = 0; i < 1000; i++) sketch2.update(value++, 1.0f);
 
   { // unordered
     tuple_intersection_float intersection;
@@ -111,10 +111,10 @@
 TEST_CASE("tuple intersection: exact mode disjoint", "[tuple_intersection]") {
   auto sketch1 = update_tuple_sketch<float>::builder().build();
   int value = 0;
-  for (int i = 0; i < 1000; i++) sketch1.update(value++, 1);
+  for (int i = 0; i < 1000; i++) sketch1.update(value++, 1.0f);
 
   auto sketch2 = update_tuple_sketch<float>::builder().build();
-  for (int i = 0; i < 1000; i++) sketch2.update(value++, 1);
+  for (int i = 0; i < 1000; i++) sketch2.update(value++, 1.0f);
 
   { // unordered
     tuple_intersection_float intersection;
@@ -139,7 +139,7 @@
 TEST_CASE("mixed intersection: exact mode half overlap", "[tuple_intersection]") {
   auto sketch1 = update_tuple_sketch<float>::builder().build();
   int value = 0;
-  for (int i = 0; i < 1000; i++) sketch1.update(value++, 1);
+  for (int i = 0; i < 1000; i++) sketch1.update(value++, 1.0f);
 
   auto sketch2 = update_theta_sketch::builder().build();
   value = 500;
@@ -168,11 +168,11 @@
 TEST_CASE("tuple intersection: estimation mode half overlap", "[tuple_intersection]") {
   auto sketch1 = update_tuple_sketch<float>::builder().build();
   int value = 0;
-  for (int i = 0; i < 10000; i++) sketch1.update(value++, 1);
+  for (int i = 0; i < 10000; i++) sketch1.update(value++, 1.0f);
 
   auto sketch2 = update_tuple_sketch<float>::builder().build();
   value = 5000;
-  for (int i = 0; i < 10000; i++) sketch2.update(value++, 1);
+  for (int i = 0; i < 10000; i++) sketch2.update(value++, 1.0f);
 
   { // unordered
     tuple_intersection_float intersection;
@@ -197,10 +197,10 @@
 TEST_CASE("tuple intersection: estimation mode disjoint", "[tuple_intersection]") {
   auto sketch1 = update_tuple_sketch<float>::builder().build();
   int value = 0;
-  for (int i = 0; i < 10000; i++) sketch1.update(value++, 1);
+  for (int i = 0; i < 10000; i++) sketch1.update(value++, 1.0f);
 
   auto sketch2 = update_tuple_sketch<float>::builder().build();
-  for (int i = 0; i < 10000; i++) sketch2.update(value++, 1);
+  for (int i = 0; i < 10000; i++) sketch2.update(value++, 1.0f);
 
   { // unordered
     tuple_intersection_float intersection;
@@ -224,7 +224,7 @@
 
 TEST_CASE("tuple intersection: seed mismatch", "[tuple_intersection]") {
   auto sketch = update_tuple_sketch<float>::builder().build();
-  sketch.update(1, 1); // non-empty should not be ignored
+  sketch.update(1, 1.0f); // non-empty should not be ignored
   tuple_intersection_float intersection(123);
   REQUIRE_THROWS_AS(intersection.update(sketch), std::invalid_argument);
 }
diff --git a/tuple/test/tuple_jaccard_similarity_test.cpp b/tuple/test/tuple_jaccard_similarity_test.cpp
index 2b3efbb..0c957db 100644
--- a/tuple/test/tuple_jaccard_similarity_test.cpp
+++ b/tuple/test/tuple_jaccard_similarity_test.cpp
@@ -44,7 +44,7 @@
 
 TEST_CASE("tuple jaccard: same sketch exact mode", "[tuple_sketch]") {
   auto sk = update_tuple_sketch<float>::builder().build();
-  for (int i = 0; i < 1000; ++i) sk.update(i, 1);
+  for (int i = 0; i < 1000; ++i) sk.update(i, 1.0f);
 
   // update sketch
   auto jc = tuple_jaccard_similarity_float::jaccard(sk, sk);
@@ -61,8 +61,8 @@
   auto sk_a = update_tuple_sketch<float>::builder().build();
   auto sk_b = update_tuple_sketch<float>::builder().build();
   for (int i = 0; i < 1000; ++i) {
-    sk_a.update(i, 1);
-    sk_b.update(i, 1);
+    sk_a.update(i, 1.0f);
+    sk_b.update(i, 1.0f);
   }
 
   // update sketches
@@ -83,8 +83,8 @@
   auto sk_a = update_tuple_sketch<float>::builder().build();
   auto sk_b = update_tuple_sketch<float>::builder().build();
   for (int i = 0; i < 1000; ++i) {
-    sk_a.update(i, 1);
-    sk_b.update(i + 1000, 1);
+    sk_a.update(i, 1.0f);
+    sk_b.update(i + 1000, 1.0f);
   }
 
   // update sketches
diff --git a/tuple/test/tuple_sketch_allocation_test.cpp b/tuple/test/tuple_sketch_allocation_test.cpp
index a8e279a..4e834e8 100644
--- a/tuple/test/tuple_sketch_allocation_test.cpp
+++ b/tuple/test/tuple_sketch_allocation_test.cpp
@@ -64,7 +64,7 @@
     REQUIRE(count == update_sketch.get_num_retained());
 
     update_sketch.trim();
-    REQUIRE(update_sketch.get_num_retained() == (1 << update_sketch.get_lg_k()));
+    REQUIRE(update_sketch.get_num_retained() == (1U << update_sketch.get_lg_k()));
 
     auto compact_sketch = update_sketch.compact();
     REQUIRE(!compact_sketch.is_empty());
diff --git a/tuple/test/tuple_sketch_test.cpp b/tuple/test/tuple_sketch_test.cpp
index ec5d959..e6a87f1 100644
--- a/tuple/test/tuple_sketch_test.cpp
+++ b/tuple/test/tuple_sketch_test.cpp
@@ -40,7 +40,7 @@
 
 TEST_CASE("tuple sketch float: builder", "[tuple_sketch]") {
   auto builder = update_tuple_sketch<float>::builder();
-  builder.set_lg_k(10).set_p(0.5).set_resize_factor(theta_constants::resize_factor::X2).set_seed(123);
+  builder.set_lg_k(10).set_p(0.5f).set_resize_factor(theta_constants::resize_factor::X2).set_seed(123);
   auto sketch = builder.build();
   REQUIRE(sketch.get_lg_k() == 10);
   REQUIRE(sketch.get_theta() == 0.5);
@@ -74,9 +74,9 @@
 
 TEST_CASE("tuple sketch float: exact mode", "[tuple_sketch]") {
   auto update_sketch = update_tuple_sketch<float>::builder().build();
-  update_sketch.update(1, 1);
-  update_sketch.update(2, 2);
-  update_sketch.update(1, 1);
+  update_sketch.update(1, 1.0f);
+  update_sketch.update(2, 2.0f);
+  update_sketch.update(1, 1.0f);
 //  std::cout << update_sketch.to_string(true);
   REQUIRE(!update_sketch.is_empty());
   REQUIRE(!update_sketch.is_estimation_mode());
@@ -167,11 +167,11 @@
 
 TEST_CASE("tuple sketch: float, custom policy", "[tuple_sketch]") {
   auto update_sketch = max_float_update_tuple_sketch::builder(max_value_policy<float>(5)).build();
-  update_sketch.update(1, 1);
-  update_sketch.update(1, 2);
-  update_sketch.update(2, 10);
-  update_sketch.update(3, 3);
-  update_sketch.update(3, 7);
+  update_sketch.update(1, 1.0f);
+  update_sketch.update(1, 2.0f);
+  update_sketch.update(2, 10.0f);
+  update_sketch.update(3, 3.0f);
+  update_sketch.update(3, 7.0f);
 //  std::cout << update_sketch.to_string(true);
   int count = 0;
   float sum = 0;
@@ -212,37 +212,37 @@
 TEST_CASE("tuple sketch: float, update with different types of keys", "[tuple_sketch]") {
   auto sketch = update_tuple_sketch<float>::builder().build();
 
-  sketch.update(static_cast<uint64_t>(1), 1);
+  sketch.update(static_cast<uint64_t>(1), 1.0f);
   REQUIRE(sketch.get_num_retained() == 1);
 
-  sketch.update(static_cast<int64_t>(1), 1);
+  sketch.update(static_cast<int64_t>(1), 1.0f);
   REQUIRE(sketch.get_num_retained() == 1);
 
-  sketch.update(static_cast<uint32_t>(1), 1);
+  sketch.update(static_cast<uint32_t>(1), 1.0f);
   REQUIRE(sketch.get_num_retained() == 1);
 
-  sketch.update(static_cast<int32_t>(1), 1);
+  sketch.update(static_cast<int32_t>(1), 1.0f);
   REQUIRE(sketch.get_num_retained() == 1);
 
-  sketch.update(static_cast<uint16_t>(1), 1);
+  sketch.update(static_cast<uint16_t>(1), 1.0f);
   REQUIRE(sketch.get_num_retained() == 1);
 
-  sketch.update(static_cast<int16_t>(1), 1);
+  sketch.update(static_cast<int16_t>(1), 1.0f);
   REQUIRE(sketch.get_num_retained() == 1);
 
-  sketch.update(static_cast<uint8_t>(1), 1);
+  sketch.update(static_cast<uint8_t>(1), 1.0f);
   REQUIRE(sketch.get_num_retained() == 1);
 
-  sketch.update(static_cast<int8_t>(1), 1);
+  sketch.update(static_cast<int8_t>(1), 1.0f);
   REQUIRE(sketch.get_num_retained() == 1);
 
-  sketch.update(1.0, 1);
+  sketch.update(1.0, 1.0f);
   REQUIRE(sketch.get_num_retained() == 2);
 
-  sketch.update(static_cast<float>(1), 1);
+  sketch.update(static_cast<float>(1), 1.0f);
   REQUIRE(sketch.get_num_retained() == 2);
 
-  sketch.update("a", 1);
+  sketch.update("a", 1.0f);
   REQUIRE(sketch.get_num_retained() == 3);
 }
 
diff --git a/tuple/test/tuple_union_test.cpp b/tuple/test/tuple_union_test.cpp
index 4088fa2..10c9a25 100644
--- a/tuple/test/tuple_union_test.cpp
+++ b/tuple/test/tuple_union_test.cpp
@@ -51,9 +51,9 @@
 }
 
 TEST_CASE("tuple_union float: non-empty no retained entries", "[tuple union]") {
-  auto update_sketch = update_tuple_sketch<float>::builder().set_p(0.001).build();
+  auto update_sketch = update_tuple_sketch<float>::builder().set_p(0.001f).build();
 //  std::cout << update_sketch.to_string();
-  update_sketch.update(1, 1);
+  update_sketch.update(1, 1.0f);
   REQUIRE(!update_sketch.is_empty());
   REQUIRE(update_sketch.get_num_retained() == 0);
   auto u = tuple_union<float>::builder().build();
@@ -69,12 +69,12 @@
 
 TEST_CASE("tuple_union float: simple case", "[tuple union]") {
   auto update_sketch1 = update_tuple_sketch<float>::builder().build();
-  update_sketch1.update(1, 1);
-  update_sketch1.update(2, 1);
+  update_sketch1.update(1, 1.0f);
+  update_sketch1.update(2, 1.0f);
 
   auto update_sketch2 = update_tuple_sketch<float>::builder().build();
-  update_sketch2.update(1, 1);
-  update_sketch2.update(3, 1);
+  update_sketch2.update(1, 1.0f);
+  update_sketch2.update(3, 1.0f);
 
   auto u = tuple_union<float>::builder().build();
   u.update(update_sketch1);
@@ -86,11 +86,11 @@
 TEST_CASE("tuple_union float: exact mode half overlap", "[tuple union]") {
   auto update_sketch1 = update_tuple_sketch<float>::builder().build();
   int value = 0;
-  for (int i = 0; i < 1000; ++i) update_sketch1.update(value++, 1);
+  for (int i = 0; i < 1000; ++i) update_sketch1.update(value++, 1.0f);
 
   auto update_sketch2 = update_tuple_sketch<float>::builder().build();
   value = 500;
-  for (int i = 0; i < 1000; ++i) update_sketch2.update(value++, 1);
+  for (int i = 0; i < 1000; ++i) update_sketch2.update(value++, 1.0f);
 
   { // unordered
     auto u = tuple_union<float>::builder().build();
@@ -115,11 +115,11 @@
 TEST_CASE("tuple_union float: estimation mode half overlap", "[tuple union]") {
   auto update_sketch1 = update_tuple_sketch<float>::builder().build();
   int value = 0;
-  for (int i = 0; i < 10000; ++i) update_sketch1.update(value++, 1);
+  for (int i = 0; i < 10000; ++i) update_sketch1.update(value++, 1.0f);
 
   auto update_sketch2 = update_tuple_sketch<float>::builder().build();
   value = 5000;
-  for (int i = 0; i < 10000; ++i) update_sketch2.update(value++, 1);
+  for (int i = 0; i < 10000; ++i) update_sketch2.update(value++, 1.0f);
 
   { // unordered
     auto u = tuple_union<float>::builder().build();
@@ -143,7 +143,7 @@
 
 TEST_CASE("tuple_union float: seed mismatch", "[tuple union]") {
   auto update_sketch = update_tuple_sketch<float>::builder().build();
-  update_sketch.update(1, 1); // non-empty should not be ignored
+  update_sketch.update(1, 1.0f); // non-empty should not be ignored
 
   auto u = tuple_union<float>::builder().set_seed(123).build();
   REQUIRE_THROWS_AS(u.update(update_sketch), std::invalid_argument);
@@ -154,7 +154,7 @@
 
   // tuple update
   auto update_tuple = update_tuple_sketch<float>::builder().build();
-  for (unsigned i = 0; i < 10; ++i) update_tuple.update(i, 1);
+  for (unsigned i = 0; i < 10; ++i) update_tuple.update(i, 1.0f);
   u.update(update_tuple);
 
   // tuple compact