From 96a2b1c77947120e52f01971109b13d0c6f750a2 Mon Sep 17 00:00:00 2001
From: Enno Rehling <enno@eressea.de>
Date: Wed, 20 Jun 2007 00:34:02 +0000
Subject: [PATCH] Include cleanup.

---
 src/common/attributes/alliance.c      |   2 +-
 src/common/attributes/follow.c        |   3 +-
 src/common/attributes/hate.c          |   7 +-
 src/common/attributes/moved.h         |   2 +-
 src/common/attributes/movement.c      |   5 +-
 src/common/attributes/movement.h      |   2 +-
 src/common/attributes/object.h        |   2 +-
 src/common/attributes/overrideroads.c |   4 +-
 src/common/attributes/targetregion.c  |   2 +-
 src/common/gamecode/archetype.c       |   1 +
 src/common/gamecode/creation.c        |   1 +
 src/common/gamecode/creport.c         |  11 +-
 src/common/gamecode/economy.c         |  45 +-
 src/common/gamecode/economy.h         |   2 +-
 src/common/gamecode/give.c            |   1 +
 src/common/gamecode/laws.c            |  32 +-
 src/common/gamecode/laws.h            |   2 +-
 src/common/gamecode/monster.c         |  15 +-
 src/common/gamecode/randenc.c         |  54 +-
 src/common/gamecode/report.c          |  26 +-
 src/common/gamecode/study.c           |  10 +-
 src/common/iniparser/iniparser.c      |   1 +
 src/common/items/artrewards.c         |   1 +
 src/common/items/seed.c               |  10 +-
 src/common/kernel/alchemy.c           |   3 +-
 src/common/kernel/alchemy.h           |   6 +-
 src/common/kernel/alliance.c          |  12 +-
 src/common/kernel/battle.c            |  32 +-
 src/common/kernel/battle.h            |   2 +
 src/common/kernel/border.c            |   1 +
 src/common/kernel/border.h            |   4 +-
 src/common/kernel/build.c             |   8 +-
 src/common/kernel/build.h             |   2 +-
 src/common/kernel/building.c          |   5 +-
 src/common/kernel/building.h          |   4 +-
 src/common/kernel/calendar.h          |   8 +
 src/common/kernel/curse.c             |  22 +-
 src/common/kernel/curse.h             |  33 +-
 src/common/kernel/eressea.c           | 136 +----
 src/common/kernel/eressea.h           | 727 ++------------------------
 src/common/kernel/faction.c           |   3 +
 src/common/kernel/faction.h           |   7 +-
 src/common/kernel/group.c             |   6 +-
 src/common/kernel/group.h             |   8 +-
 src/common/kernel/item.c              |   4 +-
 src/common/kernel/kernel.vcproj       |   3 +
 src/common/kernel/magic.c             |   2 +
 src/common/kernel/magic.h             |  16 +-
 src/common/kernel/movement.c          |  10 +-
 src/common/kernel/names.c             |  13 -
 src/common/kernel/names.h             |   1 -
 src/common/kernel/order.c             |   5 +-
 src/common/kernel/order.h             |   2 +
 src/common/kernel/pathfinder.c        |  16 +-
 src/common/kernel/plane.c             |   4 +-
 src/common/kernel/race.c              |   1 +
 src/common/kernel/region.c            |  19 +-
 src/common/kernel/region.h            |  21 +-
 src/common/kernel/reports.c           |  16 +-
 src/common/kernel/save.c              |  65 +--
 src/common/kernel/save.h              |   4 -
 src/common/kernel/ship.c              |   1 +
 src/common/kernel/ship.h              |   1 +
 src/common/kernel/skill.c             |   3 +-
 src/common/kernel/skill.h             |   4 +-
 src/common/kernel/spy.c               |  10 +-
 src/common/kernel/types.h             | 401 ++++++++++++++
 src/common/kernel/unit.c              | 136 +++++
 src/common/kernel/unit.h              |   5 +-
 src/common/kernel/version.h           |  75 +++
 src/common/kernel/xmlreader.c         |   4 +-
 src/common/modules/arena.c            |   4 +
 src/common/modules/autoseed.c         |  39 +-
 src/common/modules/gmcmd.c            |   7 +-
 src/common/modules/museum.h           |   8 +-
 src/common/modules/xecmd.c            |   5 +-
 src/common/modules/xecmd.h            |   2 +-
 src/common/settings-eressea.h         |   2 +
 src/common/spells/alp.c               |  19 +-
 src/common/spells/buildingcurse.c     |   1 +
 src/common/spells/combatspells.c      |   1 +
 src/common/spells/shipcurse.c         |   5 +-
 src/common/spells/spells.c            | 262 +++++-----
 src/common/spells/unitcurse.c         |   4 +-
 src/common/triggers/changefaction.c   |   7 +-
 src/common/triggers/changerace.c      |   7 +-
 src/common/triggers/clonedied.c       |   7 +-
 src/common/triggers/createcurse.c     |   8 +-
 src/common/triggers/createunit.c      |  10 +-
 src/common/triggers/gate.c            |   5 +-
 src/common/triggers/giveitem.c        |   7 +-
 src/common/triggers/removecurse.c     |   7 +-
 src/common/triggers/timeout.c         |   5 +-
 src/common/triggers/unitmessage.c     |  11 +-
 src/eressea/editing.c                 |   1 +
 src/eressea/gmtool.c                  |   7 +-
 src/eressea/korrektur.c               |  19 +-
 src/eressea/lua/building.cpp          |   2 +
 src/eressea/lua/eressea.cpp           |   2 +
 src/eressea/lua/faction.cpp           |   3 +-
 src/eressea/lua/gamecode.cpp          |   1 +
 src/eressea/lua/region.cpp            |   2 +
 src/eressea/lua/unit.cpp              |   2 +
 src/eressea/main.c                    |   1 +
 src/eressea/server.cpp                |   1 +
 105 files changed, 1258 insertions(+), 1328 deletions(-)
 create mode 100644 src/common/kernel/types.h
 create mode 100644 src/common/kernel/version.h

diff --git a/src/common/attributes/alliance.c b/src/common/attributes/alliance.c
index 1836f67fa..9102d0617 100644
--- a/src/common/attributes/alliance.c
+++ b/src/common/attributes/alliance.c
@@ -10,7 +10,7 @@
  */
 
 #include <config.h>
-#include <eressea.h>
+#include <types.h>
 #include "alliance.h"
 
 #include <kernel/save.h>
diff --git a/src/common/attributes/follow.c b/src/common/attributes/follow.c
index cf3126e9f..834d5a9db 100644
--- a/src/common/attributes/follow.c
+++ b/src/common/attributes/follow.c
@@ -16,7 +16,8 @@
 #include "follow.h"
 
 #include <eressea.h>
-#include <unit.h>
+#include <kernel/unit.h>
+#include <kernel/version.h>
 
 #include <attrib.h>
 #include <resolve.h>
diff --git a/src/common/attributes/hate.c b/src/common/attributes/hate.c
index 4b6d955b5..fcdfef2cd 100644
--- a/src/common/attributes/hate.c
+++ b/src/common/attributes/hate.c
@@ -16,10 +16,11 @@
 #include <eressea.h>
 #include "hate.h"
 
-#include <unit.h>
+#include <kernel/unit.h>
+#include <kernel/version.h>
 
-#include <attrib.h>
-#include <resolve.h>
+#include <util/attrib.h>
+#include <util/resolve.h>
 
 static int
 verify_hate(attrib * a)
