Fix issue with empty histograms (partially).
Create histograms in a separate function.
Merge pull request #4 from vadler/master

Histograms