Improvements to histogram bin count selection. See #343