finish discretizer / restore_levels combo and unit tests