fix bug with dependants being unregistered more than once in certain edge cases (see #271)