rework walk, fix bug in dict_invert