bugfixes write_hist