Removed some leaks and optimized some algorithms to use constant time populations that the compiler can unroll rather than variable-time or unrollable loops