Add a refcount mechanism for substatements