distributed histogram creation + other optimizations