More cohesion
Check nsamples is power of two
Big structure refctoring