diff --git a/src/common/attributes/moved.h b/src/common/attributes/moved.h
index 8d7c3da63..5972bef90 100644
--- a/src/common/attributes/moved.h
+++ b/src/common/attributes/moved.h
@@ -21,7 +21,7 @@ extern "C" {
 struct attrib;
 struct attrib_type;
 
-extern boolean get_moved(attrib ** alist);
+extern boolean get_moved(struct attrib ** alist);
 extern void set_moved(struct attrib ** alist);
 extern void init_moved(void);
 
diff --git a/src/common/attributes/movement.c b/src/common/attributes/movement.c
index 3e2d70d85..5a53ee239 100644
--- a/src/common/attributes/movement.c
+++ b/src/common/attributes/movement.c
@@ -13,10 +13,11 @@
  */
 
 #include <config.h>
-#include <eressea.h>
-#include <attrib.h>
+#include <kernel/eressea.h>
 #include "movement.h"
 
+#include <util/attrib.h>
+
 static void
 write_movement(const attrib * a, FILE * F)
 {
diff --git a/src/common/attributes/movement.h b/src/common/attributes/movement.h
index 0da303c85..5de9d80f9 100644
--- a/src/common/attributes/movement.h
+++ b/src/common/attributes/movement.h
@@ -18,7 +18,7 @@
 extern "C" {
 #endif
 
-extern boolean get_movement(attrib * const * alist, int type);
+extern boolean get_movement(struct attrib * const * alist, int type);
 extern void set_movement(struct attrib ** alist, int type);
 extern void init_movement(void);
 
diff --git a/src/common/attributes/object.h b/src/common/attributes/object.h
index 8e747273b..cd127836b 100644
--- a/src/common/attributes/object.h
+++ b/src/common/attributes/object.h
@@ -24,7 +24,7 @@ typedef enum {
   TUNIT = 10, TFACTION = 11, TREGION = 12, TBUILDING = 13, TSHIP = 14, 
 } object_type;
 
-extern attrib_type at_object;
+extern struct attrib_type at_object;
 
 extern struct attrib * object_create(const char * name, object_type type, variant value);
 extern void object_get(const struct attrib * a, object_type * type, variant * value);
diff --git a/src/common/attributes/overrideroads.c b/src/common/attributes/overrideroads.c
index b9a6fc6ca..c3298a70c 100644
--- a/src/common/attributes/overrideroads.c
+++ b/src/common/attributes/overrideroads.c
@@ -13,9 +13,11 @@
  */
 
 #include <config.h>
-#include <eressea.h>
+#include <kernel/eressea.h>
 #include "overrideroads.h"
+
 #include <kernel/save.h>
+#include <util/attrib.h>
 
 attrib_type at_overrideroads = { 
   "roads_override", NULL, NULL, NULL, &a_writestring, &a_readstring
diff --git a/src/common/attributes/targetregion.c b/src/common/attributes/targetregion.c
index d78a69a26..a9fc4dec7 100644
--- a/src/common/attributes/targetregion.c
+++ b/src/common/attributes/targetregion.c
@@ -18,7 +18,7 @@
 #include <kernel/eressea.h>
 #include <kernel/region.h>
 #include <kernel/save.h>
-
+#include <kernel/version.h>
 
 #include <util/attrib.h>
 #include <util/resolve.h>
diff --git a/src/common/gamecode/archetype.c b/src/common/gamecode/archetype.c
index 1f64341f3..5587a4494 100644
--- a/src/common/gamecode/archetype.c
+++ b/src/common/gamecode/archetype.c
@@ -9,6 +9,7 @@
 #include <kernel/xmlreader.h>
 
 /* util includes */
+#include <util/attrib.h>
 #include <util/umlaut.h>
 #include <util/language.h>
 #include <util/xml.h>
diff --git a/src/common/gamecode/creation.c b/src/common/gamecode/creation.c
index 7dc15dbc3..d7c61c458 100644
--- a/src/common/gamecode/creation.c
+++ b/src/common/gamecode/creation.c
@@ -40,6 +40,7 @@
 
 /* util includes */
 #include <util/goodies.h>
+#include <util/lists.h>
 #include <util/vmap.h>
 #include <util/vset.h>
 
diff --git a/src/common/gamecode/creport.c b/src/common/gamecode/creport.c
index 91050ca25..2de05064d 100644
--- a/src/common/gamecode/creport.c
+++ b/src/common/gamecode/creport.c
@@ -60,12 +60,13 @@
 #include <kernel/save.h>
 
 /* util includes */
+#include <util/attrib.h>
+#include <util/base36.h>
+#include <util/crmessage.h>
+#include <util/goodies.h>
+#include <util/language.h>
 #include <util/message.h>
-#include <goodies.h>
-#include <crmessage.h>
-#include <nrmessage.h>
-#include <base36.h>
-#include <language.h>
+#include <util/nrmessage.h>
 
 /* libc includes */
 #include <assert.h>
diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c
index 4c55ff7f0..0b224625b 100644
--- a/src/common/gamecode/economy.c
+++ b/src/common/gamecode/economy.c
@@ -59,6 +59,7 @@
 #include <util/base36.h>
 #include <util/event.h>
 #include <util/goodies.h>
+#include <util/lists.h>
 #include <util/message.h>
 #include <util/rng.h>
 
@@ -854,17 +855,17 @@ give_cmd(unit * u, order * ord)
 static int
 forget_cmd(unit * u, order * ord)
 {
-	skill_t talent;
+	skill_t sk;
 	const char *s;
   
   init_tokens(ord);
   skip_token();
   s = getstrtoken();
 
-	if ((talent = findskill(s, u->faction->locale)) != NOSKILL) {
+	if ((sk = findskill(s, u->faction->locale)) != NOSKILL) {
 		ADDMSG(&u->faction->msgs,
-			msg_message("forget", "unit skill", u, talent));
-		set_level(u, talent, 0);
+			msg_message("forget", "unit skill", u, sk));
+		set_level(u, sk, 0);
 	}
   return 0;
 }
@@ -920,12 +921,12 @@ maintain(building * b, boolean first)
       else need -= get_pooled(u, m->rtype, GET_DEFAULT, need);
       if (!first && need > 0) {
         unit * ua;
-        for (ua=r->units;ua;ua=ua->next) freset(ua->faction, FL_DH);
-        fset(u->faction, FL_DH); /* hat schon */
+        for (ua=r->units;ua;ua=ua->next) freset(ua->faction, FFL_SELECT);
+        fset(u->faction, FFL_SELECT); /* hat schon */
         for (ua=r->units;ua;ua=ua->next) {
-          if (!fval(ua->faction, FL_DH) && (ua->faction == u->faction || alliedunit(ua, u->faction, HELP_MONEY))) {
+          if (!fval(ua->faction, FFL_SELECT) && (ua->faction == u->faction || alliedunit(ua, u->faction, HELP_MONEY))) {
             need -= get_pooled(ua, m->rtype, GET_ALL, need);
-            fset(ua->faction, FL_DH);
+            fset(ua->faction, FFL_SELECT);
             if (need<=0) break;
           }
         }
@@ -961,14 +962,14 @@ maintain(building * b, boolean first)
 			else cost -= use_pooled(u, m->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, cost);
 			if (!first && cost > 0) {
 				unit * ua;
-				for (ua=r->units;ua;ua=ua->next) freset(ua->faction, FL_DH);
-				fset(u->faction, FL_DH); /* hat schon */
+				for (ua=r->units;ua;ua=ua->next) freset(ua->faction, FFL_SELECT);
+				fset(u->faction, FFL_SELECT); /* hat schon */
 				for (ua=r->units;ua;ua=ua->next) {
-					if (!fval(ua->faction, FL_DH) && alliedunit(ua, u->faction, HELP_MONEY)) {
+					if (!fval(ua->faction, FFL_SELECT) && alliedunit(ua, u->faction, HELP_MONEY)) {
 						int give = use_pooled(ua, m->rtype, GET_ALL, cost);
 						if (!give) continue;
 						cost -= give;
-						fset(ua->faction, FL_DH);
+						fset(ua->faction, FFL_SELECT);
 						if (m->rtype==r_silver) add_spende(ua->faction, u->faction, give, r);
 						if (cost<=0) break;
 					}
@@ -997,12 +998,12 @@ gebaeude_stuerzt_ein(region * r, building * b)
 		if (u->building == b) {
 			int loss = 0;
 
-			fset(u->faction, FL_MARK);
+			fset(u->faction, FFL_MARK);
 			freset(u, UFL_OWNER);
 			leave(r,u);
 			n = u->number;
 			for (i = 0; i < n; i++) {
-				if (rng_int() % 100 >= EINSTURZUEBERLEBEN) {
+				if (rng_double() >= COLLAPSE_SURVIVAL) {
 					++loss;
 				}
 			}
@@ -1015,8 +1016,8 @@ gebaeude_stuerzt_ein(region * r, building * b)
 	add_message(&r->msgs, msg);
 	for (u=r->units; u; u=u->next) {
 		faction * f = u->faction;
-		if (fval(f, FL_MARK)) {
-			freset(u->faction, FL_MARK);
+		if (fval(f, FFL_MARK)) {
+			freset(u->faction, FFL_MARK);
 			add_message(&f->msgs, msg);
 		}
 	}
@@ -1034,7 +1035,7 @@ maintain_buildings(region * r, boolean crash)
 
     /* the second time, send a message */
     if (crash) {
-      if (!maintained && (rng_int() % 100 < EINSTURZCHANCE)) {
+      if (!maintained && (rng_double() < COLLAPSE_CHANCE)) {
         gebaeude_stuerzt_ein(r, b);
         continue;
       } else if (!fval(b, BLD_WORKING)) {
@@ -1636,7 +1637,7 @@ void
 split_allocations(region * r)
 {
   allocation_list ** p_alist=&allocations;
-  freset(r, RF_DH);
+  freset(r, RF_SELECT);
   while (*p_alist) {
     allocation_list * alist = *p_alist;
     const resource_type * rtype = alist->type;
@@ -1644,7 +1645,7 @@ split_allocations(region * r)
     const item_type * itype = resource2item(rtype);
     allocation ** p_al = &alist->data;
 
-    freset(r, RF_DH);
+    freset(r, RF_SELECT);
     alloc(rtype, r, alist->data);
 
     while (*p_al) {
@@ -1653,7 +1654,7 @@ split_allocations(region * r)
         assert(itype || !"not implemented for non-items");
         i_change(&al->unit->items, itype, al->get);
         produceexp(al->unit, itype->construction->skill, al->unit->number);
-        fset(r, RF_DH);
+        fset(r, RF_SELECT);
       }
       if (al->want==INT_MAX) al->want = al->get;
       if (fval(al, AFL_LOWSKILL)) {
@@ -2403,7 +2404,7 @@ expandstealing(region * r, request * stealorders)
     if (oa[i].type.goblin) { /* Goblin-Spezialklau */
       int uct = 0;
       unit *u2;
-      assert(effskill(oa[i].unit, SK_STEALTH)>=4 || !"this goblin\'s talent is too low");
+      assert(effskill(oa[i].unit, SK_STEALTH)>=4 || !"this goblin\'s skill is too low");
       for (u2 = r->units; u2; u2 = u2->next) {
         if (u2->faction == u->faction) {
           uct += maintenance_cost(u2);
@@ -2992,7 +2993,7 @@ expandwork(region * r)
 
 	/* Der Rest wird von den Bauern verdient. n ist das uebriggebliebene
 	* Geld. */
-#if AFFECT_SALARY
+#ifdef AFFECT_SALARY
 	{
 		attrib * a = a_find(r->attribs, &at_salary);
 		if (a) verdienst = a->data.i;
diff --git a/src/common/gamecode/economy.h b/src/common/gamecode/economy.h
index 2f11538f9..ed74d9dfc 100644
--- a/src/common/gamecode/economy.h
+++ b/src/common/gamecode/economy.h
@@ -40,7 +40,7 @@ extern "C" {
 
 #define TRADE_FRACTION          100
 
-extern attrib_type at_reduceproduction;
+extern struct attrib_type at_reduceproduction;
 
 extern int income(const struct unit * u);
 
diff --git a/src/common/gamecode/give.c b/src/common/gamecode/give.c
index 018f810d6..f578d4586 100644
--- a/src/common/gamecode/give.c
+++ b/src/common/gamecode/give.c
@@ -36,6 +36,7 @@
 #include <attributes/orcification.h>
 
 /* util includes */
+#include <util/attrib.h>
 #include <util/event.h>
 #include <util/base36.h>
 
diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c
index 6bde6ee0a..e2c41dcdf 100644
--- a/src/common/gamecode/laws.c
+++ b/src/common/gamecode/laws.c
@@ -71,10 +71,12 @@
 #include <attributes/variable.h>
 
 /* util includes */
+#include <util/attrib.h>
 #include <util/base36.h>
 #include <util/bsdstring.h>
 #include <util/event.h>
 #include <util/goodies.h>
+#include <util/lists.h>
 #include <util/log.h>
 #include <util/rand.h>
 #include <util/rng.h>
@@ -656,7 +658,7 @@ count_race(const region *r, const race *rc)
   return c;
 }
 
-extern attrib_type at_germs;
+extern struct attrib_type at_germs;
 
 static void
 trees(region * r, const int current_season, const int last_weeks_season)
@@ -1848,13 +1850,13 @@ mail_cmd(unit * u, struct order * ord)
         break;
       }
 
-      for (u2 = r->units; u2; u2 = u2->next) freset(u2->faction, FL_DH);
+      for (u2 = r->units; u2; u2 = u2->next) freset(u2->faction, FFL_SELECT);
 
       for(u2=r->units; u2; u2=u2->next) {
-        if(u2->building == b && !fval(u2->faction, FL_DH)
+        if(u2->building == b && !fval(u2->faction, FFL_SELECT)
           && cansee(u->faction, r, u2, 0)) {
             mailunit(r, u, u2->no, ord, s);
-            fset(u2->faction, FL_DH);
+            fset(u2->faction, FFL_SELECT);
           }
       }
     }
@@ -1876,13 +1878,13 @@ mail_cmd(unit * u, struct order * ord)
         break;
       }
 
-      for (u2 = r->units; u2; u2 = u2->next) freset(u2->faction, FL_DH);
+      for (u2 = r->units; u2; u2 = u2->next) freset(u2->faction, FFL_SELECT);
 
       for(u2=r->units; u2; u2=u2->next) {
-        if(u2->ship == sh && !fval(u2->faction, FL_DH)
+        if(u2->ship == sh && !fval(u2->faction, FFL_SELECT)
           && cansee(u->faction, r, u2, 0)) {
             mailunit(r, u, u2->no, ord, s);
-            fset(u2->faction, FL_DH);
+            fset(u2->faction, FFL_SELECT);
           }
       }
     }
@@ -2536,9 +2538,10 @@ guard_on_cmd(unit * u, struct order * ord)
 static void
 sinkships(region * r)
 {
-  ship *sh;
+  ship **shp = &r->ships;
 
-  list_foreach(ship, r->ships, sh) {
+  while (*shp) {
+    ship * sh = *shp;
     if (fval(r->terrain, SEA_REGION) && (!enoughsailors(sh, r) || get_captain(sh)==NULL)) {
       /* Schiff nicht seet�chtig */
       damage_ship(sh, 0.30);
@@ -2546,10 +2549,11 @@ sinkships(region * r)
     if (shipowner(sh)==NULL) {
       damage_ship(sh, 0.05);
     }
-    if (sh->damage >= sh->size * DAMAGE_SCALE)
+    if (sh->damage >= sh->size * DAMAGE_SCALE) {
       destroy_ship(sh);
+    }
+    if (*shp==sh) shp=&sh->next;
   }
-  list_next(sh);
 }
 
 /* The following functions do not really belong here: */
@@ -2638,7 +2642,7 @@ reorder(void)
     boolean sorted=false;
     while (*up) {
       unit * u = *up;
-      if (!fval(u, FL_MARK)) {
+      if (!fval(u, UFL_MARK)) {
         struct order * ord;
         for (ord = u->orders;ord;ord=ord->next) {
           if (get_keyword(ord)==K_SORT) {
@@ -2681,7 +2685,7 @@ reorder(void)
                 }
                 break;
               }
-              fset(u, FL_MARK);
+              fset(u, UFL_MARK);
               sorted = true;
             }
             break;
@@ -2692,7 +2696,7 @@ reorder(void)
     }
     if (sorted) {
       unit * u;
-      for (u=r->units;u;u=u->next) freset(u, FL_MARK);
+      for (u=r->units;u;u=u->next) freset(u, UFL_MARK);
     }
   }
 }
diff --git a/src/common/gamecode/laws.h b/src/common/gamecode/laws.h
index 24528f507..0079dfa08 100644
--- a/src/common/gamecode/laws.h
+++ b/src/common/gamecode/laws.h
@@ -37,7 +37,7 @@ void update_guards(void);
 /* eressea-specific. put somewhere else, please. */
 #include "resolve.h"
 void processorders(void);
-extern attrib_type at_germs;
+extern struct attrib_type at_germs;
 
 #ifdef __cplusplus
 }
diff --git a/src/common/gamecode/monster.c b/src/common/gamecode/monster.c
index 2700563e7..6d650c2e7 100644
--- a/src/common/gamecode/monster.c
+++ b/src/common/gamecode/monster.c
@@ -60,6 +60,7 @@
 #include <util/attrib.h>
 #include <util/base36.h>
 #include <util/event.h>
+#include <util/lists.h>
 #include <util/rand.h>
 #include <util/rng.h>
 
@@ -725,7 +726,7 @@ random_growl(void)
 	return "";
 }
 
-extern attrib_type at_direction;
+extern struct attrib_type at_direction;
 
 static order *
 monster_learn(unit *u)
@@ -1110,12 +1111,12 @@ spawn_dragons(void)
       /* create new message to add to units */
       msg = msg_message("sighting", "region race number",
         u->region, u->race, u->number);
-      for (u=r->units;u;u=u->next) freset(u->faction, FL_DH);
+      for (u=r->units;u;u=u->next) freset(u->faction, FFL_SELECT);
       for (u=r->units;u;u=u->next) {
         faction * f = u->faction;
-        if (!fval(f, FL_DH)) {
+        if (!fval(f, FFL_SELECT)) {
           add_message(&f->msgs, msg);
-          fset(f, FL_DH);
+          fset(f, FFL_SELECT);
         }
       }
       msg_release(msg);
@@ -1182,10 +1183,10 @@ spawn_undead(void)
       {
         message * msg = msg_message("undeadrise", "region", r);
         add_message(&r->msgs, msg);
-        for (u=r->units;u;u=u->next) freset(u->faction, FL_DH);
+        for (u=r->units;u;u=u->next) freset(u->faction, FFL_SELECT);
         for (u=r->units;u;u=u->next) {
-          if (fval(u->faction, FL_DH)) continue;
-          fset(u->faction, FL_DH);
+          if (fval(u->faction, FFL_SELECT)) continue;
+          fset(u->faction, FFL_SELECT);
           add_message(&u->faction->msgs, msg);
         }
         msg_release(msg);
diff --git a/src/common/gamecode/randenc.c b/src/common/gamecode/randenc.c
index 173f577ed..14e1c8113 100644
--- a/src/common/gamecode/randenc.c
+++ b/src/common/gamecode/randenc.c
@@ -55,7 +55,9 @@
 #include <attributes/racename.h>
 
 /* util includes */
+#include <util/attrib.h>
 #include <util/rand.h>
+#include <util/lists.h>
 #include <util/message.h>
 #include <util/rng.h>
 
@@ -67,8 +69,8 @@
 #include <stdlib.h>
 
 #include <attributes/iceberg.h>
-extern attrib_type at_unitdissolve;
-extern attrib_type at_orcification;
+extern struct attrib_type at_unitdissolve;
+extern struct attrib_type at_orcification;
 
 /* In a->data.ca[1] steht der Prozentsatz mit dem sich die Einheit
  * aufl�st, in a->data.ca[0] kann angegeben werden, wohin die Personen
@@ -743,7 +745,7 @@ volcano_outbreak(region *r)
 
   for (u=r->units; u; u=u->next) {
     f = u->faction;
-    freset(f, FL_DH);
+    freset(f, FFL_SELECT);
   }
   rn = rrandneighbour(r);
 
@@ -771,8 +773,8 @@ volcano_outbreak(region *r)
         ADDMSG(&u->faction->msgs, msg_message("volcano_dead", 
           "unit region dead", u, r, dead));
       }
-      if (!fval(u->faction, FL_DH)) {
-        fset(u->faction, FL_DH);
+      if (!fval(u->faction, FFL_SELECT)) {
+        fset(u->faction, FFL_SELECT);
         if (rn) {
           ADDMSG(&u->faction->msgs, msg_message("volcanooutbreak", 
             "regionv regionn", r, rn));
@@ -826,9 +828,9 @@ melt_iceberg(region *r)
 	unit *u;
 	building *b, *b2;
 
-	for (u=r->units; u; u=u->next) freset(u->faction, FL_DH);
-	for (u=r->units; u; u=u->next) if (!fval(u->faction, FL_DH)) {
-		fset(u->faction, FL_DH);
+	for (u=r->units; u; u=u->next) freset(u->faction, FFL_SELECT);
+	for (u=r->units; u; u=u->next) if (!fval(u->faction, FFL_SELECT)) {
+		fset(u->faction, FFL_SELECT);
 		ADDMSG(&u->faction->msgs, msg_message("iceberg_melt", "region", r));
 	}
 
@@ -879,9 +881,9 @@ move_iceberg(region *r)
 			short x, y;
 
 
-			for (u=r->units; u; u=u->next) freset(u->faction, FL_DH);
-			for (u=r->units; u; u=u->next) if (!fval(u->faction, FL_DH)) {
-				fset(u->faction, FL_DH);
+			for (u=r->units; u; u=u->next) freset(u->faction, FFL_SELECT);
+			for (u=r->units; u; u=u->next) if (!fval(u->faction, FFL_SELECT)) {
+				fset(u->faction, FFL_SELECT);
 				ADDMSG(&u->faction->msgs, msg_message("iceberg_drift", 
           "region dir", r, dir));
 			}
@@ -903,12 +905,12 @@ move_iceberg(region *r)
 			/* Schiffe aus dem Zielozean werden in den Eisberg transferiert
 			 * und nehmen Schaden. */
 
-			for (sh = r->ships; sh; sh=sh->next) freset(sh, FL_DH);
+			for (sh = r->ships; sh; sh=sh->next) freset(sh, SF_SELECT);
 
 			for (sh = r->ships; sh; sh = sh->next) {
 				/* Meldung an Kapit�n */
 				damage_ship(sh, 0.10);
-				fset(sh, FL_DH);
+				fset(sh, SF_SELECT);
 			}
 
 			/* Personen, Schiffe und Geb�ude verschieben */
@@ -917,7 +919,7 @@ move_iceberg(region *r)
 				translist(&rc->buildings, &r->buildings, rc->buildings);
 			}
 			while (rc->ships) {
-				fset(rc->ships, FL_DH);
+				fset(rc->ships, SF_SELECT);
 				damage_ship(rc->ships, 0.10);
 				move_ship(rc->ships, rc, r, NULL);
 			}
@@ -932,7 +934,7 @@ move_iceberg(region *r)
 
 			for (sh = r->ships; sh;) {
 				shn = sh->next;
-				if (fval(sh, FL_DH)) {
+				if (fval(sh, SF_SELECT)) {
 					u = captain(sh, r);
 					if (sh->damage>=sh->size * DAMAGE_SCALE) {
             if (u!=NULL) {
@@ -954,9 +956,9 @@ move_iceberg(region *r)
 			rsetterrain(r, T_GLACIER);
 			a_remove(&r->attribs, a);
 
-			for (u=r->units; u; u=u->next) freset(u->faction, FL_DH);
-			for (u=r->units; u; u=u->next) if (!fval(u->faction, FL_DH)) {
-				fset(u->faction, FL_DH);
+			for (u=r->units; u; u=u->next) freset(u->faction, FFL_SELECT);
+			for (u=r->units; u; u=u->next) if (!fval(u->faction, FFL_SELECT)) {
+				fset(u->faction, FFL_SELECT);
         ADDMSG(&u->faction->msgs, msg_message("iceberg_land", "region", r));
 			}
 		}
@@ -969,15 +971,15 @@ move_icebergs(void)
 	region *r;
 
   for (r=regions; r; r=r->next) {
-    if (rterrain(r) == T_ICEBERG && !fval(r, RF_DH)) {
+    if (rterrain(r) == T_ICEBERG && !fval(r, RF_SELECT)) {
       int select = rng_int() % 10;
       if (select < 4) {
         /* 4% chance */
-  			fset(r, RF_DH);
+  			fset(r, RF_SELECT);
 	  		melt_iceberg(r);
       } else if (select<64) {
         /* 60% chance */
-        fset(r, RF_DH);
+        fset(r, RF_SELECT);
         move_iceberg(r);
       }
 		}
@@ -996,7 +998,7 @@ create_icebergs(void)
       region *rc;
       unit *u;
 
-      freset(r, RF_DH);
+      freset(r, RF_SELECT);
       for (dir=0; dir < MAXDIRECTIONS; dir++) {
         rc = rconnect(r, dir);
         if (rc && fval(rc->terrain, SEA_REGION)) {
@@ -1008,15 +1010,15 @@ create_icebergs(void)
 
       rsetterrain(r, T_ICEBERG);
 
-      fset(r, RF_DH);
+      fset(r, RF_SELECT);
       move_iceberg(r);
 
       for (u=r->units; u; u=u->next) {
-        freset(u->faction, FL_DH);
+        freset(u->faction, FFL_SELECT);
       }
       for (u=r->units; u; u=u->next) {
-        if (!fval(u->faction, FL_DH)) {
-          fset(u->faction, FL_DH);
+        if (!fval(u->faction, FFL_SELECT)) {
+          fset(u->faction, FFL_SELECT);
           ADDMSG(&u->faction->msgs, msg_message("iceberg_create", "region", r));
         }
       }
diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c
index 1afee46cf..d42c128cd 100644
--- a/src/common/gamecode/report.c
+++ b/src/common/gamecode/report.c
@@ -13,6 +13,7 @@
  */
 
 #define INDENT 0
+#define ECHECK_VERSION "4.01"
 
 #include <config.h>
 #include <eressea.h>
@@ -67,20 +68,23 @@
 #include <kernel/alliance.h>
 
 /* util includes */
+#include <util/attrib.h>
+#include <util/base36.h>
 #include <util/bsdstring.h>
 #include <util/goodies.h>
-#include <util/base36.h>
-#include <util/nrmessage.h>
-#include <util/translation.h>
-#include <util/message.h>
-#include <util/rng.h>
+#include <util/lists.h>
 #include <util/log.h>
+#include <util/message.h>
+#include <util/nrmessage.h>
+#include <util/rng.h>
+#include <util/translation.h>
 
 /* libc includes */
 #include <assert.h>
 #include <ctype.h>
 #include <errno.h>
 #include <string.h>
+#include <stddef.h>
 #include <stdio.h>
 #include <time.h>
 #include <math.h>
@@ -2378,7 +2382,7 @@ make_summary(void)
       /* Einheiten Info. nregions darf nur einmal pro Partei
        * incrementiert werden. */
 
-      for (u = r->units; u; u = u->next) freset(u->faction, FL_DH);
+      for (u = r->units; u; u = u->next) freset(u->faction, FFL_SELECT);
       for (u = r->units; u; u = u->next) {
         f = u->faction;
         if (u->faction->no != MONSTER_FACTION) {
@@ -2409,9 +2413,9 @@ make_summary(void)
             int aktskill = eff_skill(u, sk, r);
             if (aktskill > s->maxskill) s->maxskill = aktskill;
           }
-          if (!fval(f, FL_DH)) {
+          if (!fval(f, FFL_SELECT)) {
             f->nregions++;
-            fset(f, FL_DH);
+            fset(f, FFL_SELECT);
           }
         }
 
@@ -2455,7 +2459,7 @@ writemonument(void)
   for (r = regions; r; r = r->next) {
     for (b = r->buildings; b; b = b->next) {
       if (b->type == bt_find("monument") && b->display && *b->display) {
-        freset(b, FL_DH);
+        freset(b, BLD_SELECT);
         count++;
         if(b->size > size[6]) {
           for(i=0; i <= 6; i++) if(b->size >= size[i]) {
@@ -2473,7 +2477,7 @@ writemonument(void)
   }
 
   for(i=0; i <= 6; i++) if(buildings[i]) {
-    fset(buildings[i], FL_DH);
+    fset(buildings[i], BLD_SELECT);
   }
   {
     char zText[MAX_PATH];
@@ -2501,7 +2505,7 @@ writemonument(void)
     j = 0;
     for (r = regions; r; r = r->next) {
       for (b = r->buildings; b; b = b->next) {
-        if (b->type == bt_find("monument") && b->display && *b->display && !fval(b, FL_DH)) {
+        if (b->type == bt_find("monument") && b->display && *b->display && !fval(b, BLD_SELECT)) {
           j++;
           if(j == ra) {
             fprintf(F, "In %s", rname(b->region, NULL));
diff --git a/src/common/gamecode/study.c b/src/common/gamecode/study.c
index ae3d18fbe..8d0a42663 100644
--- a/src/common/gamecode/study.c
+++ b/src/common/gamecode/study.c
@@ -44,6 +44,7 @@
 #include <kernel/unit.h>
 
 /* util includes */
+#include <util/attrib.h>
 #include <util/base36.h>
 #include <util/rand.h>
 
@@ -100,11 +101,11 @@ magic_lowskill(unit *u)
 /* ------------------------------------------------------------- */
 
 int
-study_cost(unit *u, skill_t talent)
+study_cost(unit *u, skill_t sk)
 {
 	int stufe, k = 50;
 
-	switch (talent) {
+	switch (sk) {
 		case SK_SPY:
 			return 100;
 			break;
@@ -617,13 +618,8 @@ learn_cmd(unit * u, order * ord)
     studycost = p;	/* Ohne Univertreurung */
     money = min(money, studycost);
     if (p>0 && money < studycost * u->number) {
-  #ifdef PARTIAL_STUDY
       cmistake(u, ord, 65, MSG_EVENT);
       multi = money / (double)(studycost * u->number);
-  #else
-      cmistake(u, ord, 65, MSG_EVENT);
-      return 0;		/* nein, Silber reicht auch so nicht */
-  #endif
     }
   }
 
diff --git a/src/common/iniparser/iniparser.c b/src/common/iniparser/iniparser.c
index 747d5a183..02da9f42f 100644
--- a/src/common/iniparser/iniparser.c
+++ b/src/common/iniparser/iniparser.c
@@ -28,6 +28,7 @@
  */
 
 
+#include <config.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/common/items/artrewards.c b/src/common/items/artrewards.c
index 3eb02c6c6..9e84d4eee 100644
--- a/src/common/items/artrewards.c
+++ b/src/common/items/artrewards.c
@@ -28,6 +28,7 @@
 #include <kernel/ship.h>
 
 /* util includes */
+#include <util/attrib.h>
 #include <util/functions.h>
 #include <util/rand.h>
 
diff --git a/src/common/items/seed.c b/src/common/items/seed.c
index 995cdc71e..5cf519d92 100644
--- a/src/common/items/seed.c
+++ b/src/common/items/seed.c
@@ -11,18 +11,20 @@
 */
 
 #include <config.h>
-#include <eressea.h>
+#include <kernel/eressea.h>
 
 #include "seed.h"
 
-#include <build.h>
-#include <region.h>
+#include <kernel/build.h>
+#include <kernel/eressea.h>
+#include <kernel/region.h>
 
 /* kernel includes */
 #include <item.h>
 
 /* util includes */
-#include <functions.h>
+#include <util/attrib.h>
+#include <util/functions.h>
 
 /* libc includes */
 #include <assert.h>
diff --git a/src/common/kernel/alchemy.c b/src/common/kernel/alchemy.c
index 3f5f351c7..f975b9a12 100644
--- a/src/common/kernel/alchemy.c
+++ b/src/common/kernel/alchemy.c
@@ -36,7 +36,8 @@
 #include "movement.h"
 
 /* util includes */
-#include <rand.h>
+#include <util/attrib.h>
+#include <util/rand.h>
 
 /* libc includes */
 #include <stdio.h>
diff --git a/src/common/kernel/alchemy.h b/src/common/kernel/alchemy.h
index 0bdac409b..4a5e0b429 100644
--- a/src/common/kernel/alchemy.h
+++ b/src/common/kernel/alchemy.h
@@ -48,18 +48,16 @@ enum {
 	P_WAHRHEIT,
 	P_MACHT,
 	P_HEAL,
-	MAX_POTIONS,
-	NOPOTION = (potion_t) - 1
+	MAX_POTIONS
 };
 
-herb_t rherb2herb(struct region *r);
 void herbsearch(struct region * r, struct unit * u, int max);
 int use_potion(struct unit * u, const struct item_type * itype, int amount, struct order *);
 void init_potions(void);
 
 extern int get_effect(const struct unit * u, const struct potion_type * effect);
 extern int change_effect(struct unit * u, const struct potion_type * effect, int value);
-extern attrib_type at_effect;
+extern struct attrib_type at_effect;
 
 /* rausnehmen, sobald man attribute splitten kann: */
 typedef struct effect_data {
diff --git a/src/common/kernel/alliance.c b/src/common/kernel/alliance.c
index 41693570e..787eafdd2 100644
--- a/src/common/kernel/alliance.c
+++ b/src/common/kernel/alliance.c
@@ -26,9 +26,11 @@
 #include <kernel/item.h>
 
 /* util includes */
-#include <util/command.h>
-#include <util/umlaut.h>
+#include <util/attrib.h>
 #include <util/base36.h>
+#include <util/command.h>
+#include <util/lists.h>
+#include <util/umlaut.h>
 
 /* libc includes */
 #include <assert.h>
@@ -255,7 +257,7 @@ alliancevictory(void)
 			if (b->type==btype) {
 				unit * u = buildingowner(r, b);
 				if (u) {
-					fset(u->faction->alliance, FL_MARK);
+					fset(u->faction->alliance, FFL_MARK);
 				}
 			}
 			b = b->next;
@@ -263,7 +265,7 @@ alliancevictory(void)
 		r=r->next;
 	}
 	while (al!=NULL) {
-		if (!fval(al, FL_MARK)) {
+		if (!fval(al, FFL_MARK)) {
 			faction_list * flist = al->members;
 			while (flist!=0) {
 				faction * f = flist->data;
@@ -275,7 +277,7 @@ alliancevictory(void)
 				flist = flist->next;
 			}
 		} else {
-			freset(al, FL_MARK);
+			freset(al, FFL_MARK);
 		}
 		al = al->next;
 	}
diff --git a/src/common/kernel/battle.c b/src/common/kernel/battle.c
index 5070bf9b3..365b246fc 100644
--- a/src/common/kernel/battle.c
+++ b/src/common/kernel/battle.c
@@ -52,12 +52,14 @@
 #include <items/demonseye.h>
 
 /* util includes */
+#include <util/attrib.h>
 #include <util/base36.h>
 #include <util/bsdstring.h>
 #include <util/cvector.h>
+#include <util/lists.h>
+#include <util/log.h>
 #include <util/rand.h>
 #include <util/rng.h>
-#include <util/log.h>
 
 /* libc includes */
 #include <assert.h>
@@ -3366,7 +3368,6 @@ make_battle(region * r)
 {
   battle *b = calloc(1, sizeof(struct battle));
   unit *u;
-  faction *lastf = NULL;
   bfaction * bf;
   static int max_fac_no = 0; /* need this only once */
 
@@ -3388,27 +3389,28 @@ make_battle(region * r)
   b->region = r;
   b->plane = getplane(r);
   /* Finde alle Parteien, die den Kampf beobachten k�nnen: */
-  list_foreach(unit, r->units, u)
+  for (u = r->units; u; u=u->next) {
     if (u->number > 0) {
-    if (lastf != u->faction) {  /* Speed optimiert, aufeinanderfolgende
-                 * * gleiche nicht getestet */
-      lastf = u->faction;
-      for (bf=b->factions;bf;bf=bf->next)
-        if (bf->faction==lastf) break;
-      if (!bf) {
-        bf = calloc(sizeof(bfaction), 1);
-        ++b->nfactions;
-        bf->faction = lastf;
-        bf->next = b->factions;
-        b->factions = bf;
+      if (!fval(u->faction, FFL_MARK)) {
+        fset(u->faction, FFL_MARK);
+        for (bf=b->factions;bf;bf=bf->next) {
+          if (bf->faction==u->faction) break;
+        }
+        if (!bf) {
+          bf = calloc(sizeof(bfaction), 1);
+          ++b->nfactions;
+          bf->faction = u->faction;
+          bf->next = b->factions;
+          b->factions = bf;
+        }
       }
     }
   }
-  list_next(u);
 
   for (bf=b->factions;bf;bf=bf->next) {
     faction * f = bf->faction;
     max_fac_no = max(max_fac_no, f->no);
+    freset(f, FFL_MARK);
   }
   return b;
 }
diff --git a/src/common/kernel/battle.h b/src/common/kernel/battle.h
index cec5885d2..6966f1892 100644
--- a/src/common/kernel/battle.h
+++ b/src/common/kernel/battle.h
@@ -17,6 +17,8 @@
 extern "C" {
 #endif
 
+#include <util/cvector.h>
+
 #define SHOW_KILLS
 #undef SMALL_BATTLE_MESSAGES
 
diff --git a/src/common/kernel/border.c b/src/common/kernel/border.c
index c25c65902..80d56df17 100644
--- a/src/common/kernel/border.c
+++ b/src/common/kernel/border.c
@@ -22,6 +22,7 @@
 #include "unit.h"
 
 #include <util/rng.h>
+#include <util/attrib.h>
 
 /* libc includes */
 #include <assert.h>
diff --git a/src/common/kernel/border.h b/src/common/kernel/border.h
index 790da5926..576df17aa 100644
--- a/src/common/kernel/border.h
+++ b/src/common/kernel/border.h
@@ -30,7 +30,7 @@ extern "C" {
     struct border * next; /* next border between these regions */
     struct border * nexthash; /* next border between these regions */
     struct region * from, * to; /* borders can be directed edges */
-    attrib * attribs;
+    struct attrib * attribs;
     variant data;
     unsigned int id; /* unique id */
   } border;
@@ -126,7 +126,7 @@ extern "C" {
   extern border_type bt_road;
   extern border_type bt_questportal;
 
-  extern attrib_type at_countdown;
+  extern struct attrib_type at_countdown;
 
 #ifdef __cplusplus
 }
diff --git a/src/common/kernel/build.c b/src/common/kernel/build.c
index 8aed18d19..cb19e224c 100644
--- a/src/common/kernel/build.c
+++ b/src/common/kernel/build.c
@@ -267,13 +267,13 @@ siege_cmd(unit * u, order * ord)
   ADDMSG(&u->faction->msgs, msg_message("siege",
     "unit building destruction", u, b, d));
 
-  for (u2 = r->units; u2; u2 = u2->next) freset(u2->faction, FL_DH);
-  fset(u->faction, FL_DH);
+  for (u2 = r->units; u2; u2 = u2->next) freset(u2->faction, FFL_SELECT);
+  fset(u->faction, FFL_SELECT);
 
   /* Meldung fuer Burginsassen */
   for (u2 = r->units; u2; u2 = u2->next) {
-    if (u2->building == b && !fval(u2->faction, FL_DH)) {
-      fset(u2->faction, FL_DH);
+    if (u2->building == b && !fval(u2->faction, FFL_SELECT)) {
+      fset(u2->faction, FFL_SELECT);
       ADDMSG(&u2->faction->msgs, msg_message("siege",
         "unit building destruction", u, b, d));
     }
diff --git a/src/common/kernel/build.h b/src/common/kernel/build.h
index 191409c3d..ea2441e6d 100644
--- a/src/common/kernel/build.h
+++ b/src/common/kernel/build.h
@@ -53,7 +53,7 @@ typedef struct construction {
 		 * last level of a building points to NULL, as do objects of
 		 * an unlimited size.
 		 */
-	attrib * attribs;
+	struct attrib * attribs;
 		/* stores skill modifiers and other attributes */
 } construction;
 
diff --git a/src/common/kernel/building.c b/src/common/kernel/building.c
index b843a47ee..f0b8ab015 100644
--- a/src/common/kernel/building.c
+++ b/src/common/kernel/building.c
@@ -13,6 +13,7 @@
  */
 
 #include <config.h>
+
 #include "eressea.h"
 #include "building.h"
 #include "attrib.h"
@@ -25,12 +26,14 @@
 #include "skill.h"
 #include "magic.h"
 #include "save.h"
+#include "version.h"
 
 /* util includes */
 #include <util/base36.h>
 #include <util/event.h>
 #include <util/functions.h>
 #include <util/language.h>
+#include <util/lists.h>
 #include <util/resolve.h>
 #include <util/umlaut.h>
 
@@ -490,7 +493,7 @@ destroy_building(building * b)
   handle_event(b->attribs, "destroy", b);
 }
 
-extern attrib_type at_icastle;
+extern struct attrib_type at_icastle;
 
 int
 buildingeffsize(const building * b, boolean img)
diff --git a/src/common/kernel/building.h b/src/common/kernel/building.h
index 4c49ab226..239d336e7 100644
--- a/src/common/kernel/building.h
+++ b/src/common/kernel/building.h
@@ -79,6 +79,8 @@ extern void bt_register(building_type * type);
 #define BLD_UNGUARDED      0x04 /* you can enter this building anytime */
 #define BLD_EXPANDED       0x08 /* has been expanded this turn */
 
+#define BLD_SELECT         0x10 /* formerly FL_DH */
+
 #define BLD_SAVEMASK       0x00 /* mask for persistent flags */
 
 typedef struct building {
@@ -134,7 +136,7 @@ extern struct building *findbuilding(int n);
 
 extern struct unit * buildingowner(const struct region * r, const struct building * b);
 
-extern attrib_type at_building_action;
+extern struct attrib_type at_building_action;
 
 #ifdef WDW_PYRAMID
 extern int wdw_pyramid_level(const struct building *b);
diff --git a/src/common/kernel/calendar.h b/src/common/kernel/calendar.h
index 45bb067a5..ae4306d28 100644
--- a/src/common/kernel/calendar.h
+++ b/src/common/kernel/calendar.h
@@ -5,6 +5,14 @@
 extern "C" {
 #endif
 
+enum {
+  SEASON_WINTER,
+  SEASON_SPRING,
+  SEASON_SUMMER,
+  SEASON_AUTUMN
+};
+
+
 extern char *agename;
 extern int  first_turn;
 extern int  first_month;
diff --git a/src/common/kernel/curse.c b/src/common/kernel/curse.c
index 3c507a2a1..be142a4a5 100644
--- a/src/common/kernel/curse.c
+++ b/src/common/kernel/curse.c
@@ -24,16 +24,18 @@
 #include "curse.h"
 
 /* kernel includes */
-#include "magic.h"
-#include "skill.h"
-#include "unit.h"
-#include "region.h"
-#include "race.h"
-#include "faction.h"
+#include "attrib.h"
 #include "building.h"
-#include "ship.h"
+#include "faction.h"
+#include "magic.h"
 #include "message.h"
 #include "objtypes.h"
+#include "race.h"
+#include "region.h"
+#include "ship.h"
+#include "skill.h"
+#include "unit.h"
+#include "version.h"
 
 /* util includes */
 #include <util/resolve.h>
@@ -656,12 +658,12 @@ is_cursed_internal(attrib *ap, const curse_type *ct)
 
 
 boolean
-is_cursed_with(attrib *ap, curse *c)
+is_cursed_with(const attrib *ap, const curse *c)
 {
-  attrib *a = ap;
+  const attrib *a = ap;
 
   while (a) {
-    if ((a->type->flags & ATF_CURSE) && (c == (curse *)a->data.v)) {
+    if ((a->type->flags & ATF_CURSE) && (c == (const curse *)a->data.v)) {
       return true;
     }
     a = a->next;
diff --git a/src/common/kernel/curse.h b/src/common/kernel/curse.h
index d9445c099..08a409cfe 100644
--- a/src/common/kernel/curse.h
+++ b/src/common/kernel/curse.h
@@ -218,17 +218,17 @@ typedef struct curse_type {
   unsigned int mergeflags;
   const char *info_str;  /* Wirkung des curse, wird bei einer gelungenen
                  Zauberanalyse angezeigt */
-  struct message * (*curseinfo)(const void*, typ_t, const curse*, int);
+  struct message * (*curseinfo)(const void*, typ_t, const struct curse*, int);
   void (*change_vigour)(curse*, double);
   int (*read)(FILE * F, curse * c);
-  int (*write)(FILE * F, const curse * c);
-  int (*cansee)(const struct faction*, const void*, typ_t, const curse *, int);
+  int (*write)(FILE * F, const struct curse * c);
+  int (*cansee)(const struct faction*, const void*, typ_t, const struct curse *, int);
   int (*age)(curse *);
 } curse_type;
 
-extern attrib_type at_curse;
-extern void curse_write(const attrib * a,FILE * f);
-extern int curse_read(struct attrib * a,FILE * f);
+extern struct attrib_type at_curse;
+extern void curse_write(const struct attrib * a, FILE * f);
+extern int curse_read(struct attrib * a, FILE * f);
 
 
 /* ------------------------------------------------------------- */
@@ -257,11 +257,11 @@ extern void destroy_curse(curse * c);
 boolean is_cursed_internal(struct attrib *ap, const curse_type * ctype);
   /* ignoriert CURSE_ISNEW */
 
-extern void remove_curse(struct attrib **ap, const curse * c);
+extern void remove_curse(struct attrib **ap, const struct curse * c);
   /* l�scht einen konkreten Spruch auf einem Objekt.
    */
 
-extern int curse_geteffect(const curse * c);
+extern int curse_geteffect(const struct curse * c);
   /* gibt die Auswirkungen der Verzauberungen zur�ck. zB bei
    * Skillmodifiziernden Verzauberungen ist hier der Modifizierer
    * gespeichert. Wird automatisch beim Anlegen eines neuen curse
@@ -286,12 +286,12 @@ void transfer_curse(struct unit * u, struct unit * u2, int n);
    * unterschiedlich gew�nscht sein
    * */
 
-extern curse * get_cursex(attrib *ap, const curse_type * ctype, variant data,
-              boolean(*compare)(const curse *, variant));
+extern struct curse * get_cursex(struct attrib *ap, const curse_type * ctype, variant data,
+              boolean(*compare)(const struct curse *, variant));
   /* gibt pointer auf die erste curse-struct zur�ck, deren Typ ctype ist,
    * und f�r die compare() true liefert, oder einen NULL-pointer.
    * */
-extern curse * get_curse(struct attrib *ap, const curse_type * ctype);
+extern struct curse * get_curse(struct attrib *ap, const curse_type * ctype);
   /* gibt pointer auf die erste curse-struct zur�ck, deren Typ ctype ist,
    * oder einen NULL-pointer
    * */
@@ -310,13 +310,13 @@ extern void curse_init(struct attrib * a);
 extern void curse_done(struct attrib * a);
 extern int curse_age(struct attrib * a);
 
-extern boolean cmp_curse(const attrib * a, const void * data);
-extern boolean cmp_cursetype(const attrib * a, const void * data);
+extern boolean cmp_curse(const struct attrib * a, const void * data);
+extern boolean cmp_cursetype(const struct attrib * a, const void * data);
 
 extern void * resolve_curse(variant data);
-extern boolean is_cursed_with(attrib *ap, curse *c);
+extern boolean is_cursed_with(const struct attrib *ap, const struct curse *c);
 
-extern boolean curse_active(const curse * c);
+extern boolean curse_active(const struct curse * c);
   /* gibt true, wenn der Curse nicht NULL oder inaktiv ist */
 
 /*** COMPATIBILITY MACROS. DO NOT USE FOR NEW CODE, REPLACE IN OLD CODE: */
@@ -329,6 +329,9 @@ extern struct message * cinfo_simple(const void * obj, typ_t typ, const struct c
 #define get_curseeffect(a, id, id2) \
   curse_geteffect(get_curse(a, ct_find(oldcursename(id))))
 
+/* eressea-defined attribute-type flags */
+#define ATF_CURSE  ATF_USER_DEFINED
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c
index 2e983041b..8dc8676c9 100644
--- a/src/common/kernel/eressea.c
+++ b/src/common/kernel/eressea.c
@@ -26,8 +26,6 @@
 
 /* attributes includes */
 #include <attributes/reduceproduction.h>
-#include <attributes/otherfaction.h>
-#include <attributes/racename.h>
 #include <attributes/gm.h>
 
 /* kernel includes */
@@ -59,11 +57,13 @@
 #include "unit.h"
 
 /* util includes */
+#include <util/attrib.h>
 #include <util/base36.h>
 #include <util/crmessage.h>
 #include <util/event.h>
 #include <util/functions.h>
 #include <util/log.h>
+#include <util/lists.h>
 #include <util/rng.h>
 #include <util/sql.h>
 #include <util/translation.h>
@@ -97,11 +97,6 @@ const struct race * new_race[MAXRACES];
 boolean sqlpatch = false;
 int turn;
 
-static attrib_type at_creator = {
-  "creator"
-  /* Rest ist NULL; tempor�res, nicht alterndes Attribut */
-};
-
 int
 NewbieImmunity(void) {
   static int value = -1;
@@ -1529,9 +1524,7 @@ findkeyword(const char *s, const struct locale * lang)
   struct tnode * tokens = get_translations(lang, UT_KEYWORDS);
   variant token;
 
-#ifdef AT_PERSISTENT
   if (*s == '@') s++;
-#endif
   if (findtoken(tokens, s, &token)==E_TOK_NOMATCH) return NOKEYWORD;
   if (global.disabled[token.i]) return NOKEYWORD;
   return (keyword_t) token.i;
@@ -1886,16 +1879,6 @@ newcontainerid(void)
   return random_no;
 }
 
-static void
-createunitid(unit *u, int id)
-{
-  if (id<=0 || id > MAX_UNIT_NR || ufindhash(id) || dfindhash(id) || forbiddenid(id))
-    u->no = newunitid();
-  else
-    u->no = id;
-  uhash(u);
-}
-
 unit *
 createunit(region * r, faction * f, int number, const struct race * rc)
 {
@@ -1903,111 +1886,6 @@ createunit(region * r, faction * f, int number, const struct race * rc)
   return create_unit(r, f, number, rc, 0, NULL, NULL);
 }
 
-/** creates a new unit.
- *
- * @param dname: name, set to NULL to get a default.
- * @param creator: unit to inherit stealth, group, building, ship, etc. from
- */
-unit *
-create_unit(region * r, faction * f, int number, const struct race *urace, int id, const char * dname, unit *creator)
-{
-  unit * u = calloc(1, sizeof(unit));
-  order * deford = default_order(f->locale);
-
-  assert(urace);
-  assert(deford);
-  assert(f->alive);
-  u_setfaction(u, f);
-  set_order(&u->thisorder, NULL);
-#ifdef LASTORDER
-  set_order(&u->lastorder, deford);
-#else
-  addlist(&u->orders, deford);
-#endif
-  u_seteffstealth(u, -1);
-  u->race = urace;
-  u->irace = urace;
-
-  set_number(u, number);
-
-  /* die nummer der neuen einheit muss vor name_unit generiert werden,
-   * da der default name immer noch 'Nummer u->no' ist */
-  createunitid(u, id);
-
-  /* zuerst in die Region setzen, da zb Drachennamen den Regionsnamen
-   * enthalten */
-  move_unit(u, r, NULL);
-
-  /* u->race muss bereits gesetzt sein, wird f�r default-hp gebraucht */
-  /* u->region auch */
-  u->hp = unit_max_hp(u) * number;
-
-  if (!dname) {
-    name_unit(u);
-  }
-  else set_string(&u->name, dname);
-  set_string(&u->display, "");
-
-  if (count_unit(u)) f->no_units++;
-
-  if (creator) {
-    attrib * a;
-
-    /* erbt Kampfstatus */
-    setstatus(u, creator->status);
-
-    /* erbt Geb�ude/Schiff*/
-    if (creator->region==r) {
-      u->building = creator->building;
-      assert(creator->ship==NULL || fval(u->race, RCF_CANSAIL));
-      u->ship = creator->ship;
-    }
-
-    /* Tarnlimit wird vererbt */
-    if (fval(creator, UFL_STEALTH)) {
-      attrib * a = a_find(creator->attribs, &at_stealth);
-      if (a) {
-        int stealth = a->data.i;
-        a = a_add(&u->attribs, a_new(&at_stealth));
-        a->data.i = stealth;
-      }
-    }
-
-    /* Temps von parteigetarnten Einheiten sind wieder parteigetarnt */
-    if (fval(creator, UFL_PARTEITARNUNG)) {
-      fset(u, UFL_PARTEITARNUNG);
-    }
-    /* Daemonentarnung */
-    set_racename(&u->attribs, get_racename(creator->attribs));
-    if (fval(u->race, RCF_SHAPESHIFT) && fval(creator->race, RCF_SHAPESHIFT)) {
-      u->irace = creator->irace;
-    }
-
-    /* Gruppen */
-    if (fval(creator, UFL_GROUP)) {
-      a = a_find(creator->attribs, &at_group);
-      if (a) {
-        group * g = (group*)a->data.v;
-        a_add(&u->attribs, a_new(&at_group))->data.v = g;
-        fset(u, UFL_GROUP);
-      }
-    }
-    a = a_find(creator->attribs, &at_otherfaction);
-    if (a) {
-      a_add(&u->attribs, make_otherfaction(get_otherfaction(a)));
-    }
-
-    a = a_add(&u->attribs, a_new(&at_creator));
-    a->data.v = creator;
-  }
-  /* Monster sind grunds�tzlich parteigetarnt */
-  if (f->no <= 0) fset(u, UFL_PARTEITARNUNG);
-
-  return u;
-}
-
-/* Setzt Default Befehle -------------------------------------- */
-
 boolean
 idle (faction * f)
 {
@@ -2419,7 +2297,7 @@ init_locales(void)
 }
 
 /* TODO: soll hier weg */
-extern attrib_type at_shiptrail;
+extern struct attrib_type at_shiptrail;
 
 attrib_type at_germs = {
   "germs",
@@ -2763,16 +2641,16 @@ plagues(region * r, boolean ismagic)
   if (!ismagic) {
     double mwp = max(maxworkingpeasants(r), 1);
     double prob = pow(rpeasants(r) / (mwp * wage(r, NULL, NULL) * 0.13), 4.0)
-        * SEUCHE;
+        * PLAGUE_CHANCE;
 
     if (rng_double() >= prob) return;
   }
 
   peasants = rpeasants(r);
-  dead = (int)(0.5F + SEUCHENOPFER * peasants);
+  dead = (int)(0.5F + PLAGUE_VICTIMS * peasants);
   for (i = dead; i != 0; i--) {
-    if (rng_int() % 100 < HEILCHANCE && rmoney(r) >= HEILKOSTEN) {
-      rsetmoney(r, rmoney(r) - HEILKOSTEN);
+    if (rng_double() < PLAGUE_HEALCHANCE && rmoney(r) >= PLAGUE_HEALCOST) {
+      rsetmoney(r, rmoney(r) - PLAGUE_HEALCOST);
     } else {
       --dead;
     }
diff --git a/src/common/kernel/eressea.h b/src/common/kernel/eressea.h
index f96629727..72f585a94 100644
--- a/src/common/kernel/eressea.h
+++ b/src/common/kernel/eressea.h
@@ -32,225 +32,27 @@ extern "C" {
  * your game to use) in there.
  * !!! DO NOT COMMIT THE SETTINGS.H FILE TO CVS !!!
  */
-#include <settings.h>
+#include "types.h"
 
-/* basic types used in the eressea "kernel" */
-#ifdef __TINYC__
-#define order_t short
-#define terrain_t short
-#define direction_t short
-#define race_t short
-#define magic_t short
-#define skill_t short
-#define typ_t short
-#define herb_t short
-#define luxury_t short
-#define weapon_t short
-#define item_t short
-#define spellid_t unsigned int
-#else
-typedef short order_t;
-typedef short terrain_t;
-typedef short direction_t;
-typedef short race_t;
-typedef short magic_t;
-typedef short skill_t;
-typedef short typ_t;
-typedef short herb_t;
-typedef short potion_t;
-typedef short luxury_t;
-typedef short weapon_t;
-typedef short item_t;
-typedef unsigned int spellid_t;
-#endif
-
-struct equipment;
-struct plane;
-struct order;
-struct spell;
-struct region;
-struct curse;
-struct fighter;
-struct region_list;
-struct race;
-struct ship;
-struct terrain_type;
-struct building;
-struct faction;
-struct party;
-struct unit;
-struct unit_list;
-struct item;
-struct skill;
-/* item */
-struct strlist;
-struct resource_type;
-struct item_type;
-struct potion_type;
-struct luxury_type;
-struct weapon_type;
-/* types */
-struct ship_type;
-struct building_type;
-
-#include <util/attrib.h>
-#include <util/cvector.h>
-#include <util/language.h>
-#include <util/lists.h>
-#include <util/log.h>
-#include <util/variant.h>
-#include <util/vmap.h>
-#include <util/vset.h>
-
-#define AT_PERSISTENT
 #define ALLIED(f1, f2) (f1==f2 || (f1->alliance && f1->alliance==f2->alliance))
 
-/* eressea-defined attribute-type flags */
-#define ATF_CURSE  ATF_USER_DEFINED
+/* experimental gameplay features (that don't affect the savefile) */
+#define GOBLINKILL /* Goblin-Spezialklau kann t�dlich enden */
+#define HERBS_ROT  /* herbs owned by units have a chance to rot. */
+#define SHIPDAMAGE /* Schiffsbesch�digungen */
+#define INSECT_POTION /* Spezialtrank f�r Insekten */
+#define ORCIFICATION /* gioving snotlings to the peasants gets counted */
+#undef TROLLSAVE /* saving throw for dead trolls */
+#undef AFFECT_SALARY /* gibt es ein attribut at_salary (ist noch nicht fertig!) */
 
-#define OLD_FAMILIAR_MOD /* conversion required */
-/* feature-dis/en-able */
-#define NEW_DRIVE     /* Neuer Algorithmus Transportiere/Fahre */
-#define PARTIAL_STUDY /* Wenn nicht genug Silber vorhanden, wird ein Talent anteilig gelernt */
-#define GOBLINKILL
+#include <settings.h>
 
 #define MONSTER_FACTION 0 /* Die Partei, in der die Monster sind. */
+#define MAXPEASANTS_PER_AREA 10 /* number of peasants per region-size */
+#define TREESIZE (MAXPEASANTS_PER_AREA-2) /* space used by trees (in #peasants) */
 
-/**
- * heaps and heaps of unsupported versions:
-	#define RACES_VERSION 91
-	#define MAGIEGEBIET_VERSION 92
-	#define FATTRIBS_VERSION 94
-	#define ATNORD_VERSION 95
-	#define NEWMAGIC 100
-	#define MEMSAVE_VERSION 101
-	#define BORDER_VERSION 102
-	#define ATNAME_VERSION 103
-	#define ATTRIBFIX_VERSION 104
-	#define BORDERID_VERSION 105
-	#define NEWROAD_VERSION 106
-	#define GUARD_VERSION 107
-	#define TIMEOUT_VERSION 108
-	#define GUARDFIX_VERSION 109
-	#define NEW_FACTIONID_VERSION 110
-	#define ACTIONFIX1_VERSION 111
-	#define SHIPTYPE_VERSION 112
-	#define GROUPS_VERSION 113
-	#define MSGLEVEL_VERSION 114
-	#define DISABLE_ROADFIX 114
-	#define FACTIONFLAGS_VERSION 114
-	#define KARMA_VERSION 114
-	#define FULL_BASE36_VERSION 115
- **/
-#define TYPES_VERSION 117
-#define ITEMTYPE_VERSION 190
-#define NOFOREST_VERSION 191
-#define REGIONAGE_VERSION 192
-#define CURSE_NO_VERSION 193
-#define EFFSTEALTH_VERSION 194
-#define MAGE_ATTRIB_VERSION 195
-#define GLOBAL_ATTRIB_VERSION 196
-#define BASE36IDS_VERSION 197
-#define NEWSOURCE_VERSION 197
-#define NEWSTATUS_VERSION 198
-#define NEWNAMES_VERSION 199
-#define LOCALE_VERSION 300
-#define GROUPATTRIB_VERSION 301
-#define NEWRESOURCE_VERSION 303
-#define GROWTREE_VERSION 305
-#define RANDOMIZED_RESOURCES_VERSION 306 /* should be the same, but doesn't work */
-#define NEWRACE_VERSION 307
-#define INTERIM_VERSION 309
-#define NEWSKILL_VERSION 309
-#define WATCHERS_VERSION 310
-#define OVERRIDE_VERSION 311
-#define CURSETYPE_VERSION 312
-#define ALLIANCES_VERSION 313
-#define DBLINK_VERSION 314
-#define CURSEVIGOURISFLOAT_VERSION 315
-#define SAVEXMLNAME_VERSION 316
-#define SAVEALLIANCE_VERSION 317
-#define CLAIM_VERSION 318
-#define BACTION_VERSION 319 /* building action gets a param string */
-#define NOLASTORDER_VERSION 320 /* do not use lastorder */
-#define SPELLNAME_VERSION 321 /* reference spells by name */
-#define TERRAIN_VERSION 322 /* terrains are a full type and saved by name */
-#define REGIONITEMS_VERSION 323 /* regions have items */
-#define ATTRIBREAD_VERSION 324 /* remove a_readint */
-#define CURSEFLAGS_VERSION 325 /* remove a_readint */
-
-#define MIN_VERSION CURSETYPE_VERSION
-#define REGIONOWNERS_VERSION 400
-
-#ifdef ENEMIES
-# define RELEASE_VERSION ENEMIES_VERSION
-#else
-# define RELEASE_VERSION CURSEFLAGS_VERSION
-#endif
-
-#define RESOURCE_CONVERSION
-
-#ifdef RESOURCE_CONVERSION
-extern void init_resourcefix(void);
-extern void read_iron(struct region * r, int iron);
-extern void read_laen(struct region * r, int laen);
-#endif
-
-#define ECHECK_VERSION "4.01"
-
-/* changes from->to: 72->73: struct unit::lock entfernt.
- * 73->74: struct unit::flags eingef�hrt.
- * 74->75: parteitarnung als flag.
- * 75->76: #ifdef NEW_HP: hp
- * 76->77: ship->damage
- * 77->78: neue Message-Option "Orkvermehrung" (MAX_MSG +1)
- * 78->79: showdata nicht mehr speichern
- * 79->HEX_VERSION: hex
- * 80->82: ATTRIB_VERSION
- * 90: Ebenen
- * 92: Magiegebiet-Auswahl f->magiegebiet
- * 94: f->attribs wird gespeichert
- * 100: NEWMAGIC, neue Message-Option "Zauber" (MAX_MSG +1)
- * 108: Speichern von Timeouts
- * 193: curse bekommen id aus struct unit-nummernraum
- */
-
-/* NEWMAIL benutzt ein spezielles Skript zum Erstellen der Reportmails */
-#define MAIL				"eresseamail"
-
-#define DEFAULT_LOCALE "de"
-
-#define MAXPEASANTS_PER_AREA    10
-
-/* So lange kann die Partei nicht angegriffen werden */
-#undef STUDY_IF_NOT_WORKING
-
-/** Attackierende Einheiten k�nnen keine langen Befehle ausf�hren */
-
-#define DISALLOW_ATTACK_AND_WORK
-
-/* Vermehrung trotz 90% Auslastung */
-#define PEASANTFORCE   0.75
-
-#define TREESIZE     (MAXPEASANTS_PER_AREA-2)
-
-/* Eisen in Bergregionen bei Erschaffung */
-#define IRONSTART     250
-/* Zuwachs Eisen in Bergregionen */
-#define IRONPERTURN    25
-#define MAXLAENPERTURN  6
-/* Eisen in Gletschern */
-#define GLIRONSTART    20
-/* Zuwachs Eisen in Gletschern */
-#define GLIRONPERTURN   3
-/* Maximales Eisen in Gletschern */
-#define MAXGLIRON      80
-
-/* Verrottchance f�r Kr�uter */
-#define HERBROTCHANCE 5
-#define HERBS_ROT
-
-#define STUDYCOST     200
+#define PEASANTFORCE 0.75 /* Chance einer Vermehrung trotz 90% Auslastung */
+#define HERBROTCHANCE 5 /* Verrottchance f�r Kr�uter (ifdef HERBS_ROT) */
 
 /* Geb�udegr��e = Minimalbelagerer */
 #define SIEGEFACTOR     2
@@ -260,56 +62,22 @@ extern void read_laen(struct region * r, int laen);
 #define MAXALCHEMISTS   3
 
 /** Plagues **/
-/* Seuchenwahrscheinlichkeit (siehe plagues()) */
-#define SEUCHE         0.1F
-/* % Betroffene */
-#define SEUCHENOPFER   0.2F
-extern void plagues(struct region * r, boolean ismagic);
-
-/** Healing **/
-/* Wahrscheinlichkeit Heilung */
-#define HEILCHANCE     25
-/* Heilkosten */
-#define HEILKOSTEN     30
+#define PLAGUE_CHANCE      0.1F /* Seuchenwahrscheinlichkeit (siehe plagues()) */
+#define PLAGUE_VICTIMS     0.2F /* % Betroffene */
+#define PLAGUE_HEALCHANCE  0.25F /* Wahrscheinlichkeit Heilung */
+#define PLAGUE_HEALCOST    30    /* Heilkosten */
 
 /** Monster */
 
-/* Chance f�r Monsterangriff */
-#define MONSTERATTACK  0.4
+#define MONSTERATTACK  0.4F /* Chance f�r Monsterangriff */
 
 /** Geb�ude */
-/* Chance f�r Einsturz bei unversorgtem Gebaeude */
-#define EINSTURZCHANCE     40
-/* Soviele % �berleben den Einsturz */
-#define EINSTURZUEBERLEBEN 50
-
-/** Geographie. Nicht im laufenden Spiel �ndern!!! */
-#define BLOCKSIZE           9
-
-/* Nur Bewaffnete bewachen */
-#undef TROLLSAVE
-
-/* Spezialtrank f�r Insekten */
-#define INSECT_POTION
-
-/* Schiffsbesch�digungen */
-#define SHIPDAMAGE
-
-/* regionen im Report der Parteien werden nur einmal berechnet: */
-#define FAST_REGION
+#define COLLAPSE_CHANCE    0.4F /* Chance f�r Einsturz bei unversorgtem Gebaeude */
+#define COLLAPSE_SURVIVAL  0.5F /* Soviele % �berleben den Einsturz */
 
 /* Magiesystem */
 #define NIGHT_EYE_TALENT        5
 
-/* gibt es ein attribut at_salary */
-#undef AFFECT_SALARY
-/* ist noch nicht fertig! */
-
-#define ARENA_PLANE
-#undef UNDERWORLD_PLANE
-
-#define ORCIFICATION
-
 /* Bewegungsweiten: */
 #define BP_WALKING 4
 #define BP_RIDING  6
@@ -335,448 +103,25 @@ extern void plagues(struct region * r, boolean ismagic);
 #define KEYWORDSIZE         15	/* max. L�nge eines Keyword, ohne trailing 0 */
 #define OBJECTIDSIZE        (NAMESIZE+5+IDSIZE)	/* max. L�nge der Strings, die
 						 * von struct unitname, etc. zur�ckgegeben werden. ohne die 0 */
-#define CMDSIZE             (DISPLAYSIZE*2+1)
-#define STARTMONEY          5000
-
-#define TAVERN_MAINTENANCE  14
-/* Man gibt in einer Taverne mehr Geld aus! */
 
 #define BAGCAPACITY		20000	/* soviel pa�t in einen Bag of Holding */
 #define STRENGTHCAPACITY	50000	/* zus�tzliche Tragkraft beim Kraftzauber (deprecated) */
 #define STRENGTHMULTIPLIER 50   /* multiplier for trollbelt */
 
-typedef struct ursprung {
-	struct ursprung *next;
-	int id;
-	short x, y;
-} ursprung;
-
 /* ----------------- Befehle ----------------------------------- */
 
-typedef unsigned char keyword_t;
-enum {
-  K_KOMMENTAR,
-  K_BANNER,
-  K_WORK,
-  K_ATTACK,
-  K_STEAL,
-  K_BESIEGE,
-  K_NAME,
-  K_USE,
-  K_DISPLAY,
-  K_ENTER,
-  K_GUARD,
-  K_MAIL,
-  K_END,
-  K_DRIVE,
-  K_NUMBER,
-  K_WAR,
-  K_PEACE,
-  K_FOLLOW,
-  K_RESEARCH,
-  K_GIVE,
-  K_ALLY,
-  K_STATUS,
-  K_COMBAT,
-  K_BUY,
-  K_CONTACT,
-  K_TEACH,
-  K_STUDY,
-  K_LIEFERE,
-  K_MAKE,
-  K_MOVE,
-  K_PASSWORD,
-  K_RECRUIT,
-  K_RESERVE,
-  K_ROUTE,
-  K_SABOTAGE,
-  K_SEND,
-  K_SPY,
-  K_QUIT,
-  K_SETSTEALTH,
-  K_TRANSPORT,
-  K_TAX,
-  K_ENTERTAIN,
-  K_SELL,
-  K_LEAVE,
-  K_FORGET,
-  K_CAST,
-  K_RESHOW,
-  K_DESTROY,
-  K_BREED,
-  K_DEFAULT,
-  K_URSPRUNG,
-  K_EMAIL,
-  K_VOTE,
-  K_MAGIEGEBIET,
-  K_PIRACY,
-  K_RESTART,
-  K_GROUP,
-  K_SACRIFICE,
-  K_PRAY,
-  K_SORT,
-  K_SETJIHAD,
-  K_GM,          /* perform GM commands */
-  K_INFO,        /* set player-info */
-  K_PREFIX,
-  K_SYNONYM,
-  K_PLANT,
-  K_WEREWOLF,
-  K_XE,
-  K_ALLIANCE,
-  K_CLAIM,
-#ifdef HEROES
-  K_PROMOTION,
-#endif
-  MAXKEYWORDS,
-  NOKEYWORD = (keyword_t) - 1
-};
-
 extern const char *keywords[MAXKEYWORDS];
-
-/* ------------------ Status von Einheiten --------------------- */
-
-typedef unsigned char status_t;
-enum {
-  ST_AGGRO,
-  ST_FIGHT,
-  ST_BEHIND,
-  ST_CHICKEN,
-  ST_AVOID,
-  ST_FLEE
-};
-
-/* ----------------- Parameter --------------------------------- */
-
-typedef unsigned char param_t;
-enum {
-	P_LOCALE,
-  P_ANY,
-  P_EACH,
-	P_PEASANT,
-	P_BUILDING,
-	P_UNIT,
-	P_PRIVAT,
-	P_BEHIND,
-	P_CONTROL,
-	P_HERBS,
-	P_NOT,
-	P_NEXT,
-	P_FACTION,
-	P_GAMENAME,
-	P_PERSON,
-	P_REGION,
-	P_SHIP,
-	P_SILVER,
-	P_ROAD,
-	P_TEMP,
-	P_FLEE,
-	P_GEBAEUDE,
-	P_GIB,
-	P_KAEMPFE,
-  P_TRAVEL,
-	P_GUARD,
-	P_ZAUBER,
-	P_PAUSE,
-	P_VORNE,
-	P_AGGRO,
-	P_CHICKEN,
-	P_LEVEL,
-	P_HELP,
-	P_FOREIGN,
-	P_AURA,
-	P_FOR,
-	P_AID,
-	P_MERCY,
-	P_AFTER,
-	P_BEFORE,
-	P_NUMBER,
-	P_ITEMS,
-	P_POTIONS,
-	P_GROUP,
-	P_FACTIONSTEALTH,
-	P_TREES,
-	P_XEPOTION,
-	P_XEBALLOON,
-	P_XELAEN,
-	MAXPARAMS,
-	NOPARAM = (param_t) - 1
-};
-
-typedef enum {					/* Fehler und Meldungen im Report */
-	MSG_BATTLE,
-	MSG_EVENT,
-	MSG_MOVE,
-	MSG_INCOME,
-	MSG_COMMERCE,
-	MSG_PRODUCE,
-	MSG_ORCVERMEHRUNG,
-	MSG_MESSAGE,
-	MSG_COMMENT,
-	MSG_MAGIC,
-	MAX_MSG
-} msg_t;
-
-enum {					/* Message-Level */
-	ML_IMPORTANT,				/* Sachen, die IMO erscheinen _muessen_ */
-	ML_DEBUG,
-	ML_MISTAKE,
-	ML_WARN,
-	ML_INFO,
-	ML_MAX
-};
-
 extern const char *parameters[MAXPARAMS];
 
-/* --------------- Reports Typen ------------------------------- */
-
-enum {
-	O_REPORT,				/* 1 */
-	O_COMPUTER,			/* 2 */
-	O_ZUGVORLAGE,		/* 4 */
-	O_SILBERPOOL,		/* 8 */
-	O_STATISTICS,		/* 16 */
-	O_DEBUG,				/* 32 */
-	O_COMPRESS,			/* 64 */
-	O_NEWS,					/* 128 */
-	O_MATERIALPOOL,	/* 256 */
-	O_ADRESSEN,			/* 512 */
-	O_BZIP2,				/* 1024 - compress as bzip2 */
-	O_SCORE,				/* 2048 - punkte anzeigen? */
-	O_SHOWSKCHANGE,	/* 4096 - Skillver�nderungen anzeigen? */
-  O_XML,    			/* 8192 - XML report versenden */
-	MAXOPTIONS
-};
-
-#define want(i) (1<<i)
-
+/** report options **/
+#define want(option) (1<<option)
 extern const char *options[MAXOPTIONS];
 
-/* ------------------ Talente ---------------------------------- */
-
-enum {
-	SK_ALCHEMY,
-	SK_CROSSBOW,
-	SK_MINING,
-	SK_LONGBOW,
-	SK_BUILDING,
-	SK_TRADE,
-	SK_LUMBERJACK,
-	SK_CATAPULT,
-	SK_HERBALISM,
-	SK_MAGIC,
-	SK_HORSE_TRAINING,			/* 10 */
-	SK_RIDING,
-	SK_ARMORER,
-	SK_SHIPBUILDING,
-	SK_MELEE,
-	SK_SAILING,
-	SK_SPEAR,
-	SK_SPY,
-	SK_QUARRYING,
-	SK_ROAD_BUILDING,
-	SK_TACTICS,					/* 20 */
-	SK_STEALTH,
-	SK_ENTERTAINMENT,
-	SK_WEAPONSMITH,
-	SK_CARTMAKER,
-	SK_OBSERVATION,
-	SK_TAXING,
-	SK_AUSDAUER,
-	SK_WEAPONLESS,
-	MAXSKILLS,
-	NOSKILL = (skill_t) -1
-};
-
-/* ------------- Typ von Einheiten ----------------------------- */
-
-enum {
-	RC_DWARF,		/* 0 - Zwerg */
-	RC_ELF,
-	RC_ORC,
-	RC_GOBLIN,
-	RC_HUMAN,
-
-  RC_TROLL,
-  RC_DAEMON,
-	RC_INSECT,
-	RC_HALFLING,
-	RC_CAT,
-
-  RC_AQUARIAN,
-  RC_URUK,
-	RC_SNOTLING,
-	RC_UNDEAD,
-	RC_ILLUSION,
-
-  RC_FIREDRAGON,
-  RC_DRAGON,
-	RC_WYRM,
-	RC_TREEMAN,
-	RC_BIRTHDAYDRAGON,
-
-  RC_DRACOID,
-	RC_SPECIAL,
-	RC_SPELL,
-	RC_IRONGOLEM,
-	RC_STONEGOLEM,
-
-  RC_SHADOW,
-  RC_SHADOWLORD,
-	RC_IRONKEEPER,
-	RC_ALP,
-	RC_TOAD,
-
-  RC_HIRNTOETER,
-	RC_PEASANT,
-	RC_WOLF = 32,
-
-	RC_SONGDRAGON = 37,
-
-  RC_SEASERPENT = 51,
-	RC_SHADOWKNIGHT, 
-	RC_CENTAUR,
-	RC_SKELETON,
-
-  RC_SKELETON_LORD,
-	RC_ZOMBIE,
-	RC_ZOMBIE_LORD,
-	RC_GHOUL,
-	RC_GHOUL_LORD,
-
-	RC_MUS_SPIRIT,
-	RC_GNOME,     
-	RC_TEMPLATE,  
-	RC_CLONE,
-
-	MAXRACES,
-	NORACE = (race_t) - 1
-};
-
-/* movewhere error codes */
-enum {
-  E_MOVE_OK = 0,   /* possible to move */
-  E_MOVE_NOREGION, /* no region exists in this direction */
-  E_MOVE_BLOCKED   /* cannot see this region, there is a blocking border. */
-};
-
-/* Richtungen */
-enum {
-	D_NORTHWEST,
-	D_NORTHEAST,
-	D_EAST,
-	D_SOUTHEAST,
-	D_SOUTHWEST,
-	D_WEST,
-	MAXDIRECTIONS,
-	D_PAUSE,
-  D_SPECIAL,
-	NODIRECTION = (direction_t) - 1
-};
-
-/* Jahreszeiten, siehe auch res/timestrings */
-enum {
-	SEASON_WINTER,
-	SEASON_SPRING,
-	SEASON_SUMMER,
-	SEASON_AUTUMN
-};
-
-/* Siegbedingungen */
-
-#define VICTORY_NONE   0
-#define VICTORY_MURDER 1
-
 /* ------------------------------------------------------------- */
 
 extern int shipspeed(const struct ship * sh, const struct unit * u);
 extern int init_data(const char * filename);
 
-/* MAXSPEED setzt die groesse fuer den Array, der die Kuesten Beschreibungen
- * enthaelt. MAXSPEED muss 2x +3 so gross wie die groesste Geschw. sein
- * (Zauberspruch) */
-
-/* ------------------------------------------------------------- */
-
-/* ------------------------------------------------------------- */
-/* TODO
- * werden diese hier eigendlich noch f�r irgendwas gebraucht?*/
-
-
-/* Attribute: auf Einheiten */
-
-/* Klassen */
-
-enum {
-	A_KL_GEGENSTAND,
-	A_KL_EIGENSCHAFT
-};
-/* Eigenschaften (in i[0]) */
-
-#define ZEIGE_PARTEI	1		/* Zeigt s[0] in eigenem Report an */
-#define ZEIGE_ANDEREN 2			/* Zeigt s[1] in fremden Reports an */
-#define TALENTMOD			4	/* Gegenstand ver�ndert Talent
-						 * i[2] um i[3] */
-
-/* A_KL_EIGENSCHAFT */
-
-enum {
-	A_TY_NOT_PARTEI_GETARNT,	/* In i[0] die Pseudopartei?! */
-	A_TY_NOT_FLAGS,		/* Verschiedene Eigenschaften in i[0] */
-	A_TY_EX_TYPNAME,		/* Was soll als Typname erscheinen? s[0] =
-				 * Singular, s[1] = Plural */
-	A_TY_EX_ZIELREGION,
-	A_TY_EX_BAUERNBLUT		/* In i[0] die Zahl der max. gesch�tzten
-				 * D�monen. */
-};
-
-/* A_TY_GESEHEN:    fuer cansee() in i[0] steht drin, welche Partei uns
- * sah, in i[1], wie gut (0,1 oder 2) */
-
-/* Auf Regionen */
-
-/* Klassen */
-
-enum {
-	A_KL_MERKMAL,
-	A_KL_ZAUBER
-};
-
-/* A_KL_MERKMAL */
-
-enum {
-	A_TY_MITHRIL,
-	A_TY_ADAMANTIUM,
-	A_TY_DIRECTION		/* In s[0] describe_txt, in s[1] das command,
-											 in i[0]-i[2] die Koordinaten des Ziels. */
-};
-
-/* Auf Schiffen */
-
-/* Klassen */
-
-enum {
-	A_KL_MERKMAL_SCHIFF
-};
-
-/* A_KL_MERKMAL */
-
-enum {
-	A_TY_EX_KUESTE		/* In i[0] steht die Richtung */
-};
-
-/* Auf Borders */
-
-/* Klassen */
-
-enum {
-	A_KL_BLOCK
-};
-
-enum {
-	A_TY_LOCK
-};
-
 #define DONT_HELP      0
 #define HELP_MONEY     1			/* Mitversorgen von Einheiten */
 #define HELP_FIGHT     2			/* Bei Verteidigung mithelfen */
@@ -795,8 +140,6 @@ enum {
 #define ALLIED_NOBLOCK 2
 #define ALLIED_HELP    4
 
-extern vmap region_map;
-
 #define i2b(i) ((boolean)((i)?(true):(false)))
 
 typedef struct ally {
@@ -814,16 +157,6 @@ typedef struct strlist {
 	char * s;
 } strlist;
 
-#define FL_DH             (1<<18) /* ehemals f->dh, u->dh, r->dh, etc... */
-#define FL_MARK           (1<<23) /* f�r markierende algorithmen, die das 
-                                   * hinterher auch wieder l�schen m�ssen! 
-                                   * (FL_DH muss man vorher initialisieren, 
-                                   * FL_MARK hinterher l�schen) */
-
-/* alle vierstelligen zahlen: */
-#define MAX_UNIT_NR (36*36*36*36-1)
-#define MAX_CONTAINER_NR (36*36*36*36-1)
-
 #define fval(u, i) ((u)->flags & (i))
 #define fset(u, i) ((u)->flags |= (i))
 #define freset(u, i) ((u)->flags &= ~(i))
@@ -919,7 +252,6 @@ int forbiddenid(int id);
 int newcontainerid(void);
 
 extern struct unit *createunit(struct region * r, struct faction * f, int number, const struct race * rc);
-extern struct unit *create_unit(struct region * r1, struct faction * f, int number, const struct race * rc, int id, const char * dname, struct unit *creator);
 extern void create_unitid(struct unit *u, int id);
 extern boolean getunitpeasants;
 extern struct unit *getunitg(const struct region * r, const struct faction * f);
@@ -1054,11 +386,18 @@ extern int maxworkingpeasants(const struct region * r);
 
 extern int wage(const struct region *r, const struct faction *f, const struct race * rc);
 extern int maintenance_cost(const struct unit * u);
-extern int movewhere(const struct unit *u, const char * token, struct region * r, struct region** resultp);
 extern struct message * movement_error(struct unit * u, const char * token, struct order * ord, int error_code);
 extern boolean move_blocked(const struct unit * u, const struct region *src, const struct region *dest);
 extern void add_income(struct unit * u, int type, int want, int qty);
 
+/* movewhere error codes */
+enum {
+  E_MOVE_OK = 0,   /* possible to move */
+  E_MOVE_NOREGION, /* no region exists in this direction */
+  E_MOVE_BLOCKED   /* cannot see this region, there is a blocking border. */
+};
+extern int movewhere(const struct unit *u, const char * token, struct region * r, struct region** resultp);
+
 extern const char * basepath(void);
 extern const char * resourcepath(void);
 extern void kernel_init(void);
@@ -1122,7 +461,9 @@ extern int entertainmoney(const struct region * r);
 extern int freadstr(FILE * F, char * str, size_t size);
 extern int fwritestr(FILE * F, const char * str);
 
-extern attrib_type at_guard;
+extern void plagues(struct region * r, boolean ismagic);
+
+extern struct attrib_type at_guard;
 
 #if 1 /* disable to count all units */
 # define count_unit(u) playerrace(u->race)
diff --git a/src/common/kernel/faction.c b/src/common/kernel/faction.c
index 2a7fe5741..125872f3f 100644
--- a/src/common/kernel/faction.c
+++ b/src/common/kernel/faction.c
@@ -25,11 +25,14 @@
 #include "region.h"
 #include "terrain.h"
 #include "unit.h"
+#include "version.h"
 
 /* util includes */
+#include <util/attrib.h>
 #include <util/base36.h>
 #include <util/event.h>
 #include <util/goodies.h>
+#include <util/lists.h>
 #include <util/resolve.h>
 #include <util/rng.h>
 #include <util/variant.h>
diff --git a/src/common/kernel/faction.h b/src/common/kernel/faction.h
index 2e21d582e..dea2ab082 100644
--- a/src/common/kernel/faction.h
+++ b/src/common/kernel/faction.h
@@ -38,9 +38,12 @@ typedef struct shortpwd {
 #define FFL_ISNEW         (1<<1)
 #define FFL_RESTART       (1<<2)
 #define FFL_QUIT          (1<<3)
-/* #define FL_DH             (1<<18) */
+#define FFL_SELECT        (1<<18) /* ehemals f->dh, u->dh, r->dh, etc... */
 #define FFL_NOAID         (1<<21) /* Hilfsflag Kampf */
-/* #define FL_MARK           (1<<23) */
+#define FFL_MARK          (1<<23) /* f�r markierende algorithmen, die das 
+                                   * hinterher auch wieder l�schen m�ssen! 
+                                   * (FL_DH muss man vorher initialisieren, 
+                                   * FL_MARK hinterher l�schen) */
 #define FFL_NOIDLEOUT     (1<<24) /* Partei stirbt nicht an NMRs */
 #define FFL_OVERRIDE      (1<<27) /* Override-Passwort wurde benutzt */
 #define FFL_DBENTRY       (1<<28) /* Partei ist in Datenbank eingetragen */
diff --git a/src/common/kernel/group.c b/src/common/kernel/group.c
index 49125db94..48526eb33 100644
--- a/src/common/kernel/group.c
+++ b/src/common/kernel/group.c
@@ -20,13 +20,15 @@
 #include "unit.h"
 #include "faction.h"
 #include "save.h"
+#include "version.h"
 
 /* attrib includes */
 #include <attributes/raceprefix.h>
 
 /* util includes */
-#include <resolve.h>
-#include <base36.h>
+#include <util/attrib.h>
+#include <util/base36.h>
+#include <util/resolve.h>
 
 /* libc includes */
 #include <stdlib.h>
diff --git a/src/common/kernel/group.h b/src/common/kernel/group.h
index d31ac94c7..09e40e5e2 100644
--- a/src/common/kernel/group.h
+++ b/src/common/kernel/group.h
@@ -24,7 +24,7 @@ typedef struct group {
 	struct group * next;
 	struct group * nexthash;
 	struct faction * f;
-	attrib *attribs;
+	struct attrib *attribs;
 	char * name;
 	struct ally * allies;
 	int flags;
@@ -32,11 +32,11 @@ typedef struct group {
 	int members;
 } group;
 
-extern attrib_type at_group; /* attribute for units assigned to a group */
+extern struct attrib_type at_group; /* attribute for units assigned to a group */
 extern boolean join_group(struct unit * u, const char* name);
-extern void free_group(group * g);
+extern void free_group(struct group * g);
 
-extern void write_groups(FILE * F, group * g);
+extern void write_groups(FILE * F, struct group * g);
 extern void read_groups(FILE * F, struct faction * f);
 
 #ifdef __cplusplus
diff --git a/src/common/kernel/item.c b/src/common/kernel/item.c
index 8eae794f8..edfc49632 100644
--- a/src/common/kernel/item.c
+++ b/src/common/kernel/item.c
@@ -35,6 +35,7 @@
 #include <triggers/timeout.h>
 
 /* util includes */
+#include <util/attrib.h>
 #include <util/event.h>
 #include <util/functions.h>
 #include <util/goodies.h>
@@ -76,8 +77,7 @@ enum {
   H_GLACIER_1,
   H_GLACIER_2,
   H_GLACIER_3,
-  MAX_HERBS,
-  NOHERB = (herb_t) - 1
+  MAX_HERBS
 };
 
 static int
diff --git a/src/common/kernel/kernel.vcproj b/src/common/kernel/kernel.vcproj
index 641c1a514..02f6af4a7 100644
--- a/src/common/kernel/kernel.vcproj
+++ b/src/common/kernel/kernel.vcproj
@@ -288,6 +288,9 @@
 			<File
 				RelativePath=".\terrain.h">
 			</File>
+			<File
+				RelativePath=".\types.h">
+			</File>
 			<File
 				RelativePath=".\unit.h">
 			</File>
diff --git a/src/common/kernel/magic.c b/src/common/kernel/magic.c
index 39a85439f..99f3094fe 100644
--- a/src/common/kernel/magic.c
+++ b/src/common/kernel/magic.c
@@ -42,6 +42,7 @@
 #include "spellid.h"
 #include "terrain.h"
 #include "unit.h"
+#include "version.h"
 
 #include <triggers/timeout.h>
 #include <triggers/shock.h>
@@ -52,6 +53,7 @@
 
 /* util includes */
 #include <util/attrib.h>
+#include <util/lists.h>
 #include <util/resolve.h>
 #include <util/rand.h>
 #include <util/rng.h>
diff --git a/src/common/kernel/magic.h b/src/common/kernel/magic.h
index 9b63ae6bf..a5a66eb9b 100644
--- a/src/common/kernel/magic.h
+++ b/src/common/kernel/magic.h
@@ -226,14 +226,14 @@ void magic(void);
 
 void regeneration_magiepunkte(void);
 
-extern attrib_type at_seenspell;
-extern attrib_type at_mage;
-extern attrib_type at_familiarmage;
-extern attrib_type at_familiar;
-extern attrib_type at_clonemage;
-extern attrib_type at_clone;
-extern attrib_type at_reportspell;
-extern attrib_type at_icastle;
+extern struct attrib_type at_seenspell;
+extern struct attrib_type at_mage;
+extern struct attrib_type at_familiarmage;
+extern struct attrib_type at_familiar;
+extern struct attrib_type at_clonemage;
+extern struct attrib_type at_clone;
+extern struct attrib_type at_reportspell;
+extern struct attrib_type at_icastle;
 
 typedef struct icastle_data {
 	const struct building_type * type;
diff --git a/src/common/kernel/movement.c b/src/common/kernel/movement.c
index a6169a229..1020663b7 100644
--- a/src/common/kernel/movement.c
+++ b/src/common/kernel/movement.c
@@ -50,6 +50,7 @@
 #include <util/base36.h>
 #include <util/goodies.h>
 #include <util/language.h>
+#include <util/lists.h>
 #include <util/rand.h>
 #include <util/rng.h>
 
@@ -761,14 +762,14 @@ drifting_ships(region * r)
         unit *u, *lastu = NULL;
         message * msg = msg_message("ship_drift", "ship dir", sh, dir);
         for (u=firstu;u;u=u->next) {
-          if (u->ship==sh && !fval(u->faction, FL_MARK)) {
-            fset(u->faction, FL_MARK);
+          if (u->ship==sh && !fval(u->faction, FFL_MARK)) {
+            fset(u->faction, FFL_MARK);
             add_message(&u->faction->msgs, msg);
             lastu = u->next;
           }
         }
         for (u=firstu;u!=lastu;u=u->next) {
-          freset(u->faction, FL_MARK);
+          freset(u->faction, FFL_MARK);
         }
         msg_release(msg);
       }
@@ -2373,8 +2374,7 @@ move_hunters(void)
   region *r;
 
   for (r = regions; r; r = r->next) {
-    unit ** up = &r->units, * u;
-    for (u=r->units; u; u=u->next) freset(u, FL_DH);
+    unit ** up = &r->units;
 
     while (*up!=NULL) {
       unit * u = *up;
diff --git a/src/common/kernel/names.c b/src/common/kernel/names.c
index c0983c665..9991b421d 100644
--- a/src/common/kernel/names.c
+++ b/src/common/kernel/names.c
@@ -707,16 +707,3 @@ abkz(const char *s, size_t max)
 
 	return buf;
 }
-
-void
-name_unit(unit *u)
-{
-	char name[16];
-
-	if (u->race->generate_name) {
-		set_string(&u->name, (u->race->generate_name(u)));
-	} else {
-		sprintf(name, "%s %s", LOC(u->faction->locale, "unitdefault"), itoa36(u->no));
-		set_string(&u->name, name);
-	}
-}
diff --git a/src/common/kernel/names.h b/src/common/kernel/names.h
index 496986bf4..7a6249c9d 100644
--- a/src/common/kernel/names.h
+++ b/src/common/kernel/names.h
@@ -27,7 +27,6 @@ const char *drachen_name(const struct unit *u);
 const char *dracoid_name(const struct unit *u);
 const char *shadow_name(const struct unit *u);
 const char *abkz(const char *s, size_t max);
-void name_unit(struct unit *u);
 
 #ifdef __cplusplus
 }
diff --git a/src/common/kernel/order.c b/src/common/kernel/order.c
index a8b89aeef..adcd773b2 100644
--- a/src/common/kernel/order.c
+++ b/src/common/kernel/order.c
@@ -12,11 +12,12 @@
 
 #include <config.h>
 #include "eressea.h"
-
 #include "order.h"
+
 #include "skill.h"
 
 #include <util/bsdstring.h>
+#include <util/language.h>
 
 /* libc includes */
 #include <assert.h>
@@ -263,12 +264,10 @@ parse_order(const char * s, const struct locale * lang)
     int persistent = 0;
     int lindex;
 
-#ifdef AT_PERSISTENT
     while (*s=='@') {
       persistent = 1;
       ++s;
     }
-#endif
     sptr = s;
     kwd = findkeyword(parse_token(&sptr), lang);
     while (isspace(*(unsigned char*)sptr)) ++sptr;
diff --git a/src/common/kernel/order.h b/src/common/kernel/order.h
index 7eba0e8aa..fd3d1fcc1 100644
--- a/src/common/kernel/order.h
+++ b/src/common/kernel/order.h
@@ -69,6 +69,8 @@ extern boolean is_exclusive(const order *ord);
 extern boolean is_repeated(const order * ord);
 
 extern char * write_order(const order * ord, const struct locale * lang, char * buffer, size_t size);
+
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/common/kernel/pathfinder.c b/src/common/kernel/pathfinder.c
index 5b6652a27..85056b2b1 100644
--- a/src/common/kernel/pathfinder.c
+++ b/src/common/kernel/pathfinder.c
@@ -99,7 +99,7 @@ free_nodes(node * root)
 {
   while (root!=NULL) {
     region * r = root->r;
-    freset(r, FL_MARK);
+    freset(r, RF_MARK);
     root = free_node(root);
   }
 }
@@ -121,7 +121,7 @@ regions_in_range(struct region * start, int maxdist, boolean (*allowed)(const st
     for (d=0;d!=MAXDIRECTIONS; ++d) {
       region * rn = rconnect(r, d);
       if (rn==NULL) continue;
-      if (fval(rn, FL_MARK)) continue; /* already been there */
+      if (fval(rn, RF_MARK)) continue; /* already been there */
       if (allowed && !allowed(r, rn)) continue; /* can't go there */
 
       /* add the region to the list of available ones. */
@@ -129,7 +129,7 @@ regions_in_range(struct region * start, int maxdist, boolean (*allowed)(const st
 
       /* make sure we don't go here again, and put the region into the set for
          further BFS'ing */
-      fset(rn, FL_MARK);
+      fset(rn, RF_MARK);
       *end = new_node(rn, depth, n);
       end = &(*end)->next;
     }
@@ -150,7 +150,7 @@ internal_path_find(region *start, const region *target, int maxlen, boolean (*al
 	node * n = root;
 	boolean found = false;
 	assert(maxlen<=MAXDEPTH);
-	fset(start, FL_MARK);
+	fset(start, RF_MARK);
 
 	while (n!=NULL) {
 		region * r = n->r;
@@ -159,7 +159,7 @@ internal_path_find(region *start, const region *target, int maxlen, boolean (*al
 		for (d=0;d!=MAXDIRECTIONS; ++d) {
 			region * rn = rconnect(r, d);
 			if (rn==NULL) continue;
-			if (fval(rn, FL_MARK)) continue; /* already been there */
+			if (fval(rn, RF_MARK)) continue; /* already been there */
 			if (!allowed(r, rn)) continue; /* can't go there */
 			if (rn==target) {
 				int i = depth;
@@ -172,7 +172,7 @@ internal_path_find(region *start, const region *target, int maxlen, boolean (*al
 				found = true;
 				break;
 			} else {
-				fset(rn, FL_MARK);
+				fset(rn, RF_MARK);
 				*end = new_node(rn, depth, n);
 				end = &(*end)->next;
 			}
@@ -188,7 +188,7 @@ internal_path_find(region *start, const region *target, int maxlen, boolean (*al
 boolean
 path_exists(region *start, const region *target, int maxlen, boolean (*allowed)(const region*, const region*))
 {
-	assert((!fval(start, FL_MARK) && !fval(target, FL_MARK)) || !"Some Algorithm did not clear its FL_MARKs!");
+	assert((!fval(start, RF_MARK) && !fval(target, RF_MARK)) || !"Some Algorithm did not clear its RF_MARKs!");
 	if (start==target) return true;
 	if (internal_path_find(start, target, maxlen, allowed)!=NULL) return true;
 	return false;
@@ -197,6 +197,6 @@ path_exists(region *start, const region *target, int maxlen, boolean (*allowed)(
 region **
 path_find(region *start, const region *target, int maxlen, boolean (*allowed)(const region*, const region*))
 {
-	assert((!fval(start, FL_MARK) && !fval(target, FL_MARK)) || !"Did you call path_init()?");
+	assert((!fval(start, RF_MARK) && !fval(target, RF_MARK)) || !"Did you call path_init()?");
 	return internal_path_find(start, target, maxlen, allowed);
 }
diff --git a/src/common/kernel/plane.c b/src/common/kernel/plane.c
index 3fa3b0663..b148846cf 100644
--- a/src/common/kernel/plane.c
+++ b/src/common/kernel/plane.c
@@ -28,7 +28,9 @@
 #include "faction.h"
 
 /* util includes */
-#include <resolve.h>
+#include <util/attrib.h>
+#include <util/resolve.h>
+#include <util/lists.h>
 
 /* libc includes */
 #include <assert.h>
diff --git a/src/common/kernel/race.c b/src/common/kernel/race.c
index b881a1146..23eb99811 100644
--- a/src/common/kernel/race.c
+++ b/src/common/kernel/race.c
@@ -41,6 +41,7 @@
 #include "skill.h"
 #include "terrain.h"
 #include "unit.h"
+#include "version.h"
 
 /* util includes */
 #include <util/attrib.h>
diff --git a/src/common/kernel/region.c b/src/common/kernel/region.c
index ff44e6864..1dab44237 100644
--- a/src/common/kernel/region.c
+++ b/src/common/kernel/region.c
@@ -40,6 +40,8 @@
 #include "unit.h"
 
 /* util includes */
+#include <util/attrib.h>
+#include <util/lists.h>
 #include <util/resolve.h>
 #include <util/rng.h>
 
@@ -200,13 +202,14 @@ a_agedirection(attrib *a)
 static int
 a_readdirection(attrib *a, FILE *f)
 {
+  char lbuf[16];
   spec_direction *d = (spec_direction *)(a->data.v);
   fscanf(f, "%hd %hd %d", &d->x, &d->y, &d->duration);
-  fscanf(f, "%s ", buf);
-  d->desc = strdup(cstring(buf));
-  fscanf(f, "%s ", buf);
-  d->keyword = strdup(cstring(buf));
-        d->active = true;
+  fscanf(f, "%15s ", lbuf);
+  d->desc = strdup(cstring(lbuf));
+  fscanf(f, "%15s ", lbuf);
+  d->keyword = strdup(cstring(lbuf));
+  d->active = true;
   return AT_READ_OK;
 }
 
@@ -533,8 +536,6 @@ attrib_type at_travelunit = {
 };
 
 extern int laen_read(attrib * a, FILE * F);
-#define LAEN_READ laen_read
-#define LAEN_WRITE NULL
 
 /***************/
 /*   at_laen   */
@@ -544,8 +545,8 @@ attrib_type at_laen = {
   DEFAULT_INIT,
   DEFAULT_FINALIZE,
   DEFAULT_AGE,
-  LAEN_WRITE,
-  LAEN_READ,
+  NULL,
+  laen_read,
   ATF_UNIQUE
 };
 
diff --git a/src/common/kernel/region.h b/src/common/kernel/region.h
index f68f5cac3..38c5fc47b 100644
--- a/src/common/kernel/region.h
+++ b/src/common/kernel/region.h
@@ -46,7 +46,8 @@ extern "C" {
 #define RF_COMBATDEBUG (1<<14)
 #define RF_MAPPER_HIGHLIGHT (1<<14) /* only used by mapper, not stored */
 
-#define RF_DH          (1<<18)
+#define RF_SELECT      (1<<17)
+#define RF_MARK        (1<<18)
 
 /* flags that speed up attribute access: */
 #define RF_TRAVELUNIT    (1<<19)
@@ -146,16 +147,16 @@ int koor_distance(int ax, int ay, int bx, int by) ;
 extern direction_t reldirection(const struct region * from, const struct region * to);
 extern struct region * findregion(short x, short y);
 
-extern attrib_type at_direction;
-extern attrib_type at_moveblock;
+extern struct attrib_type at_direction;
+extern struct attrib_type at_moveblock;
 /* new: */
-extern attrib_type at_peasantluck;
-extern attrib_type at_horseluck;
-extern attrib_type at_chaoscount;
-extern attrib_type at_woodcount;
-extern attrib_type at_deathcount;
-extern attrib_type at_travelunit;
-extern attrib_type at_laen;
+extern struct attrib_type at_peasantluck;
+extern struct attrib_type at_horseluck;
+extern struct attrib_type at_chaoscount;
+extern struct attrib_type at_woodcount;
+extern struct attrib_type at_deathcount;
+extern struct attrib_type at_travelunit;
+extern struct attrib_type at_laen;
 
 void initrhash(void);
 void rhash(struct region * r);
diff --git a/src/common/kernel/reports.c b/src/common/kernel/reports.c
index 6e59ad6af..dfcb8d867 100644
--- a/src/common/kernel/reports.c
+++ b/src/common/kernel/reports.c
@@ -22,10 +22,9 @@
 #include "reports.h"
 
 /* kernel includes */
-#include <kernel/curse.h>
-#include <kernel/building.h>
 #include <kernel/border.h>
-#include <kernel/terrain.h>
+#include <kernel/building.h>
+#include <kernel/curse.h>
 #include <kernel/faction.h>
 #include <kernel/group.h>
 #include <kernel/item.h>
@@ -38,13 +37,16 @@
 #include <kernel/region.h>
 #include <kernel/ship.h>
 #include <kernel/skill.h>
+#include <kernel/terrain.h>
 #include <kernel/unit.h>
 
 /* util includes */
+#include <util/attrib.h>
 #include <util/bsdstring.h>
 #include <util/base36.h>
 #include <util/functions.h>
 #include <util/goodies.h>
+#include <util/lists.h>
 
 /* libc includes */
 #include <assert.h>
@@ -1077,21 +1079,21 @@ get_regions_distance(region * root, int radius)
   region_list * rptr, * rlist = NULL;
   region_list ** rp = &rlist;
   add_regionlist(rp, root);
-  fset(root, FL_MARK);
+  fset(root, RF_MARK);
   while (*rp) {
     region_list * r = *rp;
     direction_t d;
     rp = &r->next;
     for (d=0;d!=MAXDIRECTIONS;++d) {
       region * rn = rconnect(r->data, d);
-      if (rn!=NULL && !fval(rn, FL_MARK) && distance(rn, root)<=radius) {
+      if (rn!=NULL && !fval(rn, RF_MARK) && distance(rn, root)<=radius) {
         add_regionlist(rp, rn);
-        fset(rn, FL_MARK);
+        fset(rn, RF_MARK);
       }
     }
   }
   for (rptr=rlist;rptr;rptr=rptr->next) {
-    freset(rptr->data, FL_MARK);
+    freset(rptr->data, RF_MARK);
   }
   return rlist;
 }
diff --git a/src/common/kernel/save.c b/src/common/kernel/save.c
index 3f308544a..2764aff54 100644
--- a/src/common/kernel/save.c
+++ b/src/common/kernel/save.c
@@ -47,6 +47,7 @@
 #include "terrain.h"
 #include "terrainid.h" /* only for conversion code */
 #include "unit.h"
+#include "version.h"
 
 /* attributes includes */
 #include <attributes/key.h>
@@ -57,6 +58,7 @@
 #include <util/bsdstring.h>
 #include <util/event.h>
 #include <util/goodies.h>
+#include <util/lists.h>
 #include <util/resolve.h>
 #include <util/sql.h>
 #include <util/rand.h>
@@ -87,7 +89,36 @@ static region * current_region;
 
 
 #ifdef RESOURCE_CONVERSION
-int laen_read(attrib * a, FILE * F)
+struct attrib_type at_resources = {
+  "resources", NULL, NULL, NULL, NULL, NULL, ATF_UNIQUE
+};
+
+static void
+read_iron(struct region * r, int iron)
+{
+  attrib * a = a_find(r->attribs, &at_resources);
+  assert(iron>=0);
+  if (a==NULL) {
+    a = a_add(&r->attribs, a_new(&at_resources));
+    a->data.sa[1] = -1;
+  }
+  a->data.sa[0] = (short)iron;
+}
+
+static void
+read_laen(struct region * r, int laen)
+{
+  attrib * a = a_find(r->attribs, &at_resources);
+  assert(laen>=0);
+  if (a==NULL) {
+    a = a_add(&r->attribs, a_new(&at_resources));
+    a->data.sa[0] = -1;
+  }
+  a->data.sa[1] = (short)laen;
+}
+
+int
+laen_read(attrib * a, FILE * F)
 {
 	int laen;
 	fscanf(F, "%d", &laen);
@@ -760,36 +791,6 @@ read_items(FILE *F, item **ilist)
 	}
 }
 
-#ifdef RESOURCE_CONVERSION
-struct attrib_type at_resources = {
-	"resources", NULL, NULL, NULL, NULL, NULL, ATF_UNIQUE
-};
-
-void
-read_iron(struct region * r, int iron)
-{
-	attrib * a = a_find(r->attribs, &at_resources);
-	assert(iron>=0);
-	if (a==NULL) {
-		a = a_add(&r->attribs, a_new(&at_resources));
-		a->data.sa[1] = -1;
-	}
-	a->data.sa[0] = (short)iron;
-}
-
-void
-read_laen(struct region * r, int laen)
-{
-	attrib * a = a_find(r->attribs, &at_resources);
-	assert(laen>=0);
-	if (a==NULL) {
-		a = a_add(&r->attribs, a_new(&at_resources));
-		a->data.sa[0] = -1;
-	}
-	a->data.sa[1] = (short)laen;
-}
-#endif
-
 static void
 read_alliances(FILE * F)
 {
@@ -939,7 +940,7 @@ lastturn(void)
 }
 
 void
-fwriteorder(FILE * F, const order * ord, const struct locale * lang)
+fwriteorder(FILE * F, const struct order * ord, const struct locale * lang)
 {
   write_order(ord, lang, buf, sizeof(buf));
   if (buf[0]) fwritestr(F, buf);
diff --git a/src/common/kernel/save.h b/src/common/kernel/save.h
index 550420868..e3852d81d 100644
--- a/src/common/kernel/save.h
+++ b/src/common/kernel/save.h
@@ -56,10 +56,6 @@ extern void write_items(FILE *f, struct item *it);
 
 extern const char * datapath(void);
 
-#ifdef RESOURCE_CONVERSION
-extern struct attrib_type at_resources;
-#endif
-
 extern void writeunit(FILE * stream, const struct unit * u);
 extern struct unit * readunit(FILE * stream);
 
diff --git a/src/common/kernel/ship.c b/src/common/kernel/ship.c
index d65cbf810..bded2a964 100644
--- a/src/common/kernel/ship.c
+++ b/src/common/kernel/ship.c
@@ -27,6 +27,7 @@
 #include <util/base36.h>
 #include <util/event.h>
 #include <util/language.h>
+#include <util/lists.h>
 #include <util/umlaut.h>
 #include <util/xml.h>
 
diff --git a/src/common/kernel/ship.h b/src/common/kernel/ship.h
index c2ff51d3e..2ed7e0eb8 100644
--- a/src/common/kernel/ship.h
+++ b/src/common/kernel/ship.h
@@ -63,6 +63,7 @@ extern void st_register(const ship_type * type);
 #define SF_DRIFTED 1<<0
 #define SF_MOVED   1<<1
 #define SF_DAMAGED 1<<2 /* for use in combat */
+#define SF_SELECT  1<<3 /* previously FL_DH */
 
 typedef struct ship {
 	struct ship *next;
diff --git a/src/common/kernel/skill.c b/src/common/kernel/skill.c
index 8de88267f..352753eef 100644
--- a/src/common/kernel/skill.c
+++ b/src/common/kernel/skill.c
@@ -24,6 +24,7 @@
 #include "skill.h"
 
 #include "curse.h"
+#include "karma.h"
 #include "item.h"
 #include "magic.h"
 #include "race.h"
@@ -31,10 +32,10 @@
 #include "terrain.h"
 #include "terrainid.h"
 #include "unit.h"
-#include "karma.h"
 
 #include <util/attrib.h>
 #include <util/goodies.h>
+#include <util/log.h>
 #include <util/rng.h>
 
 /* libc includes */
diff --git a/src/common/kernel/skill.h b/src/common/kernel/skill.h
index efbcea363..a04022e7a 100644
--- a/src/common/kernel/skill.h
+++ b/src/common/kernel/skill.h
@@ -39,9 +39,9 @@ typedef struct skillmod_data {
 	int bonus;
 	int flags;
 } skillmod_data;
-extern attrib_type at_skillmod;
+extern struct attrib_type at_skillmod;
 extern int rc_skillmod(const struct race * rc, const struct region *r, skill_t sk);
-extern int skillmod(const attrib * a, const struct unit * u, const struct region * r, skill_t sk, int value, int flags);
+extern int skillmod(const struct attrib * a, const struct unit * u, const struct region * r, skill_t sk, int value, int flags);
 extern void skill_init(void);
 extern void skill_done(void);
 extern struct attrib * make_skillmod(skill_t sk, unsigned int flags, skillmod_fun special, double multiplier, int bonus);
diff --git a/src/common/kernel/spy.c b/src/common/kernel/spy.c
index 4a5b0bb10..90bcd53dd 100644
--- a/src/common/kernel/spy.c
+++ b/src/common/kernel/spy.c
@@ -43,9 +43,10 @@
 #include <attributes/racename.h>
 
 /* util includes */
-#include <util/vset.h>
+#include <util/attrib.h>
 #include <util/rand.h>
 #include <util/rng.h>
+#include <util/vset.h>
 
 /* libc includes */
 #include <assert.h>
@@ -465,13 +466,12 @@ faction_skill(region * r, faction * f, skill_t sk)
 	int value = 0;
 	unit *u;
 
-	list_foreach(unit, r->units, u)
-		if (u->faction == f)
-		{
+  for (u=r->units; u; u=u->next) {
+		if (u->faction == f) {
 			int s = eff_skill(u, sk, r);
 			value = max(value, s);
 		}
-	list_next(u);
+  }
 	return value;
 }
 
diff --git a/src/common/kernel/types.h b/src/common/kernel/types.h
new file mode 100644
index 000000000..741010b3f
--- /dev/null
+++ b/src/common/kernel/types.h
@@ -0,0 +1,401 @@
+/* vi: set ts=2:
+ *
+ *	Eressea PB(E)M host Copyright (C) 1998-2003
+ *      Christian Schlittchen (corwin@amber.kn-bremen.de)
+ *      Katja Zedel (katze@felidae.kn-bremen.de)
+ *      Henning Peters (faroul@beyond.kn-bremen.de)
+ *      Enno Rehling (enno@eressea-pbem.de)
+ *      Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
+ *
+ *  based on:
+ *
+ * Atlantis v1.0  13 September 1993 Copyright 1993 by Russell Wallace
+ * Atlantis v1.7                    Copyright 1996 by Alex Schr�der
+ *
+ * This program may not be used, modified or distributed without
+ * prior permission by the authors of Eressea.
+ * This program may not be sold or used commercially without prior written
+ * permission from the authors.
+ */
+
+#ifndef ERESSEA_TYPES_H
+#define ERESSEA_TYPES_H
+
+#include <util/variant.h>
+
+typedef short terrain_t;
+typedef short direction_t;
+typedef short race_t;
+typedef short magic_t;
+typedef short skill_t;
+typedef short typ_t;
+typedef short item_t;
+typedef unsigned int spellid_t;
+
+struct attrib;
+struct attrib_type;
+struct building;
+struct building_type;
+struct curse;
+struct equipment;
+struct faction;
+struct fighter;
+struct item;
+struct item_type;
+struct locale;
+struct luxury_type;
+struct order;
+struct plane;
+struct potion_type;
+struct race;
+struct region;
+struct region_list;
+struct resource_type;
+struct ship;
+struct ship_type;
+struct skill;
+struct spell;
+struct strlist;
+struct terrain_type;
+struct unit;
+struct unit_list;
+struct weapon_type;
+
+typedef struct ursprung {
+	struct ursprung *next;
+	int id;
+	short x, y;
+} ursprung;
+
+/* ----------------- Befehle ----------------------------------- */
+
+typedef unsigned char keyword_t;
+enum {
+  K_KOMMENTAR,
+  K_BANNER,
+  K_WORK,
+  K_ATTACK,
+  K_STEAL,
+  K_BESIEGE,
+  K_NAME,
+  K_USE,
+  K_DISPLAY,
+  K_ENTER,
+  K_GUARD,
+  K_MAIL,
+  K_END,
+  K_DRIVE,
+  K_NUMBER,
+  K_WAR,
+  K_PEACE,
+  K_FOLLOW,
+  K_RESEARCH,
+  K_GIVE,
+  K_ALLY,
+  K_STATUS,
+  K_COMBAT,
+  K_BUY,
+  K_CONTACT,
+  K_TEACH,
+  K_STUDY,
+  K_LIEFERE,
+  K_MAKE,
+  K_MOVE,
+  K_PASSWORD,
+  K_RECRUIT,
+  K_RESERVE,
+  K_ROUTE,
+  K_SABOTAGE,
+  K_SEND,
+  K_SPY,
+  K_QUIT,
+  K_SETSTEALTH,
+  K_TRANSPORT,
+  K_TAX,
+  K_ENTERTAIN,
+  K_SELL,
+  K_LEAVE,
+  K_FORGET,
+  K_CAST,
+  K_RESHOW,
+  K_DESTROY,
+  K_BREED,
+  K_DEFAULT,
+  K_URSPRUNG,
+  K_EMAIL,
+  K_VOTE,
+  K_MAGIEGEBIET,
+  K_PIRACY,
+  K_RESTART,
+  K_GROUP,
+  K_SACRIFICE,
+  K_PRAY,
+  K_SORT,
+  K_SETJIHAD,
+  K_GM,          /* perform GM commands */
+  K_INFO,        /* set player-info */
+  K_PREFIX,
+  K_SYNONYM,
+  K_PLANT,
+  K_WEREWOLF,
+  K_XE,
+  K_ALLIANCE,
+  K_CLAIM,
+  K_PROMOTION,
+  MAXKEYWORDS,
+  NOKEYWORD = (keyword_t) - 1
+};
+
+/* ------------------ Status von Einheiten --------------------- */
+
+typedef unsigned char status_t;
+enum {
+  ST_AGGRO,
+  ST_FIGHT,
+  ST_BEHIND,
+  ST_CHICKEN,
+  ST_AVOID,
+  ST_FLEE
+};
+
+/* ----------------- Parameter --------------------------------- */
+
+typedef unsigned char param_t;
+enum {
+	P_LOCALE,
+  P_ANY,
+  P_EACH,
+	P_PEASANT,
+	P_BUILDING,
+	P_UNIT,
+	P_PRIVAT,
+	P_BEHIND,
+	P_CONTROL,
+	P_HERBS,
+	P_NOT,
+	P_NEXT,
+	P_FACTION,
+	P_GAMENAME,
+	P_PERSON,
+	P_REGION,
+	P_SHIP,
+	P_SILVER,
+	P_ROAD,
+	P_TEMP,
+	P_FLEE,
+	P_GEBAEUDE,
+	P_GIB,
+	P_KAEMPFE,
+  P_TRAVEL,
+	P_GUARD,
+	P_ZAUBER,
+	P_PAUSE,
+	P_VORNE,
+	P_AGGRO,
+	P_CHICKEN,
+	P_LEVEL,
+	P_HELP,
+	P_FOREIGN,
+	P_AURA,
+	P_FOR,
+	P_AID,
+	P_MERCY,
+	P_AFTER,
+	P_BEFORE,
+	P_NUMBER,
+	P_ITEMS,
+	P_POTIONS,
+	P_GROUP,
+	P_FACTIONSTEALTH,
+	P_TREES,
+	P_XEPOTION,
+	P_XEBALLOON,
+	P_XELAEN,
+	MAXPARAMS,
+	NOPARAM = (param_t) - 1
+};
+
+typedef enum {					/* Fehler und Meldungen im Report */
+	MSG_BATTLE,
+	MSG_EVENT,
+	MSG_MOVE,
+	MSG_INCOME,
+	MSG_COMMERCE,
+	MSG_PRODUCE,
+	MSG_ORCVERMEHRUNG,
+	MSG_MESSAGE,
+	MSG_COMMENT,
+	MSG_MAGIC,
+	MAX_MSG
+} msg_t;
+
+enum {					/* Message-Level */
+	ML_IMPORTANT,				/* Sachen, die IMO erscheinen _muessen_ */
+	ML_DEBUG,
+	ML_MISTAKE,
+	ML_WARN,
+	ML_INFO,
+	ML_MAX
+};
+
+extern const char *parameters[MAXPARAMS];
+
+/* --------------- Reports Typen ------------------------------- */
+
+enum {
+	O_REPORT,				/* 1 */
+	O_COMPUTER,			/* 2 */
+	O_ZUGVORLAGE,		/* 4 */
+	O_SILBERPOOL,		/* 8 */
+	O_STATISTICS,		/* 16 */
+	O_DEBUG,				/* 32 */
+	O_COMPRESS,			/* 64 */
+	O_NEWS,					/* 128 */
+	O_MATERIALPOOL,	/* 256 */
+	O_ADRESSEN,			/* 512 */
+	O_BZIP2,				/* 1024 - compress as bzip2 */
+	O_SCORE,				/* 2048 - punkte anzeigen? */
+	O_SHOWSKCHANGE,	/* 4096 - Skillver�nderungen anzeigen? */
+  O_XML,    			/* 8192 - XML report versenden */
+	MAXOPTIONS
+};
+
+/* ------------------ Talente ---------------------------------- */
+
+enum {
+	SK_ALCHEMY,
+	SK_CROSSBOW,
+	SK_MINING,
+	SK_LONGBOW,
+	SK_BUILDING,
+	SK_TRADE,
+	SK_LUMBERJACK,
+	SK_CATAPULT,
+	SK_HERBALISM,
+	SK_MAGIC,
+	SK_HORSE_TRAINING,			/* 10 */
+	SK_RIDING,
+	SK_ARMORER,
+	SK_SHIPBUILDING,
+	SK_MELEE,
+	SK_SAILING,
+	SK_SPEAR,
+	SK_SPY,
+	SK_QUARRYING,
+	SK_ROAD_BUILDING,
+	SK_TACTICS,					/* 20 */
+	SK_STEALTH,
+	SK_ENTERTAINMENT,
+	SK_WEAPONSMITH,
+	SK_CARTMAKER,
+	SK_OBSERVATION,
+	SK_TAXING,
+	SK_AUSDAUER,
+	SK_WEAPONLESS,
+	MAXSKILLS,
+	NOSKILL = (skill_t) -1
+};
+
+/* ------------- Typ von Einheiten ----------------------------- */
+
+enum {
+	RC_DWARF,		/* 0 - Zwerg */
+	RC_ELF,
+	RC_ORC,
+	RC_GOBLIN,
+	RC_HUMAN,
+
+  RC_TROLL,
+  RC_DAEMON,
+	RC_INSECT,
+	RC_HALFLING,
+	RC_CAT,
+
+  RC_AQUARIAN,
+  RC_URUK,
+	RC_SNOTLING,
+	RC_UNDEAD,
+	RC_ILLUSION,
+
+  RC_FIREDRAGON,
+  RC_DRAGON,
+	RC_WYRM,
+	RC_TREEMAN,
+	RC_BIRTHDAYDRAGON,
+
+  RC_DRACOID,
+	RC_SPECIAL,
+	RC_SPELL,
+	RC_IRONGOLEM,
+	RC_STONEGOLEM,
+
+  RC_SHADOW,
+  RC_SHADOWLORD,
+	RC_IRONKEEPER,
+	RC_ALP,
+	RC_TOAD,
+
+  RC_HIRNTOETER,
+	RC_PEASANT,
+	RC_WOLF = 32,
+
+	RC_SONGDRAGON = 37,
+
+  RC_SEASERPENT = 51,
+	RC_SHADOWKNIGHT, 
+	RC_CENTAUR,
+	RC_SKELETON,
+
+  RC_SKELETON_LORD,
+	RC_ZOMBIE,
+	RC_ZOMBIE_LORD,
+	RC_GHOUL,
+	RC_GHOUL_LORD,
+
+	RC_MUS_SPIRIT,
+	RC_GNOME,     
+	RC_TEMPLATE,  
+	RC_CLONE,
+
+	MAXRACES,
+	NORACE = (race_t) - 1
+};
+
+/* Richtungen */
+enum {
+	D_NORTHWEST,
+	D_NORTHEAST,
+	D_EAST,
+	D_SOUTHEAST,
+	D_SOUTHWEST,
+	D_WEST,
+	MAXDIRECTIONS,
+	D_PAUSE,
+  D_SPECIAL,
+	NODIRECTION = (direction_t) - 1
+};
+
+#define DONT_HELP      0
+#define HELP_MONEY     1			/* Mitversorgen von Einheiten */
+#define HELP_FIGHT     2			/* Bei Verteidigung mithelfen */
+#define HELP_OBSERVE   4			/* Bei Wahrnehmung mithelfen */
+#define HELP_GIVE      8			/* Dinge annehmen ohne KONTAKTIERE */
+#define HELP_GUARD    16			/* Laesst Steuern eintreiben etc. */
+#define HELP_FSTEALTH 32			/* Parteitarnung anzeigen. */
+#define HELP_TRAVEL   64			/* Laesst Regionen betreten. */
+#define HELP_ALL    (127-HELP_TRAVEL-HELP_OBSERVE)		/* Alle "positiven" HELPs zusammen */
+/* HELP_OBSERVE deaktiviert */
+/* ------------------------------------------------------------- */
+/* Prototypen */
+
+
+#define ALLIED_TAX     1
+#define ALLIED_NOBLOCK 2
+#define ALLIED_HELP    4
+
+/* alle vierstelligen zahlen: */
+#define MAX_UNIT_NR (36*36*36*36-1)
+#define MAX_CONTAINER_NR (36*36*36*36-1)
+
+
+#endif
diff --git a/src/common/kernel/unit.c b/src/common/kernel/unit.c
index 2ac37458f..bf1562830 100644
--- a/src/common/kernel/unit.c
+++ b/src/common/kernel/unit.c
@@ -40,11 +40,15 @@
 #include "terrain.h"
 
 #include <attributes/moved.h>
+#include <attributes/otherfaction.h>
+#include <attributes/racename.h>
 
 /* util includes */
+#include <util/attrib.h>
 #include <util/base36.h>
 #include <util/event.h>
 #include <util/goodies.h>
+#include <util/lists.h>
 #include <util/resolve.h>
 #include <util/rng.h>
 #include <util/variant.h>
@@ -57,6 +61,11 @@
 
 #define FIND_FOREIGN_TEMP
 
+attrib_type at_creator = {
+  "creator"
+    /* Rest ist NULL; tempor�res, nicht alterndes Attribut */
+};
+
 const unit *
 u_peasants(void)
 {
@@ -1259,6 +1268,133 @@ unitlist_insert(struct unit_list **ul, struct unit *u)
   *ul = rl2;
 }
 
+
+static void
+createunitid(unit *u, int id)
+{
+  if (id<=0 || id > MAX_UNIT_NR || ufindhash(id) || dfindhash(id) || forbiddenid(id))
+    u->no = newunitid();
+  else
+    u->no = id;
+  uhash(u);
+}
+
+void
+name_unit(unit *u)
+{
+	char name[16];
+
+	if (u->race->generate_name) {
+		set_string(&u->name, (u->race->generate_name(u)));
+	} else {
+		sprintf(name, "%s %s", LOC(u->faction->locale, "unitdefault"), itoa36(u->no));
+		set_string(&u->name, name);
+	}
+}
+
+/** creates a new unit.
+*
+* @param dname: name, set to NULL to get a default.
+* @param creator: unit to inherit stealth, group, building, ship, etc. from
+*/
+unit *
+create_unit(region * r, faction * f, int number, const struct race *urace, int id, const char * dname, unit *creator)
+{
+  unit * u = calloc(1, sizeof(unit));
+  order * deford = default_order(f->locale);
+
+  assert(urace);
+  assert(deford);
+  assert(f->alive);
+  u_setfaction(u, f);
+  set_order(&u->thisorder, NULL);
+#ifdef LASTORDER
+  set_order(&u->lastorder, deford);
+#else
+  addlist(&u->orders, deford);
+#endif
+  u_seteffstealth(u, -1);
+  u->race = urace;
+  u->irace = urace;
+
+  set_number(u, number);
+
+  /* die nummer der neuen einheit muss vor name_unit generiert werden,
+  * da der default name immer noch 'Nummer u->no' ist */
+  createunitid(u, id);
+
+  /* zuerst in die Region setzen, da zb Drachennamen den Regionsnamen
+  * enthalten */
+  move_unit(u, r, NULL);
+
+  /* u->race muss bereits gesetzt sein, wird f�r default-hp gebraucht */
+  /* u->region auch */
+  u->hp = unit_max_hp(u) * number;
+
+  if (!dname) {
+    name_unit(u);
+  }
+  else set_string(&u->name, dname);
+  set_string(&u->display, "");
+
+  if (count_unit(u)) f->no_units++;
+
+  if (creator) {
+    attrib * a;
+
+    /* erbt Kampfstatus */
+    setstatus(u, creator->status);
+
+    /* erbt Geb�ude/Schiff*/
+    if (creator->region==r) {
+      u->building = creator->building;
+      assert(creator->ship==NULL || fval(u->race, RCF_CANSAIL));
+      u->ship = creator->ship;
+    }
+
+    /* Tarnlimit wird vererbt */
+    if (fval(creator, UFL_STEALTH)) {
+      attrib * a = a_find(creator->attribs, &at_stealth);
+      if (a) {
+        int stealth = a->data.i;
+        a = a_add(&u->attribs, a_new(&at_stealth));
+        a->data.i = stealth;
+      }
+    }
+
+    /* Temps von parteigetarnten Einheiten sind wieder parteigetarnt */
+    if (fval(creator, UFL_PARTEITARNUNG)) {
+      fset(u, UFL_PARTEITARNUNG);
+    }
+    /* Daemonentarnung */
+    set_racename(&u->attribs, get_racename(creator->attribs));
+    if (fval(u->race, RCF_SHAPESHIFT) && fval(creator->race, RCF_SHAPESHIFT)) {
+      u->irace = creator->irace;
+    }
+
+    /* Gruppen */
+    if (fval(creator, UFL_GROUP)) {
+      a = a_find(creator->attribs, &at_group);
+      if (a) {
+        group * g = (group*)a->data.v;
+        a_add(&u->attribs, a_new(&at_group))->data.v = g;
+        fset(u, UFL_GROUP);
+      }
+    }
+    a = a_find(creator->attribs, &at_otherfaction);
+    if (a) {
+      a_add(&u->attribs, make_otherfaction(get_otherfaction(a)));
+    }
+
+    a = a_add(&u->attribs, a_new(&at_creator));
+    a->data.v = creator;
+  }
+  /* Monster sind grunds�tzlich parteigetarnt */
+  if (f->no <= 0) fset(u, UFL_PARTEITARNUNG);
+
+  return u;
+}
+
 #ifdef HEROES
 int 
 maxheroes(const struct faction * f)
diff --git a/src/common/kernel/unit.h b/src/common/kernel/unit.h
index b13fc13fb..a5f77ee07 100644
--- a/src/common/kernel/unit.h
+++ b/src/common/kernel/unit.h
@@ -48,7 +48,6 @@ struct item;
 
 /* warning: von 512/1024 gewechslet, wegen konflikt mit NEW_FOLLOW */
 #define UFL_LOCKED        (1<<16) /* Einheit kann keine Personen aufnehmen oder weggeben, nicht rekrutieren. */
-#define UFL_DH            (1<<18) /* same as FL_DH */
 #define UFL_STORM         (1<<19) /* Kapit�n war in einem Sturm */
 #define UFL_FOLLOWING     (1<<20)
 #define UFL_FOLLOWED      (1<<21)
@@ -219,6 +218,10 @@ extern boolean learn_skill(struct unit * u, skill_t sk, double chance);
 extern int invisible(const struct unit *target, const struct unit * viewer);
 extern void stripunit(struct unit * u);
 
+extern void name_unit(struct unit *u);
+extern struct unit * create_unit(struct region * r1, struct faction * f, int number, const struct race * rc, int id, const char * dname, struct unit *creator);
+
+extern struct attrib_type at_creator;
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/common/kernel/version.h b/src/common/kernel/version.h
new file mode 100644
index 000000000..b7f5883f9
--- /dev/null
+++ b/src/common/kernel/version.h
@@ -0,0 +1,75 @@
+/* vi: set ts=2:
+ +-------------------+  
+ |                   |  Enno Rehling <enno@eressea-pbem.de>
+ | Eressea PBEM host |  Katja Zedel <katze@felidae.kn-bremen.de>
+ | (c) 1998 - 2007   |  Christian Schlittchen <corwin@amber.kn-bremen.de>
+ |                   |
+ +-------------------+
+
+ This program may not be used, modified or distributed 
+ without prior permission by the authors of Eressea.
+ 
+ */
+
+/* changes from->to: 72->73: struct unit::lock entfernt.
+ * 73->74: struct unit::flags eingef�hrt.
+ * 74->75: parteitarnung als flag.
+ * 75->76: #ifdef NEW_HP: hp
+ * 76->77: ship->damage
+ * 77->78: neue Message-Option "Orkvermehrung" (MAX_MSG +1)
+ * 78->79: showdata nicht mehr speichern
+ * 79->HEX_VERSION: hex
+ * 80->82: ATTRIB_VERSION
+ * 90: Ebenen
+ * 92: Magiegebiet-Auswahl f->magiegebiet
+ * 94: f->attribs wird gespeichert
+ * 100: NEWMAGIC, neue Message-Option "Zauber" (MAX_MSG +1)
+ * 108: Speichern von Timeouts
+ * 193: curse bekommen id aus struct unit-nummernraum
+ */
+
+#define TYPES_VERSION 117
+#define ITEMTYPE_VERSION 190
+#define NOFOREST_VERSION 191
+#define REGIONAGE_VERSION 192
+#define CURSE_NO_VERSION 193
+#define EFFSTEALTH_VERSION 194
+#define MAGE_ATTRIB_VERSION 195
+#define GLOBAL_ATTRIB_VERSION 196
+#define BASE36IDS_VERSION 197
+#define NEWSOURCE_VERSION 197
+#define NEWSTATUS_VERSION 198
+#define NEWNAMES_VERSION 199
+#define LOCALE_VERSION 300
+#define GROUPATTRIB_VERSION 301
+#define NEWRESOURCE_VERSION 303
+#define GROWTREE_VERSION 305
+#define RANDOMIZED_RESOURCES_VERSION 306 /* should be the same, but doesn't work */
+#define NEWRACE_VERSION 307
+#define INTERIM_VERSION 309
+#define NEWSKILL_VERSION 309
+#define WATCHERS_VERSION 310
+#define OVERRIDE_VERSION 311
+#define CURSETYPE_VERSION 312
+#define ALLIANCES_VERSION 313
+#define DBLINK_VERSION 314
+#define CURSEVIGOURISFLOAT_VERSION 315
+#define SAVEXMLNAME_VERSION 316
+#define SAVEALLIANCE_VERSION 317
+#define CLAIM_VERSION 318
+#define BACTION_VERSION 319 /* building action gets a param string */
+#define NOLASTORDER_VERSION 320 /* do not use lastorder */
+#define SPELLNAME_VERSION 321 /* reference spells by name */
+#define TERRAIN_VERSION 322 /* terrains are a full type and saved by name */
+#define REGIONITEMS_VERSION 323 /* regions have items */
+#define ATTRIBREAD_VERSION 324 /* remove a_readint */
+#define CURSEFLAGS_VERSION 325 /* remove a_readint */
+
+#define MIN_VERSION CURSETYPE_VERSION
+#define REGIONOWNERS_VERSION 400
+
+#ifdef ENEMIES
+# define RELEASE_VERSION ENEMIES_VERSION
+#else
+# define RELEASE_VERSION CURSEFLAGS_VERSION
+#endif
diff --git a/src/common/kernel/xmlreader.c b/src/common/kernel/xmlreader.c
index e123af032..4760165fc 100644
--- a/src/common/kernel/xmlreader.c
+++ b/src/common/kernel/xmlreader.c
@@ -29,10 +29,12 @@ without prior permission by the authors of Eressea.
 #include "calendar.h"
 
 /* util includes */
+#include <util/attrib.h>
+#include <util/crmessage.h>
 #include <util/functions.h>
 #include <util/message.h>
 #include <util/nrmessage.h>
-#include <util/crmessage.h>
+#include <util/language.h>
 
 /* libxml includes */
 #include <libxml/tree.h>
diff --git a/src/common/modules/arena.c b/src/common/modules/arena.c
index 898bb75d4..b72fe8cf8 100644
--- a/src/common/modules/arena.c
+++ b/src/common/modules/arena.c
@@ -46,10 +46,12 @@
 #include <kernel/unit.h>
 
 /* util include */
+#include <util/attrib.h>
 #include <util/base36.h>
 #include <util/event.h>
 #include <util/functions.h>
 #include <util/goodies.h>
+#include <util/lists.h>
 #include <util/resolve.h>
 #include <util/rng.h>
 
@@ -341,6 +343,8 @@ guardian_faction(plane * pl, int id)
 	}
 }
 
+#define BLOCKSIZE           9
+
 static void 
 block_create(short x1, short y1, char terrain)
 {
diff --git a/src/common/modules/autoseed.c b/src/common/modules/autoseed.c
index 8190ad8a2..6f32e55ca 100644
--- a/src/common/modules/autoseed.c
+++ b/src/common/modules/autoseed.c
@@ -28,6 +28,7 @@
 /* util includes */
 #include <util/base36.h>
 #include <util/goodies.h>
+#include <util/lists.h>
 #include <util/rng.h>
 #include <util/sql.h>
 
@@ -82,10 +83,10 @@ recurse_regions(region *r, region_list **rlist, boolean(*fun)(const region *r))
     rl->next = *rlist;
     rl->data = r;
     (*rlist) = rl;
-    fset(r, FL_MARK);
+    fset(r, RF_MARK);
     for (d=0;d!=MAXDIRECTIONS;++d) {
       region * nr = rconnect(r, d);
-      if (nr && !fval(nr, FL_MARK)) len += recurse_regions(nr, rlist, fun);
+      if (nr && !fval(nr, RF_MARK)) len += recurse_regions(nr, rlist, fun);
     }
     return len+1;
   }
@@ -145,7 +146,7 @@ fix_demand(region *r)
         }
       }
     }
-    freset(r, FL_MARK); /* undo recursive marker */
+    freset(r, RF_MARK); /* undo recursive marker */
   }
   if (maxlux<2) {
     int i;
@@ -414,7 +415,7 @@ get_island(region * root, region_list ** rlist)
   region_list ** rnext = rlist;
   while (*rnext) rnext=&(*rnext)->next;
 
-  fset(root, FL_MARK);
+  fset(root, RF_MARK);
   add_regionlist(rnext, root);
 
   while (*rnext) {
@@ -425,8 +426,8 @@ get_island(region * root, region_list ** rlist)
 
     for (dir=0;dir!=MAXDIRECTIONS;++dir) {
       region * r = rconnect(rcurrent, dir);
-      if (r!=NULL && r->land && !fval(r, FL_MARK)) {
-        fset(r, FL_MARK);
+      if (r!=NULL && r->land && !fval(r, RF_MARK)) {
+        fset(r, RF_MARK);
         add_regionlist(rnext, r);
       }
     }
@@ -434,7 +435,7 @@ get_island(region * root, region_list ** rlist)
   rnext=rlist;
   while (*rnext) {
     region_list * rptr = *rnext;
-    freset(rptr->data, FL_MARK);
+    freset(rptr->data, RF_MARK);
     rnext = &rptr->next;
   }
 }
@@ -447,25 +448,25 @@ island_size(region * r)
   region_list * island = NULL;
   add_regionlist(&rlist, r);
   island = rlist;
-  fset(r, FL_MARK);
+  fset(r, RF_MARK);
   while (rlist) {
     direction_t d;
     r = rlist->data;
     ++size;
     for (d=0;d!=MAXDIRECTIONS;++d) {
       region * rn = rconnect(r, d);
-      if (rn && !fval(rn, FL_MARK) && rn->land) {
+      if (rn && !fval(rn, RF_MARK) && rn->land) {
         region_list * rnew = malloc(sizeof(region_list));
         rnew->data = rn;
         rnew->next = rlist->next;
         rlist->next = rnew;
-        fset(rn, FL_MARK);
+        fset(rn, RF_MARK);
       }
     }
     rlist = rlist->next;
   }
   for (rlist=island;rlist;rlist=rlist->next) {
-    freset(rlist->data, FL_MARK);
+    freset(rlist->data, RF_MARK);
   }
   free_regionlist(island);
   return size;
@@ -525,14 +526,14 @@ autoseed(newfaction ** players, int nsize, boolean new_island)
         unit * u;
         for (u=r->units;u;u=u->next) {
           f = u->faction;
-          if (!fval(f, FL_MARK)) {
+          if (!fval(f, FFL_MARK)) {
             ++psize;
-            fset(f, FL_MARK);
+            fset(f, FFL_MARK);
           }
         }
       }
       free_regionlist(rlist);
-      if (psize>0) for (f=factions;f;f=f->next) freset(f, FL_MARK);
+      if (psize>0) for (f=factions;f;f=f->next) freset(f, FFL_MARK);
       if (psize<PLAYERS_PER_ISLAND) {
         r = rmin;
       }
@@ -573,7 +574,7 @@ autoseed(newfaction ** players, int nsize, boolean new_island)
   }
   if (r!=NULL) {
     add_regionlist(&rlist, r);
-    fset(r, FL_MARK);
+    fset(r, RF_MARK);
     rsize = 1;
   }
 
@@ -585,20 +586,20 @@ autoseed(newfaction ** players, int nsize, boolean new_island)
     while (i--) rnext=&(*rnext)->next;
     rfind = *rnext;
     r = rfind->data;
-    freset(r, FL_MARK);
+    freset(r, RF_MARK);
     *rnext = rfind->next;
     free(rfind);
     --rsize;
     for (d=0;d!=MAXDIRECTIONS;++d) {
       region * rn = rconnect(r, d);
-      if (rn && fval(rn, FL_MARK)) continue;
+      if (rn && fval(rn, RF_MARK)) continue;
       if (virgin_region(rn)) {
         if (rn==NULL) {
           rn = new_region(r->x + delta_x[d], r->y + delta_y[d]);
           terraform(rn, T_OCEAN);
         }
         add_regionlist(&rlist, rn);
-        fset(rn, FL_MARK);
+        fset(rn, RF_MARK);
         ++rsize;
       }
     }
@@ -727,7 +728,7 @@ autoseed(newfaction ** players, int nsize, boolean new_island)
     while (rlist) {
       region_list * self = rlist;
       rlist = rlist->next;
-      freset(self->data, FL_MARK);
+      freset(self->data, RF_MARK);
       free(self);
     }
   }
diff --git a/src/common/modules/gmcmd.c b/src/common/modules/gmcmd.c
index ac54a30d7..f45a6c640 100644
--- a/src/common/modules/gmcmd.c
+++ b/src/common/modules/gmcmd.c
@@ -39,6 +39,7 @@
 #include <util/base36.h>
 #include <util/event.h>
 #include <util/goodies.h>
+#include <util/lists.h>
 #include <util/umlaut.h>
 #include <util/rng.h>
 
@@ -285,14 +286,14 @@ gm_messageplane(const tnode * tnext, const char * str, void * data, struct order
       faction * f;
       region * r;
       for (f=factions;f;f=f->next) {
-        freset(f, FL_DH);
+        freset(f, FFL_SELECT);
       }
       for (r=regions;r;r=r->next) {
         unit * u;
         if (rplane(r)!=p) continue;
-        for (u=r->units;u;u=u->next) if (!fval(u->faction, FL_DH)) {
+        for (u=r->units;u;u=u->next) if (!fval(u->faction, FFL_SELECT)) {
           f = u->faction;
-          fset(f, FL_DH);
+          fset(f, FFL_SELECT);
           add_message(&f->msgs, msg);
         }
       }
diff --git a/src/common/modules/museum.h b/src/common/modules/museum.h
index ddb751632..f05eaed77 100644
--- a/src/common/modules/museum.h
+++ b/src/common/modules/museum.h
@@ -22,10 +22,10 @@ extern "C" {
 #error "must define MUSEUM_MODULE to use this module"
 #endif
 
-extern attrib_type at_warden;
-extern attrib_type at_museumexit;
-extern attrib_type at_museumgivebackcookie;
-extern attrib_type at_museumgiveback;
+extern struct attrib_type at_warden;
+extern struct attrib_type at_museumexit;
+extern struct attrib_type at_museumgivebackcookie;
+extern struct attrib_type at_museumgiveback;
 
 typedef struct {
 	int       warden_no;
diff --git a/src/common/modules/xecmd.c b/src/common/modules/xecmd.c
index 60a12897c..a8c383f6e 100644
--- a/src/common/modules/xecmd.c
+++ b/src/common/modules/xecmd.c
@@ -30,8 +30,11 @@
 #include <kernel/ship.h>
 #include <kernel/unit.h>
 
+/* util includes */
+#include <util/attrib.h>
+#include <util/base36.h>
+
 /* libc includes */
-#include <base36.h>
 #include <stdlib.h>
 #include <string.h>
 
diff --git a/src/common/modules/xecmd.h b/src/common/modules/xecmd.h
index 80835cf76..c20fc4caf 100644
--- a/src/common/modules/xecmd.h
+++ b/src/common/modules/xecmd.h
@@ -17,7 +17,7 @@ extern "C" {
 #endif
 
 #ifdef XECMD_MODULE
-extern attrib_type at_xontormiaexpress;
+extern struct attrib_type at_xontormiaexpress;
 int xecmd(struct unit * u, struct order * ord);
 #endif
 
diff --git a/src/common/settings-eressea.h b/src/common/settings-eressea.h
index 3abffb3b4..2db1d6fca 100644
--- a/src/common/settings-eressea.h
+++ b/src/common/settings-eressea.h
@@ -47,3 +47,5 @@
 #undef FUZZY_BASE36
 #define SIMPLE_COMBAT
 #define SIMPLE_ESCAPE
+
+#define RESOURCE_CONVERSION /* support for data files < NEWRESOURCE_VERSION */
diff --git a/src/common/spells/alp.c b/src/common/spells/alp.c
index b2c85bb59..c0669f4d3 100644
--- a/src/common/spells/alp.c
+++ b/src/common/spells/alp.c
@@ -12,16 +12,20 @@
  */
 
 #include <config.h>
-#include <eressea.h>
+#include <kernel/eressea.h>
 #include "alp.h"
 
-#include <unit.h>
-#include <region.h>
-#include <skill.h>
-#include <magic.h>
+#include <kernel/eressea.h>
+#include <kernel/magic.h>
+#include <kernel/region.h>
+#include <kernel/skill.h>
+#include <kernel/unit.h>
 
 /* util includes */
-#include <event.h>
+#include <util/attrib.h>
+#include <util/event.h>
+#include <util/umlaut.h>
+
 #include <triggers/createcurse.h>
 #include <triggers/killunit.h>
 #include <triggers/removecurse.h>
@@ -101,9 +105,8 @@ sp_summon_alp(struct castorder *co)
   * Regionsberichte von ihm.  Er erh�lt aber sp�ter eine Mitteilung,
   * sobald der Alp sein Opfer erreicht hat.
   */
-  alp = createunit(r, findfaction(MONSTER_FACTION), 1, new_race[RC_ALP]);
+  alp = create_unit(r, findfaction(MONSTER_FACTION), 1, new_race[RC_ALP], 0, "Alp", NULL);
   set_level(alp, SK_STEALTH, 7);
-  set_string(&alp->name, "Alp");
   setstatus(alp, ST_FLEE); /* flieht */
 
   {
diff --git a/src/common/spells/buildingcurse.c b/src/common/spells/buildingcurse.c
index 627a79776..ebb0ac362 100644
--- a/src/common/spells/buildingcurse.c
+++ b/src/common/spells/buildingcurse.c
@@ -26,6 +26,7 @@
 #include <util/nrmessage.h>
 #include <util/base36.h>
 #include <util/functions.h>
+#include <util/language.h>
 
 /* libc includes */
 #include <string.h>
diff --git a/src/common/spells/combatspells.c b/src/common/spells/combatspells.c
index 41ab91c86..445462774 100644
--- a/src/common/spells/combatspells.c
+++ b/src/common/spells/combatspells.c
@@ -31,6 +31,7 @@
 #include <kernel/skill.h>
 
 /* util includes */
+#include <util/attrib.h>
 #include <util/base36.h>
 #include <util/rand.h>
 #include <util/rng.h>
diff --git a/src/common/spells/shipcurse.c b/src/common/spells/shipcurse.c
index 043f4241d..35432db86 100644
--- a/src/common/spells/shipcurse.c
+++ b/src/common/spells/shipcurse.c
@@ -23,8 +23,9 @@
 #include <curse.h>
 
 /* util includes */
-#include <functions.h>
-#include <base36.h>
+#include <util/base36.h>
+#include <util/functions.h>
+#include <util/language.h>
 
 /* libc includes */
 #include <string.h>
diff --git a/src/common/spells/spells.c b/src/common/spells/spells.c
index 2d73bcdfc..7a45bf71d 100644
--- a/src/common/spells/spells.c
+++ b/src/common/spells/spells.c
@@ -59,11 +59,13 @@ extern void ct_register(const struct curse_type * ct);
 #include <spells/alp.h>
 
 /* util includes */
-#include <util/umlaut.h>
+#include <util/attrib.h>
 #include <util/base36.h>
+#include <util/umlaut.h>
 #include <util/message.h>
 #include <util/event.h>
 #include <util/functions.h>
+#include <util/lists.h>
 #include <util/rand.h>
 #include <util/variant.h>
 #include <util/goodies.h>
@@ -377,11 +379,11 @@ report_effect(region * r, unit * mage, message * seen, message * unseen)
   unit * u;
 
   /* melden, 1x pro Partei */
-  freset(mage->faction, FL_DH);
-  for (u = r->units; u; u = u->next ) freset(u->faction, FL_DH);
+  freset(mage->faction, FFL_SELECT);
+  for (u = r->units; u; u = u->next ) freset(u->faction, FFL_SELECT);
   for (u = r->units; u; u = u->next ) {
-    if (!fval(u->faction, FL_DH) ) {
-      fset(u->faction, FL_DH);
+    if (!fval(u->faction, FFL_SELECT) ) {
+      fset(u->faction, FFL_SELECT);
 
       /* Bei Fernzaubern sieht nur die eigene Partei den Magier */
       if (u->faction != mage->faction) {
@@ -403,7 +405,7 @@ report_effect(region * r, unit * mage, message * seen, message * unseen)
   }
   /* Ist niemand von der Partei des Magiers in der Region, dem Magier
   * nochmal gesondert melden */
-  if (!fval(mage->faction, FL_DH)) {
+  if (!fval(mage->faction, FFL_SELECT)) {
     add_message(&mage->faction->msgs, seen);
   }
 }
@@ -802,19 +804,19 @@ sp_goodwinds(castorder *co)
   create_curse(mage, &sh->attribs, ct_find("nodrift"), power, duration, zero_effect, 0);
 
   /* melden, 1x pro Partei */
-  freset(mage->faction, FL_DH);
-  for(u = r->units; u; u = u->next ) freset(u->faction, FL_DH);
+  freset(mage->faction, FFL_SELECT);
+  for(u = r->units; u; u = u->next ) freset(u->faction, FFL_SELECT);
   for(u = r->units; u; u = u->next ) {
     if (u->ship != sh )    /* nur den Schiffsbesatzungen! */
       continue;
-    if (!fval(u->faction, FL_DH) ) {
+    if (!fval(u->faction, FFL_SELECT) ) {
       message * m = msg_message("wind_effect", "mage ship", cansee(u->faction, r, mage, 0) ? mage:NULL, sh);
       r_addmessage(r, u->faction, m);
       msg_release(m);
-      fset(u->faction, FL_DH);
+      fset(u->faction, FFL_SELECT);
     }
   }
-  if (!fval(mage->faction, FL_DH)) {
+  if (!fval(mage->faction, FFL_SELECT)) {
     message * m = msg_message("wind_effect", "mage ship", mage, sh);
     r_addmessage(r, mage->faction, m);
     msg_release(m);
@@ -1673,11 +1675,11 @@ sp_great_drought(castorder *co)
   }
 
   /* melden, 1x pro partei */
-  for (u = r->units; u; u = u->next) freset(u->faction, FL_DH);
+  for (u = r->units; u; u = u->next) freset(u->faction, FFL_SELECT);
 
   for (u = r->units; u; u = u->next) {
-    if (!fval(u->faction, FL_DH)) {
-      fset(u->faction, FL_DH);
+    if (!fval(u->faction, FFL_SELECT)) {
+      fset(u->faction, FFL_SELECT);
       sprintf(buf, "%s ruft das Feuer der Sonne auf %s hinab.",
           cansee(u->faction, r, mage, 0)? unitname(mage) : "Jemand",
           regionname(r, u->faction));
@@ -1707,7 +1709,7 @@ sp_great_drought(castorder *co)
       }
     }
   }
-  if (!fval(mage->faction, FL_DH)) {
+  if (!fval(mage->faction, FFL_SELECT)) {
     ADDMSG(&mage->faction->msgs, msg_message(
       "drought_effect", "mage region", mage, r));
   }
@@ -1793,12 +1795,12 @@ sp_treewalkenter(castorder *co)
       erfolg = cast_level;
 
       /* Meldungen in der Ausgangsregion */
-      for (u2 = r->units; u2; u2 = u2->next) freset(u2->faction, FL_DH);
+      for (u2 = r->units; u2; u2 = u2->next) freset(u2->faction, FFL_SELECT);
       m = NULL;
       for (u2 = r->units; u2; u2 = u2->next ) {
-        if (!fval(u2->faction, FL_DH)) {
+        if (!fval(u2->faction, FFL_SELECT)) {
           if (cansee(u2->faction, r, u, 0)) {
-            fset(u2->faction, FL_DH);
+            fset(u2->faction, FFL_SELECT);
             if (!m) m = msg_message("astral_disappear", "unit", u);
             r_addmessage(r, u2->faction, m);
           }
@@ -1807,12 +1809,12 @@ sp_treewalkenter(castorder *co)
       if (m) msg_release(m);
 
       /* Meldungen in der Zielregion */
-      for (u2 = rt->units; u2; u2 = u2->next) freset(u2->faction, FL_DH);
+      for (u2 = rt->units; u2; u2 = u2->next) freset(u2->faction, FFL_SELECT);
       m = NULL;
       for (u2 = rt->units; u2; u2 = u2->next ) {
-        if (!fval(u2->faction, FL_DH)) {
+        if (!fval(u2->faction, FFL_SELECT)) {
           if (cansee(u2->faction, rt, u, 0)) {
-            fset(u2->faction, FL_DH);
+            fset(u2->faction, FFL_SELECT);
             if (!m) m = msg_message("astral_appear", "unit", u);
             r_addmessage(rt, u2->faction, m);
           }
@@ -1927,12 +1929,12 @@ sp_treewalkexit(castorder *co)
 
         /* Meldungen in der Ausgangsregion */
 
-        for (u2 = r->units; u2; u2 = u2->next) freset(u2->faction, FL_DH);
+        for (u2 = r->units; u2; u2 = u2->next) freset(u2->faction, FFL_SELECT);
         m = NULL;
         for(u2 = r->units; u2; u2 = u2->next ) {
-          if (!fval(u2->faction, FL_DH)) {
+          if (!fval(u2->faction, FFL_SELECT)) {
             if (cansee(u2->faction, r, u, 0)) {
-              fset(u2->faction, FL_DH);
+              fset(u2->faction, FFL_SELECT);
               if (!m) m = msg_message("astral_disappear", "unit", u);
               r_addmessage(rt, u2->faction, m);
             }
@@ -1942,12 +1944,12 @@ sp_treewalkexit(castorder *co)
 
         /* Meldungen in der Zielregion */
 
-        for (u2 = rt->units; u2; u2 = u2->next) freset(u2->faction, FL_DH);
+        for (u2 = rt->units; u2; u2 = u2->next) freset(u2->faction, FFL_SELECT);
         m = NULL;
         for (u2 = rt->units; u2; u2 = u2->next ) {
-          if (!fval(u2->faction, FL_DH)) {
+          if (!fval(u2->faction, FFL_SELECT)) {
             if (cansee(u2->faction, rt, u, 0)) {
-              fset(u2->faction, FL_DH);
+              fset(u2->faction, FFL_SELECT);
               if (!m) m = msg_message("astral_appear", "unit", u);
               r_addmessage(rt, u2->faction, m);
             }
@@ -2037,10 +2039,10 @@ sp_homestone(castorder *co)
   c_setflag(c, CURSE_NOAGE);
 
   /* melden, 1x pro Partei in der Burg */
-  for (u = r->units; u; u = u->next) freset(u->faction, FL_DH);
+  for (u = r->units; u; u = u->next) freset(u->faction, FFL_SELECT);
   for (u = r->units; u; u = u->next) {
-    if (!fval(u->faction, FL_DH)) {
-      fset(u->faction, FL_DH);
+    if (!fval(u->faction, FFL_SELECT)) {
+      fset(u->faction, FFL_SELECT);
       if (u->building ==  mage->building) {
         sprintf(buf, "Mit einem Ritual bindet %s die magischen Kr�fte "
             "der Erde in die Mauern von %s", unitname(mage),
@@ -2086,16 +2088,16 @@ sp_drought(castorder *co)
   }
 
   /* melden, 1x pro Partei */
-  for (u = r->units; u; u = u->next) freset(u->faction, FL_DH);
+  for (u = r->units; u; u = u->next) freset(u->faction, FFL_SELECT);
   for(u = r->units; u; u = u->next ) {
-    if (!fval(u->faction, FL_DH) ) {
-      fset(u->faction, FL_DH);
+    if (!fval(u->faction, FFL_SELECT) ) {
+      fset(u->faction, FFL_SELECT);
       sprintf(buf, "%s verflucht das Land, und eine D�rreperiode beginnt.",
           cansee(u->faction, r, mage, 0) ? unitname(mage) : "Jemand");
       addmessage(r, u->faction, buf, MSG_EVENT, ML_INFO);
     }
   }
-  if (!fval(mage->faction, FL_DH)) {
+  if (!fval(mage->faction, FFL_SELECT)) {
     sprintf(buf, "%s verflucht das Land, und eine D�rreperiode beginnt.",
         unitname(mage));
     addmessage(0, mage->faction, buf, MSG_MAGIC, ML_INFO);
@@ -2171,15 +2173,15 @@ sp_fog_of_confusion(castorder *co)
     if (!ctype) ctype = ct_find("disorientationzone");
     c = create_curse(mage, &r2->attribs, ctype, power, duration, effect, 0);
 
-    for (u = r2->units; u; u = u->next) freset(u->faction, FL_DH);
+    for (u = r2->units; u; u = u->next) freset(u->faction, FFL_SELECT);
     for (u = r2->units; u; u = u->next ) {
-      if (!fval(u->faction, FL_DH) ) {
-        fset(u->faction, FL_DH);
+      if (!fval(u->faction, FFL_SELECT) ) {
+        fset(u->faction, FFL_SELECT);
         if (!m) m = msg_message("confusion_result", "mage", mage);
         add_message(&u->faction->msgs, m);
       }
     }
-    if (!fval(mage->faction, FL_DH)) {
+    if (!fval(mage->faction, FFL_SELECT)) {
       if (!m) m = msg_message("confusion_result", "mage", mage);
       add_message(&mage->faction->msgs, m);
     }
@@ -2272,8 +2274,8 @@ sp_stormwinds(castorder *co)
   message * m = NULL;
 
   /* melden vorbereiten */
-  freset(mage->faction, FL_DH);
-  for (u = r->units; u; u = u->next) freset(u->faction, FL_DH);
+  freset(mage->faction, FFL_SELECT);
+  for (u = r->units; u; u = u->next) freset(u->faction, FFL_SELECT);
 
   for (n = 0; n < pa->length; n++) {
     if (force<=0) break;
@@ -2308,15 +2310,15 @@ sp_stormwinds(castorder *co)
     for(u = r->units; u; u = u->next ) {
       if (u->ship == sh ) {
         /* nur den Schiffsbesatzungen! */
-        fset(u->faction, FL_DH);
+        fset(u->faction, FFL_SELECT);
       }
     }
   }
   /* melden, 1x pro Partei auf Schiff und f�r den Magier */
-  fset(mage->faction, FL_DH);
+  fset(mage->faction, FFL_SELECT);
   for (u = r->units; u; u = u->next ) {
-    if (fval(u->faction, FL_DH)) {
-      freset(u->faction, FL_DH);
+    if (fval(u->faction, FFL_SELECT)) {
+      freset(u->faction, FFL_SELECT);
       if (erfolg > 0) {
         if (!m) {
           m = msg_message("stormwinds_effect", "unit", mage);
@@ -2382,10 +2384,10 @@ sp_earthquake(castorder *co)
   }
 
   /* melden, 1x pro Partei */
-  for (u = r->units; u; u = u->next) freset(u->faction, FL_DH);
+  for (u = r->units; u; u = u->next) freset(u->faction, FFL_SELECT);
   for (u = r->units; u; u = u->next ) {
-    if (!fval(u->faction, FL_DH) ) {
-      fset(u->faction, FL_DH);
+    if (!fval(u->faction, FFL_SELECT) ) {
+      fset(u->faction, FFL_SELECT);
       sprintf(buf, "%s l��t die Erde in %s erzittern.",
           cansee(u->faction, r, mage, 0) ? unitname(mage) : "Jemand",
           regionname(r, u->faction));
@@ -2494,11 +2496,11 @@ sp_forest_fire(castorder *co)
   probability = destroyed * 0.001;  /* Chance, dass es sich ausbreitet */
 
   /* melden, 1x pro Partei */
-  for (u = r->units; u; u = u->next) freset(u->faction, FL_DH);
+  for (u = r->units; u; u = u->next) freset(u->faction, FFL_SELECT);
 
   for(u = r->units; u; u = u->next ) {
-    if (!fval(u->faction, FL_DH) ) {
-      fset(u->faction, FL_DH);
+    if (!fval(u->faction, FFL_SELECT) ) {
+      fset(u->faction, FFL_SELECT);
       sprintf(buf, "%s erzeugt eine verheerende Feuersbrunst.  %d %s "
           "den Flammen zum Opfer.",
           cansee(u->faction, r, mage, 0) ? unitname(mage) : "Jemand",
@@ -2507,7 +2509,7 @@ sp_forest_fire(castorder *co)
       addmessage(r, u->faction, buf, MSG_EVENT, ML_INFO);
     }
   }
-  if (!fval(mage->faction, FL_DH)) {
+  if (!fval(mage->faction, FFL_SELECT)) {
     sprintf(buf, "%s erzeugt eine verheerende Feuersbrunst.  %d %s "
         "den Flammen zum Opfer.", unitname(mage), destroyed+vernichtet_schoesslinge,
         destroyed+vernichtet_schoesslinge == 1 ? "Baum fiel" : "B�ume fielen");
@@ -3081,15 +3083,15 @@ sp_wisps(castorder *co)
   a_add(&b->attribs, a_new(&at_countdown))->data.i = cast_level;
 
   /* melden, 1x pro Partei */
-        {
-          message * seen = msg_message("wisps_effect", "mage region", mage, r);
-          message * unseen = msg_message("wisps_effect", "mage region", NULL, r);
-          report_effect(r, mage, seen, unseen);
-          msg_release(seen);
-          msg_release(unseen);
-        }
+  {
+    message * seen = msg_message("wisps_effect", "mage region", mage, r);
+    message * unseen = msg_message("wisps_effect", "mage region", NULL, r);
+    report_effect(r, mage, seen, unseen);
+    msg_release(seen);
+    msg_release(unseen);
+  }
 
-        return cast_level;
+  return cast_level;
 }
 
 /* ------------------------------------------------------------- */
@@ -3226,7 +3228,7 @@ dc_age(struct curse * c)
     unit * u = *up;
     double damage = c->effect.f * u->number;
 
-    freset(u->faction, FL_DH);
+    freset(u->faction, FFL_SELECT);
     if (u->number<=0 || target_resists_magic(mage, u, TYP_UNIT, 0)) {
       up=&u->next;
       continue;
@@ -3320,14 +3322,14 @@ sp_deathcloud(castorder *co)
 
   /* melden, 1x pro Partei */
   for (u = r->units; u; u = u->next ) {
-    if (!fval(u->faction, FL_DH) ) {
-      fset(u->faction, FL_DH);
+    if (!fval(u->faction, FFL_SELECT) ) {
+      fset(u->faction, FFL_SELECT);
       ADDMSG(&u->faction->msgs, msg_message("deathcloud_effect",
         "mage region", cansee(u->faction, r, mage, 0) ? mage : NULL, r));
     }
   }
 
-  if (!fval(mage->faction, FL_DH)) {
+  if (!fval(mage->faction, FFL_SELECT)) {
     ADDMSG(&mage->faction->msgs, msg_message("deathcloud_effect",
       "mage region", mage, r));
   }
@@ -3494,21 +3496,21 @@ sp_chaossuction(castorder *co)
       "Wirbel");
   new_border(&bt_chaosgate, r, rt);
 
-  freset(mage->faction, FL_DH);
-  for (u = r->units; u; u = u->next) freset(u->faction, FL_DH);
+  freset(mage->faction, FFL_SELECT);
+  for (u = r->units; u; u = u->next) freset(u->faction, FFL_SELECT);
   for (u = r->units; u; u = u->next) {
-    if (!fval(u->faction, FL_DH)) {
-      fset(u->faction, FL_DH);
+    if (!fval(u->faction, FFL_SELECT)) {
+      fset(u->faction, FFL_SELECT);
       sprintf(buf, "%s �ffnete ein Chaostor.",
           cansee(u->faction, r, mage, 0)?unitname(mage):"Jemand");
       addmessage(r, u->faction, buf, MSG_EVENT, ML_INFO);
     }
   }
-  for (u = rt->units; u; u = u->next) freset(u->faction, FL_DH);
+  for (u = rt->units; u; u = u->next) freset(u->faction, FFL_SELECT);
 
   for (u = rt->units; u; u = u->next) {
-    if (!fval(u->faction, FL_DH)) {
-      fset(u->faction, FL_DH);
+    if (!fval(u->faction, FFL_SELECT)) {
+      fset(u->faction, FFL_SELECT);
       addmessage(r, u->faction, "Ein Wirbel aus blendendem Licht erscheint.",
         MSG_EVENT, ML_INFO);
     }
@@ -3689,12 +3691,12 @@ sp_summonundead(castorder *co)
   addmessage(0, mage->faction, buf, MSG_MAGIC, ML_INFO);
 
   /* melden, 1x pro Partei */
-  for (u = r->units; u; u = u->next) freset(u->faction, FL_DH);
+  for (u = r->units; u; u = u->next) freset(u->faction, FFL_SELECT);
 
   for (u = r->units; u; u = u->next ) {
-    if (!fval(u->faction, FL_DH) ) {
+    if (!fval(u->faction, FFL_SELECT) ) {
       if (!m) m = msg_message("summonundead_effect", "unit", mage);
-      fset(u->faction, FL_DH);
+      fset(u->faction, FFL_SELECT);
       add_message(&u->faction->msgs, m);
     }
   }
@@ -3737,11 +3739,11 @@ sp_auraleak(castorder *co)
       lost_aura = (int)(get_spellpoints(u)*lost);
       change_spellpoints(u, -lost_aura);
     }
-    freset(u->faction, FL_DH);
+    freset(u->faction, FFL_SELECT);
   }
   for (u = r->units; u; u = u->next) {
-    if (!fval(u->faction, FL_DH)) {
-      fset(u->faction, FL_DH);
+    if (!fval(u->faction, FFL_SELECT)) {
+      fset(u->faction, FFL_SELECT);
       if (cansee(u->faction, r, mage, 0)) {
         sprintf(buf, "%s rief in %s einen Riss in dem Gef�ge der Magie "
             "hervor, der alle magische Kraft aus der Region riss.",
@@ -4100,17 +4102,17 @@ sp_rallypeasantmob(castorder *co)
   }
 
   if (erfolg) {
-    for (u = r->units; u; u = u->next) freset(u->faction, FL_DH);
+    for (u = r->units; u; u = u->next) freset(u->faction, FFL_SELECT);
     for(u = r->units; u; u = u->next ) {
-      if (!fval(u->faction, FL_DH) ) {
-        fset(u->faction, FL_DH);
+      if (!fval(u->faction, FFL_SELECT) ) {
+        fset(u->faction, FFL_SELECT);
         sprintf(buf, "%s bes�nftigt den Bauernaufstand in %s.",
             cansee(u->faction, r, mage, 0) ? unitname(mage) : "Jemand",
             regionname(r, u->faction));
         addmessage(r, u->faction, buf, MSG_MAGIC, ML_INFO);
       }
     }
-    if (!fval(mage->faction, FL_DH)) {
+    if (!fval(mage->faction, FFL_SELECT)) {
       sprintf(buf, "%s bes�nftigt den Bauernaufstand in %s.",
           unitname(mage), regionname(r, u->faction));
       addmessage(r, mage->faction, buf, MSG_MAGIC, ML_INFO);
@@ -4179,16 +4181,16 @@ sp_raisepeasantmob(castorder *co)
 
   create_curse(mage, &r->attribs, ct_find("riotzone"), cast_level, duration, anteil, 0);
 
-  for (u = r->units; u; u = u->next) freset(u->faction, FL_DH);
+  for (u = r->units; u; u = u->next) freset(u->faction, FFL_SELECT);
   for (u = r->units; u; u = u->next ) {
-    if (!fval(u->faction, FL_DH) ) {
-      fset(u->faction, FL_DH);
+    if (!fval(u->faction, FFL_SELECT) ) {
+      fset(u->faction, FFL_SELECT);
       ADDMSG(&u->faction->msgs, msg_message(
         "sp_raisepeasantmob_effect", "mage region",
         cansee(u->faction, r, mage, 0) ? mage : NULL, r ));
     }
   }
-  if (!fval(mage->faction, FL_DH)) {
+  if (!fval(mage->faction, FFL_SELECT)) {
       ADDMSG(&mage->faction->msgs, msg_message(
         "sp_raisepeasantmob_effect", "mage region", mage, r));
   }
@@ -4328,11 +4330,11 @@ sp_song_of_peace(castorder *co)
 
   create_curse(mage, &r->attribs, ct_find("peacezone"), force, duration, zero_effect, 0);
 
-  for (u = r->units; u; u = u->next) freset(u->faction, FL_DH);
+  for (u = r->units; u; u = u->next) freset(u->faction, FFL_SELECT);
   for (u = r->units; u; u = u->next ) {
-    if (!fval(u->faction, FL_DH) ) {
+    if (!fval(u->faction, FFL_SELECT) ) {
       message * m = NULL;
-      fset(u->faction, FL_DH);
+      fset(u->faction, FFL_SELECT);
       if (cansee(u->faction, r, mage, 0)) {
         if (msg[0]==NULL) msg[0] = msg_message("song_of_peace_effect_0", "mage", mage);
         m = msg[0];
@@ -4381,11 +4383,11 @@ sp_generous(castorder *co)
   effect.i = 2;
   create_curse(mage,&r->attribs, ct_find("generous"), force, duration, effect, 0);
 
-  for (u = r->units; u; u = u->next) freset(u->faction, FL_DH);
+  for (u = r->units; u; u = u->next) freset(u->faction, FFL_SELECT);
   for (u = r->units; u; u = u->next ) {
-    if (!fval(u->faction, FL_DH) ) {
+    if (!fval(u->faction, FFL_SELECT) ) {
       message * m = NULL;
-      fset(u->faction, FL_DH);
+      fset(u->faction, FFL_SELECT);
       if (cansee(u->faction, r, mage, 0)) {
         if (msg[0]==NULL) msg[0] = msg_message("song_of_peace_effect_0", "mage", mage);
         m = msg[0];
@@ -4802,10 +4804,10 @@ sp_raisepeasants(castorder *co)
   a->data.ca[1] = 15; /* 15% */
   a_add(&u2->attribs, a);
 
-  for (u = r->units; u; u = u->next) freset(u->faction, FL_DH);
+  for (u = r->units; u; u = u->next) freset(u->faction, FFL_SELECT);
   for (u = r->units; u; u = u->next ) {
-    if (!fval(u->faction, FL_DH) ) {
-      fset(u->faction, FL_DH);
+    if (!fval(u->faction, FFL_SELECT) ) {
+      fset(u->faction, FFL_SELECT);
       sprintf(buf, "%s wiegelt %d Bauern auf.",
           cansee(u->faction, r, mage, 0) ? unitname(mage) : "Jemand",
           u2->number);
@@ -4838,10 +4840,10 @@ sp_depression(castorder *co)
 
   create_curse(mage,&r->attribs, ct_find("depression"), force, duration, zero_effect, 0);
 
-  for (u = r->units; u; u = u->next) freset(u->faction, FL_DH);
+  for (u = r->units; u; u = u->next) freset(u->faction, FFL_SELECT);
   for (u = r->units; u; u = u->next ) {
-    if (!fval(u->faction, FL_DH) ) {
-      fset(u->faction, FL_DH);
+    if (!fval(u->faction, FFL_SELECT) ) {
+      fset(u->faction, FFL_SELECT);
       sprintf(buf, "%s sorgt f�r Tr�bsal unter den Bauern.",
           cansee(u->faction, r, mage, 0) ? unitname(mage) : "Jemand");
       addmessage(r, u->faction, buf, MSG_MAGIC, ML_INFO);
@@ -5451,15 +5453,15 @@ sp_dream_of_confusion(castorder *co)
     c = create_curse(mage, &r2->attribs,
       ct_find("disorientationzone"), power, duration, effect, 0);
 
-    for (u = r2->units; u; u = u->next) freset(u->faction, FL_DH);
+    for (u = r2->units; u; u = u->next) freset(u->faction, FFL_SELECT);
     for (u = r2->units; u; u = u->next ) {
-      if (!fval(u->faction, FL_DH) ) {
-        fset(u->faction, FL_DH);
+      if (!fval(u->faction, FFL_SELECT) ) {
+        fset(u->faction, FFL_SELECT);
         if (!m) m = msg_message("confusion_result", "mage", mage);
         add_message(&u->faction->msgs, m);
       }
     }
-    if (!fval(mage->faction, FL_DH)) {
+    if (!fval(mage->faction, FFL_SELECT)) {
       if (!m) m = msg_message("confusion_result", "mage", mage);
       add_message(&u->faction->msgs, m);
     }
@@ -5711,12 +5713,12 @@ sp_enterastral(castorder *co)
 
       /* Meldungen in der Ausgangsregion */
 
-      for (u2 = r->units; u2; u2 = u2->next) freset(u2->faction, FL_DH);
+      for (u2 = r->units; u2; u2 = u2->next) freset(u2->faction, FFL_SELECT);
       m = NULL;
       for (u2 = r->units; u2; u2 = u2->next ) {
-        if (!fval(u2->faction, FL_DH)) {
+        if (!fval(u2->faction, FFL_SELECT)) {
           if (cansee(u2->faction, r, u, 0)) {
-            fset(u2->faction, FL_DH);
+            fset(u2->faction, FFL_SELECT);
             if (!m) m = msg_message("astral_disappear", "unit", u);
             r_addmessage(rt, u2->faction, m);
           }
@@ -5726,12 +5728,12 @@ sp_enterastral(castorder *co)
 
       /* Meldungen in der Zielregion */
 
-      for (u2 = rt->units; u2; u2 = u2->next) freset(u2->faction, FL_DH);
+      for (u2 = rt->units; u2; u2 = u2->next) freset(u2->faction, FFL_SELECT);
       m = NULL;
       for (u2 = rt->units; u2; u2 = u2->next ) {
-        if (!fval(u2->faction, FL_DH)) {
+        if (!fval(u2->faction, FFL_SELECT)) {
           if (cansee(u2->faction, rt, u, 0)) {
-            fset(u2->faction, FL_DH);
+            fset(u2->faction, FFL_SELECT);
             if (!m) m = msg_message("astral_appear", "unit", u);
             r_addmessage(rt, u2->faction, m);
           }
@@ -5845,12 +5847,12 @@ sp_pullastral(castorder *co)
 
         /* Meldungen in der Ausgangsregion */
 
-        for (u2 = r->units; u2; u2 = u2->next) freset(u2->faction, FL_DH);
+        for (u2 = r->units; u2; u2 = u2->next) freset(u2->faction, FFL_SELECT);
         m = NULL;
         for (u2 = r->units; u2; u2 = u2->next ) {
-          if (!fval(u2->faction, FL_DH)) {
+          if (!fval(u2->faction, FFL_SELECT)) {
             if (cansee(u2->faction, r, u, 0)) {
-              fset(u2->faction, FL_DH);
+              fset(u2->faction, FFL_SELECT);
               if (!m) m = msg_message("astral_disappear", "unit", u);
               r_addmessage(rt, u2->faction, m);
             }
@@ -5860,12 +5862,12 @@ sp_pullastral(castorder *co)
 
         /* Meldungen in der Zielregion */
 
-        for (u2 = rt->units; u2; u2 = u2->next) freset(u2->faction, FL_DH);
+        for (u2 = rt->units; u2; u2 = u2->next) freset(u2->faction, FFL_SELECT);
         m = NULL;
         for (u2 = rt->units; u2; u2 = u2->next ) {
-          if (!fval(u2->faction, FL_DH)) {
+          if (!fval(u2->faction, FFL_SELECT)) {
             if (cansee(u2->faction, rt, u, 0)) {
-              fset(u2->faction, FL_DH);
+              fset(u2->faction, FFL_SELECT);
               if (!m) m = msg_message("astral_appear", "unit", u);
               r_addmessage(rt, u2->faction, m);
             }
@@ -5958,12 +5960,12 @@ sp_leaveastral(castorder *co)
 
       /* Meldungen in der Ausgangsregion */
 
-      for (u2 = r->units; u2; u2 = u2->next) freset(u2->faction, FL_DH);
+      for (u2 = r->units; u2; u2 = u2->next) freset(u2->faction, FFL_SELECT);
       m = NULL;
       for (u2 = r->units; u2; u2 = u2->next ) {
-        if (!fval(u2->faction, FL_DH)) {
+        if (!fval(u2->faction, FFL_SELECT)) {
           if (cansee(u2->faction, r, u, 0)) {
-            fset(u2->faction, FL_DH);
+            fset(u2->faction, FFL_SELECT);
             if (!m) m = msg_message("astral_disappear", "unit", u);
             r_addmessage(rt, u2->faction, m);
           }
@@ -5973,12 +5975,12 @@ sp_leaveastral(castorder *co)
 
       /* Meldungen in der Zielregion */
 
-      for (u2 = rt->units; u2; u2 = u2->next) freset(u2->faction, FL_DH);
+      for (u2 = rt->units; u2; u2 = u2->next) freset(u2->faction, FFL_SELECT);
       m = NULL;
       for (u2 = rt->units; u2; u2 = u2->next ) {
-        if (!fval(u2->faction, FL_DH)) {
+        if (!fval(u2->faction, FFL_SELECT)) {
           if (cansee(u2->faction, rt, u, 0)) {
-            fset(u2->faction, FL_DH);
+            fset(u2->faction, FFL_SELECT);
             if (!m) m = msg_message("astral_appear", "unit", u);
             r_addmessage(rt, u2->faction, m);
           }
@@ -6077,12 +6079,12 @@ sp_fetchastral(castorder *co)
     move_unit(u, rt, NULL);
 
     /* Meldungen in der Ausgangsregion */
-    for (u2 = ro->units; u2; u2 = u2->next) freset(u2->faction, FL_DH);
+    for (u2 = ro->units; u2; u2 = u2->next) freset(u2->faction, FFL_SELECT);
     m = NULL;
     for (u2 = ro->units; u2; u2 = u2->next ) {
-      if (!fval(u2->faction, FL_DH)) {
+      if (!fval(u2->faction, FFL_SELECT)) {
         if (cansee(u2->faction, ro, u, 0)) {
-          fset(u2->faction, FL_DH);
+          fset(u2->faction, FFL_SELECT);
           if (!m) m = msg_message("astral_disappear", "unit", u);
           r_addmessage(ro, u2->faction, m);
         }
@@ -6091,12 +6093,12 @@ sp_fetchastral(castorder *co)
     if (m) msg_release(m);
 
     /* Meldungen in der Zielregion */
-    for (u2 = rt->units; u2; u2 = u2->next) freset(u2->faction, FL_DH);
+    for (u2 = rt->units; u2; u2 = u2->next) freset(u2->faction, FFL_SELECT);
     m = NULL;
     for (u2 = rt->units; u2; u2 = u2->next ) {
-      if (!fval(u2->faction, FL_DH)) {
+      if (!fval(u2->faction, FFL_SELECT)) {
         if (cansee(u2->faction, rt, u, 0)) {
-          fset(u2->faction, FL_DH);
+          fset(u2->faction, FFL_SELECT);
           if (!m) m = msg_message("astral_appear", "unit", u);
           r_addmessage(rt, u2->faction, m);
         }
@@ -6377,10 +6379,10 @@ sp_eternizewall(castorder *co)
   }
 
   /* melden, 1x pro Partei in der Burg */
-  for (u = r->units; u; u = u->next) freset(u->faction, FL_DH);
+  for (u = r->units; u; u = u->next) freset(u->faction, FFL_SELECT);
   for (u = r->units; u; u = u->next) {
-    if (!fval(u->faction, FL_DH)) {
-      fset(u->faction, FL_DH);
+    if (!fval(u->faction, FFL_SELECT)) {
+      fset(u->faction, FFL_SELECT);
       if (u->building ==  b) {
         sprintf(buf, "Mit einem Ritual bindet %s die magischen Kr�fte "
             "der Erde in die Mauern von %s", unitname(mage),
@@ -6606,11 +6608,11 @@ sp_flying_ship(castorder *co)
   sh->coast = NODIRECTION;
 
   /* melden, 1x pro Partei */
-  for (u = r->units; u; u = u->next) freset(u->faction, FL_DH);
+  for (u = r->units; u; u = u->next) freset(u->faction, FFL_SELECT);
   for(u = r->units; u; u = u->next ) {
     /* das sehen nat�rlich auch die Leute an Land */
-    if (!fval(u->faction, FL_DH) ) {
-      fset(u->faction, FL_DH);
+    if (!fval(u->faction, FFL_SELECT) ) {
+      fset(u->faction, FFL_SELECT);
       if (!m) m = msg_message("flying_ship_result", "mage ship", mage, sh);
       add_message(&u->faction->msgs, m);
     }
diff --git a/src/common/spells/unitcurse.c b/src/common/spells/unitcurse.c
index e4cfa9c15..d709c18f7 100644
--- a/src/common/spells/unitcurse.c
+++ b/src/common/spells/unitcurse.c
@@ -16,15 +16,17 @@
 #include "unitcurse.h"
 
 /* kernel includes */
+#include <kernel/curse.h>
 #include <kernel/message.h>
 #include <kernel/race.h>
 #include <kernel/skill.h>
 #include <kernel/unit.h>
 #include <kernel/faction.h>
 #include <kernel/objtypes.h>
-#include <kernel/curse.h>
+#include <kernel/version.h>
 
 /* util includes */
+#include <util/language.h>
 #include <util/nrmessage.h>
 #include <util/message.h>
 #include <util/base36.h>
diff --git a/src/common/triggers/changefaction.c b/src/common/triggers/changefaction.c
index 201350904..ac96f96f1 100644
--- a/src/common/triggers/changefaction.c
+++ b/src/common/triggers/changefaction.c
@@ -22,9 +22,10 @@
 #include <faction.h> /* FIXME: resolve_faction */
 
 /* util includes */
-#include <resolve.h>
-#include <event.h>
-#include <base36.h>
+#include <util/attrib.h>
+#include <util/event.h>
+#include <util/resolve.h>
+#include <util/base36.h>
 
 /* ansi includes */
 #include <stdio.h>
diff --git a/src/common/triggers/changerace.c b/src/common/triggers/changerace.c
index 55ea8288d..0f0643f07 100644
--- a/src/common/triggers/changerace.c
+++ b/src/common/triggers/changerace.c
@@ -21,9 +21,10 @@
 #include <race.h>
 
 /* util includes */
-#include <event.h>
-#include <resolve.h>
-#include <base36.h>
+#include <util/attrib.h>
+#include <util/event.h>
+#include <util/resolve.h>
+#include <util/base36.h>
 
 /* ansi includes */
 #include <stdio.h>
diff --git a/src/common/triggers/clonedied.c b/src/common/triggers/clonedied.c
index 9cb3f89f9..3e7e07df4 100644
--- a/src/common/triggers/clonedied.c
+++ b/src/common/triggers/clonedied.c
@@ -22,9 +22,10 @@
 #include <unit.h>
 
 /* util includes */
-#include <event.h>
-#include <resolve.h>
-#include <base36.h>
+#include <util/attrib.h>
+#include <util/event.h>
+#include <util/resolve.h>
+#include <util/base36.h>
 
 /* libc includes */
 #include <stdio.h>
diff --git a/src/common/triggers/createcurse.c b/src/common/triggers/createcurse.c
index d65f1cc89..8ae4c106d 100644
--- a/src/common/triggers/createcurse.c
+++ b/src/common/triggers/createcurse.c
@@ -17,13 +17,15 @@
 #include "createcurse.h"
 
 /* kernel includes */
+#include <version.h>
 #include <curse.h>
 #include <unit.h>
 
 /* util includes */
-#include <event.h>
-#include <resolve.h>
-#include <base36.h>
+#include <util/attrib.h>
+#include <util/event.h>
+#include <util/resolve.h>
+#include <util/base36.h>
 
 /* ansi includes */
 #include <stdio.h>
diff --git a/src/common/triggers/createunit.c b/src/common/triggers/createunit.c
index bf083729e..b564530c5 100644
--- a/src/common/triggers/createunit.c
+++ b/src/common/triggers/createunit.c
@@ -23,9 +23,11 @@
 #include <region.h>
 
 /* util includes */
-#include <event.h>
-#include <resolve.h>
-#include <base36.h>
+#include <util/attrib.h>
+#include <util/base36.h>
+#include <util/event.h>
+#include <util/log.h>
+#include <util/resolve.h>
 
 /* ansi includes */
 #include <stdio.h>
@@ -65,7 +67,7 @@ createunit_handle(trigger * t, void * data)
 	 */
 	createunit_data * td = (createunit_data*)t->data.v;
 	if (td->r!=NULL && td->f!=NULL) {
-		createunit(td->r, td->f, td->number, td->race);
+		create_unit(td->r, td->f, td->number, td->race, 0, NULL, NULL);
 	} else {
 		log_error(("could not perform createunit::handle()\n"));
 	}
diff --git a/src/common/triggers/gate.c b/src/common/triggers/gate.c
index 8c3bf7b2b..6d70e0cec 100644
--- a/src/common/triggers/gate.c
+++ b/src/common/triggers/gate.c
@@ -19,8 +19,9 @@
 #include <unit.h>
 
 /* util includes */
-#include <event.h>
-#include <log.h>
+#include <util/attrib.h>
+#include <util/event.h>
+#include <util/log.h>
 
 /* libc includes */
 #include <stdlib.h>
diff --git a/src/common/triggers/giveitem.c b/src/common/triggers/giveitem.c
index c54f6daed..669eba9fe 100644
--- a/src/common/triggers/giveitem.c
+++ b/src/common/triggers/giveitem.c
@@ -21,9 +21,10 @@
 #include <unit.h>
 
 /* util includes */
-#include <event.h>
-#include <resolve.h>
-#include <base36.h>
+#include <util/attrib.h>
+#include <util/base36.h>
+#include <util/event.h>
+#include <util/resolve.h>
 
 /* ansi includes */
 #include <stdio.h>
diff --git a/src/common/triggers/removecurse.c b/src/common/triggers/removecurse.c
index 849a1386d..49b7101d0 100644
--- a/src/common/triggers/removecurse.c
+++ b/src/common/triggers/removecurse.c
@@ -21,9 +21,10 @@
 #include <unit.h>
 
 /* util includes */
-#include <event.h>
-#include <resolve.h>
-#include <base36.h>
+#include <util/attrib.h>
+#include <util/event.h>
+#include <util/resolve.h>
+#include <util/base36.h>
 
 /* ansi includes */
 #include <stdio.h>
diff --git a/src/common/triggers/timeout.c b/src/common/triggers/timeout.c
index 92a1fb858..a367bf341 100644
--- a/src/common/triggers/timeout.c
+++ b/src/common/triggers/timeout.c
@@ -17,8 +17,9 @@
 #include "timeout.h"
 
 /* util includes */
-#include <event.h>
-#include <log.h>
+#include <util/attrib.h>
+#include <util/event.h>
+#include <util/log.h>
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/src/common/triggers/unitmessage.c b/src/common/triggers/unitmessage.c
index a32f6507c..d7ac44f34 100644
--- a/src/common/triggers/unitmessage.c
+++ b/src/common/triggers/unitmessage.c
@@ -17,13 +17,14 @@
 #include "unitmessage.h"
 
 /* kernel includes */
-#include <unit.h>
+#include <kernel/unit.h>
 
 /* util includes */
-#include <resolve.h>
-#include <event.h>
-#include <base36.h>
-#include <goodies.h>
+#include <util/attrib.h>
+#include <util/resolve.h>
+#include <util/event.h>
+#include <util/base36.h>
+#include <util/goodies.h>
 
 /* ansi includes */
 #include <stdio.h>
diff --git a/src/eressea/editing.c b/src/eressea/editing.c
index b2410b035..5e646ab1c 100644
--- a/src/eressea/editing.c
+++ b/src/eressea/editing.c
@@ -15,6 +15,7 @@
 #include <kernel/region.h>
 #include <modules/autoseed.h>
 #include <util/rng.h>
+#include <util/lists.h>
 
 #define ISLANDSIZE 20
 #define TURNS_PER_ISLAND 4
diff --git a/src/eressea/gmtool.c b/src/eressea/gmtool.c
index 228cb234a..d3e144b5b 100644
--- a/src/eressea/gmtool.c
+++ b/src/eressea/gmtool.c
@@ -49,6 +49,7 @@
 #include <kernel/ship.h>
 #include <kernel/terrain.h>
 #include <kernel/xmlreader.h>
+#include <kernel/version.h>
 
 #include <spells/spells.h>
 #include <attributes/attributes.h>
@@ -551,14 +552,14 @@ paint_info_region(window * wnd, const state * st)
       mvwaddnstr(win, line++, 1, "* factions:", size-5);
       wattroff(win, A_BOLD | COLOR_PAIR(COLOR_YELLOW));
       for (u=r->units;u && line<maxline;u=u->next) {
-        if (!fval(u->faction, FL_MARK)) {
+        if (!fval(u->faction, FFL_MARK)) {
           mvwprintw(win, line, 1, "%.4s ", itoa36(u->faction->no));
           mvwaddnstr(win, line++, 6, u->faction->name, size-5);
-          fset(u->faction, FL_MARK);
+          fset(u->faction, FFL_MARK);
         }
       }
       for (u=r->units;u && line<maxline;u=u->next) {
-        freset(u->faction, FL_MARK);
+        freset(u->faction, FFL_MARK);
       }
     }
     if (r->units && (st->info_flags & IFL_UNITS)) {
diff --git a/src/eressea/korrektur.c b/src/eressea/korrektur.c
index eb2d4f78b..7d3048820 100644
--- a/src/eressea/korrektur.c
+++ b/src/eressea/korrektur.c
@@ -19,7 +19,7 @@
  */
 
 #include <config.h>
-#include <eressea.h>
+#include <types.h>
 
 /* misc includes */
 #include <attributes/key.h>
@@ -41,6 +41,7 @@
 #include <kernel/building.h>
 #include <kernel/calendar.h>
 #include <kernel/equipment.h>
+#include <kernel/eressea.h>
 #include <kernel/faction.h>
 #include <kernel/item.h>
 #include <kernel/magic.h>
@@ -62,6 +63,7 @@
 #include <kernel/terrain.h>
 #include <kernel/terrainid.h>
 #include <kernel/unit.h>
+#include <kernel/version.h>
 
 /* util includes */
 #include <util/attrib.h>
@@ -103,15 +105,15 @@ curse_emptiness(void)
     if (r->age<=200) continue;
     if (get_curse(r->attribs, ct)) continue;
     while (u && u->faction->no==MONSTER_FACTION) u=u->next;
-    if (u==NULL) fset(r, FL_MARK);
+    if (u==NULL) fset(r, RF_MARK);
   }
   for (r=regions;r!=NULL;r=r->next) {
-    if (fval(r, FL_MARK)) {
+    if (fval(r, RF_MARK)) {
       direction_t d;
       for (d=0;d!=MAXDIRECTIONS;++d) {
         region * rn = rconnect(r,d);
         if (rn==NULL) continue;
-        if (fval(rn, FL_MARK) || get_curse(rn->attribs, ct)) {
+        if (fval(rn, RF_MARK) || get_curse(rn->attribs, ct)) {
           break;
         }
       }
@@ -121,7 +123,7 @@ curse_emptiness(void)
         effect.i = 0;
         c = create_curse(NULL, &r->attribs, ct, 100, 100, effect, 0);
       }
-      freset(r, FL_MARK);
+      freset(r, RF_MARK);
     }
   }
   return 0;
@@ -452,13 +454,6 @@ get_timeout(trigger * td, trigger * tfind)
 #include <triggers/shock.h>
 #include <triggers/killunit.h>
 
-extern struct attrib_type at_resources;
-void
-init_resourcefix(void)
-{
-  at_register(&at_resources);
-}
-
 int
 growing_trees(void)
 {
diff --git a/src/eressea/lua/building.cpp b/src/eressea/lua/building.cpp
index b31587db9..0a62c4d93 100644
--- a/src/eressea/lua/building.cpp
+++ b/src/eressea/lua/building.cpp
@@ -19,7 +19,9 @@
 #endif
 
 // util includes
+#include <util/attrib.h>
 #include <util/base36.h>
+#include <util/lists.h>
 #include <util/log.h>
 
 using namespace luabind;
diff --git a/src/eressea/lua/eressea.cpp b/src/eressea/lua/eressea.cpp
index 04a22a00a..72cd8fb7d 100644
--- a/src/eressea/lua/eressea.cpp
+++ b/src/eressea/lua/eressea.cpp
@@ -27,7 +27,9 @@
 #include <luabind/iterator_policy.hpp>
 
 // util includes
+#include <util/attrib.h>
 #include <util/language.h>
+#include <util/lists.h>
 #include <util/base36.h>
 #include <util/rand.h>
 #include <util/rng.h>
diff --git a/src/eressea/lua/faction.cpp b/src/eressea/lua/faction.cpp
index fe7f18594..38aac4c33 100644
--- a/src/eressea/lua/faction.cpp
+++ b/src/eressea/lua/faction.cpp
@@ -12,8 +12,9 @@
 #include <kernel/unit.h>
 
 // util includes
-#include <util/base36.h>
 #include <util/attrib.h>
+#include <util/base36.h>
+#include <util/language.h>
 
 // attrib includes
 #include <attributes/attributes.h>
diff --git a/src/eressea/lua/gamecode.cpp b/src/eressea/lua/gamecode.cpp
index 0767eaf9c..319e04adf 100644
--- a/src/eressea/lua/gamecode.cpp
+++ b/src/eressea/lua/gamecode.cpp
@@ -37,6 +37,7 @@
 #include <luabind/iterator_policy.hpp>
 
 // util includes
+#include <util/lists.h>
 #include <util/language.h>
 #include <util/base36.h>
 #include <util/rand.h>
diff --git a/src/eressea/lua/region.cpp b/src/eressea/lua/region.cpp
index 06028bef5..27c650aba 100644
--- a/src/eressea/lua/region.cpp
+++ b/src/eressea/lua/region.cpp
@@ -13,6 +13,8 @@
 #include <kernel/terrain.h>
 #include <kernel/unit.h>
 
+#include <util/attrib.h>
+
 #include <attributes/key.h>
 
 // lua includes
diff --git a/src/eressea/lua/unit.cpp b/src/eressea/lua/unit.cpp
index 00ad5b6e3..d11860aa3 100644
--- a/src/eressea/lua/unit.cpp
+++ b/src/eressea/lua/unit.cpp
@@ -25,8 +25,10 @@
 #include <kernel/unit.h>
 
 // util includes
+#include <util/attrib.h>
 #include <util/base36.h>
 #include <util/event.h>
+#include <util/lists.h>
 
 // lua includes
 #include <lua.hpp>
diff --git a/src/eressea/main.c b/src/eressea/main.c
index ca882c1e9..08f082068 100644
--- a/src/eressea/main.c
+++ b/src/eressea/main.c
@@ -88,6 +88,7 @@
 #include <util/xml.h>
 #include <util/goodies.h>
 #include <util/log.h>
+#include <util/lists.h>
 #include <util/sql.h>
 #include <util/base36.h>
 
diff --git a/src/eressea/server.cpp b/src/eressea/server.cpp
index 1b84a9e0e..6243940d3 100644
--- a/src/eressea/server.cpp
+++ b/src/eressea/server.cpp
@@ -81,6 +81,7 @@
 #include <kernel/teleport.h>
 #include <kernel/unit.h>
 #include <kernel/xmlreader.h>
+#include <kernel/version.h>
 
 
 /* util includes */