Use reference counting instead of zval duplication