More or less finished cleanup of traverse.c (150 lines less)