diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c
index d05be5de5d367b75726ce761ce0e3a1c6afbf72c..c3b547dd5b7fe311048e08e6c42b017ca63d597c 100644
--- a/src/backend/parser/analyze.c
+++ b/src/backend/parser/analyze.c
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- *	$PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.311 2004/08/29 05:06:44 momjian Exp $
+ *	$PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.312 2004/09/27 04:12:02 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -2273,25 +2273,21 @@ getSetColTypes(ParseState *pstate, Node *node)
 static void
 applyColumnNames(List *dst, List *src)
 {
-	ListCell   *dst_item = list_head(dst);
-	ListCell   *src_item = list_head(src);
+	ListCell   *dst_item;
+	ListCell   *src_item;
 
 	if (list_length(src) > list_length(dst))
 		ereport(ERROR,
 				(errcode(ERRCODE_SYNTAX_ERROR),
 			 errmsg("CREATE TABLE AS specifies too many column names")));
 
-	while (src_item != NULL && dst_item != NULL)
+	forboth(dst_item, dst, src_item, src)
 	{
 		TargetEntry *d = (TargetEntry *) lfirst(dst_item);
 		ColumnDef  *s = (ColumnDef *) lfirst(src_item);
 
 		Assert(d->resdom && !d->resdom->resjunk);
-
 		d->resdom->resname = pstrdup(s->colname);
-
-		dst_item = lnext(dst_item);
-		src_item = lnext(src_item);
 	}
 }
 
diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c
index b66007c069379a414eba65d8f74a4c8dfe9ca262..0a11411e9a90137b9cb728c207cb7cd6939cc15e 100644
--- a/src/backend/utils/cache/catcache.c
+++ b/src/backend/utils/cache/catcache.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/utils/cache/catcache.c,v 1.116 2004/08/29 05:06:50 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/backend/utils/cache/catcache.c,v 1.117 2004/09/27 04:12:02 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1501,7 +1501,7 @@ SearchCatCacheList(CatCache *cache,
 		 * worth fixing.
 		 */
 		ct->refcount++;
-		ctlist = lcons(ct, ctlist);
+		ctlist = lappend(ctlist, ct);
 		nmembers++;
 	}
 
@@ -1522,16 +1522,17 @@ SearchCatCacheList(CatCache *cache,
 
 	cl->cl_magic = CL_MAGIC;
 	cl->my_cache = cache;
-	DLInitElem(&cl->cache_elem, (void *) cl);
+	DLInitElem(&cl->cache_elem, cl);
 	cl->refcount = 0;			/* for the moment */
 	cl->dead = false;
 	cl->ordered = ordered;
 	cl->nkeys = nkeys;
 	cl->hash_value = lHashValue;
 	cl->n_members = nmembers;
-	/* The list is backwards because we built it with lcons */
+
+	Assert(nmembers == list_length(ctlist));
 	ctlist_item = list_head(ctlist);
-	for (i = nmembers; --i >= 0;)
+	for (i = 0; i < nmembers; i++)
 	{
 		cl->members[i] = ct = (CatCTup *) lfirst(ctlist_item);
 		Assert(ct->c_list == NULL);
diff --git a/src/include/nodes/pg_list.h b/src/include/nodes/pg_list.h
index c35e7c64ba1d338e5555506711051aee59275ffc..d8957b35223cf671233919d341d6e72fa33ac0fc 100644
--- a/src/include/nodes/pg_list.h
+++ b/src/include/nodes/pg_list.h
@@ -30,7 +30,7 @@
  * Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/nodes/pg_list.h,v 1.49 2004/08/29 05:06:57 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/pg_list.h,v 1.50 2004/09/27 04:12:03 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -167,8 +167,8 @@ extern int	list_length(List *l);
  *	  a convenience macro which loops through a list starting from a
  *	  specified cell
  */
-#define for_each_cell(cell, l)	\
-	for ((cell) = (l); (cell) != NULL; (cell) = lnext(cell))
+#define for_each_cell(cell, initcell)	\
+	for ((cell) = (initcell); (cell) != NULL; (cell) = lnext(cell))
 
 /*
  * forboth -