diff --git a/include/asterisk/astobj2.h b/include/asterisk/astobj2.h
index 81d074e1409f4475d9ccc5801441793e008c1f13..3a6a1fb818758198344cd73309fb4482d26a726a 100644
--- a/include/asterisk/astobj2.h
+++ b/include/asterisk/astobj2.h
@@ -625,11 +625,20 @@ struct ao2_global_obj {
  *
  * \return Nothing
  */
+#ifdef REF_DEBUG
 #define ao2_t_global_obj_release(holder, tag)	\
 	__ao2_global_obj_release(&holder, (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
 #define ao2_global_obj_release(holder)	\
 	__ao2_global_obj_release(&holder, "", __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
 
+#else
+
+#define ao2_t_global_obj_release(holder, tag)	\
+	__ao2_global_obj_release(&holder, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
+#define ao2_global_obj_release(holder)	\
+	__ao2_global_obj_release(&holder, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
+#endif
+
 void __ao2_global_obj_release(struct ao2_global_obj *holder, const char *tag, const char *file, int line, const char *func, const char *name);
 
 /*!
@@ -647,11 +656,20 @@ void __ao2_global_obj_release(struct ao2_global_obj *holder, const char *tag, co
  * \retval Reference to previous global ao2 object stored.
  * \retval NULL if no object available.
  */
+#ifdef REF_DEBUG
 #define ao2_t_global_obj_replace(holder, obj, tag)	\
 	__ao2_global_obj_replace(&holder, (obj), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
 #define ao2_global_obj_replace(holder, obj)	\
 	__ao2_global_obj_replace(&holder, (obj), "", __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
 
+#else
+
+#define ao2_t_global_obj_replace(holder, obj, tag)	\
+	__ao2_global_obj_replace(&holder, (obj), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
+#define ao2_global_obj_replace(holder, obj)	\
+	__ao2_global_obj_replace(&holder, (obj), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
+#endif
+
 void *__ao2_global_obj_replace(struct ao2_global_obj *holder, void *obj, const char *tag, const char *file, int line, const char *func, const char *name);
 
 /*!
@@ -670,10 +688,20 @@ void *__ao2_global_obj_replace(struct ao2_global_obj *holder, void *obj, const c
  * \retval 0 The global object was previously empty
  * \retval 1 The global object was not previously empty
  */
+#ifdef REF_DEBUG
 #define ao2_t_global_obj_replace_unref(holder, obj, tag)	\
 	__ao2_global_obj_replace_unref(&holder, (obj), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
 #define ao2_global_obj_replace_unref(holder, obj)	\
 	__ao2_global_obj_replace_unref(&holder, (obj), "", __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
+
+#else
+
+#define ao2_t_global_obj_replace_unref(holder, obj, tag)	\
+	__ao2_global_obj_replace_unref(&holder, (obj), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
+#define ao2_global_obj_replace_unref(holder, obj)	\
+	__ao2_global_obj_replace_unref(&holder, (obj), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
+#endif
+
 int __ao2_global_obj_replace_unref(struct ao2_global_obj *holder, void *obj, const char *tag, const char *file, int line, const char *func, const char *name);
 
 /*!
@@ -686,11 +714,20 @@ int __ao2_global_obj_replace_unref(struct ao2_global_obj *holder, void *obj, con
  * \retval Reference to current ao2 object stored in the holder.
  * \retval NULL if no object available.
  */
+#ifdef REF_DEBUG
 #define ao2_t_global_obj_ref(holder, tag)	\
 	__ao2_global_obj_ref(&holder, (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
 #define ao2_global_obj_ref(holder)	\
 	__ao2_global_obj_ref(&holder, "", __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
 
+#else
+
+#define ao2_t_global_obj_ref(holder, tag)	\
+	__ao2_global_obj_ref(&holder, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
+#define ao2_global_obj_ref(holder)	\
+	__ao2_global_obj_ref(&holder, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder)
+#endif
+
 void *__ao2_global_obj_ref(struct ao2_global_obj *holder, const char *tag, const char *file, int line, const char *func, const char *name);
 
 
diff --git a/main/astobj2.c b/main/astobj2.c
index f3fe7c6bdf59c1a21b9645c8e727abbac80d1404..745f1c941fad68dd5a8e2b49111a401a0b544469 100644
--- a/main/astobj2.c
+++ b/main/astobj2.c
@@ -656,7 +656,11 @@ void __ao2_global_obj_release(struct ao2_global_obj *holder, const char *tag, co
 
 	/* Release the held ao2 object. */
 	if (holder->obj) {
-		__ao2_ref_debug(holder->obj, -1, tag, file, line, func);
+		if (tag) {
+			__ao2_ref_debug(holder->obj, -1, tag, file, line, func);
+		} else {
+			__ao2_ref(holder->obj, -1);
+		}
 		holder->obj = NULL;
 	}
 
@@ -678,7 +682,11 @@ void *__ao2_global_obj_replace(struct ao2_global_obj *holder, void *obj, const c
 	}
 
 	if (obj) {
-		__ao2_ref_debug(obj, +1, tag, file, line, func);
+		if (tag) {
+			__ao2_ref_debug(obj, +1, tag, file, line, func);
+		} else {
+			__ao2_ref(obj, +1);
+		}
 	}
 	obj_old = holder->obj;
 	holder->obj = obj;
@@ -694,7 +702,11 @@ int __ao2_global_obj_replace_unref(struct ao2_global_obj *holder, void *obj, con
 
 	obj_old = __ao2_global_obj_replace(holder, obj, tag, file, line, func, name);
 	if (obj_old) {
-		__ao2_ref_debug(obj_old, -1, tag, file, line, func);
+		if (tag) {
+			__ao2_ref_debug(obj_old, -1, tag, file, line, func);
+		} else {
+			__ao2_ref(obj_old, -1);
+		}
 		return 1;
 	}
 	return 0;
@@ -717,7 +729,11 @@ void *__ao2_global_obj_ref(struct ao2_global_obj *holder, const char *tag, const
 
 	obj = holder->obj;
 	if (obj) {
-		__ao2_ref_debug(obj, +1, tag, file, line, func);
+		if (tag) {
+			__ao2_ref_debug(obj, +1, tag, file, line, func);
+		} else {
+			__ao2_ref(obj, +1);
+		}
 	}
 
 	__ast_rwlock_unlock(file, line, func, &holder->lock, name);