[sr-dev] git:3.1: modules_k/dialog: Simplify and refactor parts of reference counter