Make histogram setup code more robust.