Fix histogram calculation. Fix I/O test.