diff --git a/pift.cron.inc b/pift.cron.inc
index c8f24f7..9032a1b 100644
--- a/pift.cron.inc
+++ b/pift.cron.inc
@@ -25,6 +25,7 @@ function pift_cron_retest() {
 
     // Loop over 'ON' clause to remove an 'OR' which should be more efficient.
     foreach (array('u.nid = pi.nid', 'cu.nid = pi.nid') as $clause) {
+      // TODO:  UPDATE THIS QUERY (Upload table doesn't exist anymore)
       db_query("UPDATE {pift_test}
                 SET status = :status
                 WHERE type = :type
@@ -189,28 +190,40 @@ function pift_cron_queue_batch_build() {
  */
 function pift_cron_queue_batch_build_files(array &$batch, array &$branches) {
   // Load all files that are marked as needs testing or have never been tested.
-  $result = db_query('SELECT f.fid, f.filepath, u.nid AS u_nid, cu.nid AS c_nid, cu.cid AS c_cid
-                      FROM {pift_test} t
-                      JOIN {files} f
-                        ON (t.type = :type AND t.id = f.fid)
-                      LEFT JOIN {upload} u
-                        ON f.fid = u.fid
-                      LEFT JOIN {comment_upload} cu
-                        ON f.fid = cu.fid
-                      WHERE t.status = :status
-                      LIMIT :limit', array(':type' => PIFT_TYPE_FILE, ':status' => PIFT_STATUS_QUEUE, ':limit' => PIFT_XMLRPC_MAX), array('fetch' => PDO::FETCH_ASSOC));
+  // TODO:  I'm assuming that all files end up in the file_managed table, and
+  // all comment uploads end up in the field_issue_files field ... will need to
+  // verify this assumption.
+  $result = db_query(
+    'SELECT f.fid AS fid, f.uri AS uri, fd.entity_id AS entity_id
+    FROM {pift_test} t
+    INNER JOIN {file_managed} f ON t.id = f.fid
+    INNER JOIN {field_data_field_issue_files} fd
+      ON f.fid = fd.field_issue_files_fid
+    WHERE (t.type = :type) AND (t.status = :status)
+    LIMIT :limit',
+    array(
+      ':type' => PIFT_TYPE_FILE,
+      ':status' => PIFT_STATUS_QUEUE,
+      ':limit' => PIFT_XMLRPC_MAX
+    ),
+    array('fetch' => PDO::FETCH_ASSOC)
+  );
+
   foreach ($result as $file) {
     // Load the issue related to the file, either from the comment or node.
-    $issue_nid = !empty($file['u_nid']) ? $file['u_nid'] : $file['c_nid'];
+    $issue_nid = $file['entity_id'];
     $item = array(
       'client_identifier' => $file['fid'],
-      'file_url' => file_create_url($file['filepath']),
+      'file_url' => file_create_url($file['uri']),
     );
 
-
-    $branch_info_result = db_query('SELECT prn.nid AS rid, prn.version_major, prn.tag
-                             FROM {project_issues} pi, {project_release_nodes} prn
-                             WHERE pi.nid = :nid AND pi.rid = :rid', array(':nid' => $issue_nid, ':rid' => prn . nid), array('fetch' => PDO::FETCH_ASSOC));
+    $branch_info_result = db_query(
+      'SELECT prn.nid AS rid, prn.version_major, prn.tag
+      FROM {project_issues} pi, {project_release_nodes} prn
+      WHERE pi.nid = :nid AND pi.rid = :rid',
+      array(':nid' => $issue_nid, ':rid' => prn . nid),
+      array('fetch' => PDO::FETCH_ASSOC)
+    );
 
     $item['branch_identifier'] = $branch_info_result['rid'];
     // Store branch as needed to be included with data.
@@ -242,11 +255,18 @@ function pift_cron_queue_batch_build_files(array &$batch, array &$branches) {
  */
 function pift_cron_queue_batch_build_branches(array &$branches) {
   // Load the branches that are marked as needs testing or have never been tested.
-  $result = db_query('SELECT t.id AS rid
-                      FROM {pift_test} t
-                      WHERE t.type = :type
-                      AND t.status = :status
-                      LIMIT :limit', array(':type' => PIFT_TYPE_RELEASE, ':status' => PIFT_STATUS_QUEUE, ':limit' => PIFT_XMLRPC_MAX), array('fetch' => PDO::FETCH_ASSOC));
+  $result = db_query(
+    'SELECT t.id AS rid
+    FROM {pift_test} t
+    WHERE t.type = :type AND t.status = :status
+    LIMIT :limit',
+    array(
+      ':type' => PIFT_TYPE_RELEASE,
+      ':status' => PIFT_STATUS_QUEUE,
+      ':limit' => PIFT_XMLRPC_MAX
+    ),
+    array('fetch' => PDO::FETCH_ASSOC)
+  );
   foreach ($result as $branch) {
     $branches[$branch['rid']] = TRUE;
   }
@@ -455,33 +475,22 @@ function pift_cron_check_auto_followup(array $result) {
     $test = pift_test_get($result['test_id']);
     if ($test['fid']) {
       // Get the current issue state and ensure that the test is the last one
-      // for the particular issue. Cycle through clauses to remove the need for
-      // an OR clause and thus improve performance.
+      // for the particular issue.
       $results = array();
-      foreach (array('u.nid = i.nid', 'cu.nid = i.nid') as $clause) {
-        $result = db_query('SELECT t.test_id, t.id
-                            FROM {pift_test} t
-                            LEFT JOIN {upload} u
-                              ON (t.type = :type AND t.id = u.fid)
-                            LEFT JOIN {comment_upload} cu
-                              ON (t.type = :type AND t.id = cu.fid)
-                            JOIN {project_issues} i
-                              ON ' . $clause . '
-                            WHERE u.nid = :nid OR cu.nid = :nid
-                            ORDER BY t.id DESC
-                            LIMIT 1',
-                            array(
-                              ':type' => PIFT_TYPE_FILE,
-                              ':nid' => $test['nid'],
-                            ), array('fetch' => PDO::FETCH_ASSOC));
-        $results[] = $result;
-      }
-
-      // To simulate OR clause and descending order by 'id' select the test_id
-      // that has the highest 'id' value.
-      $test_id = $results[0]['id'] > $results[1]['id'] ? $results[0]['test_id'] : $results[1]['test_id'];
-
-      if ($test_id == $test['test_id'] && pift_test_check_criteria_issue(node_load($test['nid']))) {
+      // TODO: Convert to static query - but I had all sorts of 'no parameters
+      // were bound' PDO exceptions when trying to use db_query, so stuck with
+      // the db_select() version.
+      $query = db_select('pift_test', 't', array('fetch' => PDO::FETCH_ASSOC))
+        ->fields('t', array('test_id', 'id'))
+        ->condition('t.type', PIFT_TYPE_FILE, '=');
+      $query->leftJoin('field_data_field_issue_files', 'fd', 't.id = fd.field_issue_files_fid');
+      $query->join('project_issues', 'i', 'fd.entity_id = i.nid');
+      $query->condition('fd.entity_id', $test['nid'], '=');
+      $query->orderBy('t.id', 'DESC')
+        ->range(0,1);
+      $result = $query->execute()->fetchField();
+
+      if ($result == $test['test_id'] && pift_test_check_criteria_issue(node_load($test['nid']))) {
         // Test is last one for the particular issue and still fits the criteria.
         pift_cron_auto_followup($test['nid'], $test['cid'], $test['filename']);
       }
@@ -497,6 +506,8 @@ function pift_cron_check_auto_followup(array $result) {
  * @param string $filename Name of file.
  */
 function pift_cron_auto_followup($nid, $cid, $filename) {
+  // TODO:  Update this function (project_issue_add_auto_followup() no longer
+  // exists in the project_issue project.
   project_issue_add_auto_followup(array(
     'nid' => $nid,
     'sid' => PIFT_FOLLOWUP_FAIL,
