diff --git a/nodequeue_reference.module b/nodequeue_reference.module
index 275a4c6..5d74ccd 100644
--- a/nodequeue_reference.module
+++ b/nodequeue_reference.module
@@ -17,13 +17,15 @@ function nodequeue_reference_menu() {
     'type' => MENU_CALLBACK,
   );
 
-  $items['nodequeue-reference/dialog/redirect'] = array(
-    'page callback' => 'nodequeue_reference_dialog_redirect_page',
-    'page arguments' => array(3),
-    'access callback' => TRUE,
-    'file' => 'includes/nodequeue_reference.dialog_pages.inc',
-    'type' => MENU_CALLBACK
-  );
+  if (module_exists('references_dialog')) {
+    $items['nodequeue-reference/dialog/redirect'] = array(
+      'page callback' => 'nodequeue_reference_dialog_redirect_page',
+      'page arguments' => array(3),
+      'access callback' => TRUE,
+      'file' => 'includes/nodequeue_reference.dialog_pages.inc',
+      'type' => MENU_CALLBACK
+    );
+  }
 
   return $items;
 }
@@ -39,9 +41,12 @@ function nodequeue_reference_form_nodequeue_edit_queue_form_alter(&$form, &$form
 
 /**
  * Submit callback for closing the dialog tab.
+ *
  * If creating a new Nodequeue, we will be directed to the callback for modifing the nodequeue nodes.
  * The menu callback will output javascript that will close the dialog, and pass paramenters to the main window.
  * Note that the field value will be overriden in the end.
+ *
+ * Only used when References_Dialog module is installed.
  */
 function nodequeue_reference_nodequeue_edit_submit($form, &$form_state) {
   $qid = $form_state['values']['qid'];
@@ -65,13 +70,18 @@ function nodequeue_reference_nodequeue_edit_submit($form, &$form_state) {
  * Implements hook_form_FORM_ID_alter().
  */
 function nodequeue_reference_form_nodequeue_arrange_subqueue_form_alter(&$form, &$form_state, $form_id) {
-  $form['actions']['submit']['#submit'][] = 'nodequeue_reference_nodequeue_view_submit';
+  if (module_exists('references_dialog') && references_dialog_in_dialog() && references_dialog_close_on_submit()) {
+    $form['actions']['submit']['#submit'][] = 'nodequeue_reference_nodequeue_view_submit';
+  }
 }
 
 /**
- * Submit callback for modifying nodequeue nodes from the dialog
+ * Submit callback for modifying nodequeue nodes from the dialog.
+ *
  * The menu callback will output javascript that will close the dialog, and pass paramenters to the main window.
  * Note that the field value will be overriden in the end.
+ *
+ * Only used when References_Dialog module is installed.
  */
 function nodequeue_reference_nodequeue_view_submit($form, &$form_state) {
   if (references_dialog_in_dialog() && references_dialog_close_on_submit()) {
@@ -411,4 +421,4 @@ function nodequeue_reference_autocomplete($entity_type, $bundle, $field_name, $s
   }
 
   drupal_json_output($matches);
-}
\ No newline at end of file
+}
