The only difference between this and the previous version is in if statement in sync histograms, which makes significant difference in output.
@caforio