// default render function and extension.
    $render_function = 'theme_render_template';
    $extension = '.tpl.php';
    $variables_cue = array();

    // Run through the theme engine variables, if necessary
    global $theme_engine;
    if (isset($theme_engine)) {
      // Call each of our variable override functions. We allow
      // several to create cleaner code.
      $variables_cue[] = '_'. $theme_engine .'_variables';
      $variables_cue[] = $theme_engine .'_variables';
      $variables_cue[] = '_'. $theme_engine .'_variables_'. $hook;
      $variables_cue[] = $theme_engine .'_variables_'. $hook;

      if ($info['type'] != 'module' && function_exists($theme_engine .'_render_template')) {
        $render_function = $theme_engine .'_render_template';
      }
      
      // Override the variable functions cue.
      $var_functions_cue = $theme_engine .'_var_functions_que';
      if (function_exists($var_functions_cue)) {
        $variables_cue = $var_functions_cue($variables_cue, $info);
      }
    }

    // Add theme specific variable substitution:
    global $theme;
    $variables_cue[] = $theme .'_variables';
    $variables_cue[] = $theme .'_variables_'. $hook;

    $args = array(&$variables, $hook);
    foreach ($variables_cue as $variables_function) {
      if (function_exists($variables_function)) {
        call_user_func_array($variables_function, $args);
      }
    }
    
    // Check for extension and render override.
    if (isset($variables['extension'])) {
      $extension = $variables['extension'];
    }
    if (isset($variables['render'])) {
      $render_function = $variables['render'];
    }