Not expert enough in pub/sub to tell whether these are sufficient, but perhaps these two functions could be folded into built-ins?