diff --git a/CMakeLists.txt b/CMakeLists.txt
index d60d3d721..9b26ecb6e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,56 +14,6 @@ find_package (Curses)
 find_package (Lua REQUIRED)
 find_package (ToLua REQUIRED)
 
-INCLUDE (CheckIncludeFiles)
-INCLUDE (CheckSymbolExists)
-CHECK_INCLUDE_FILES (stdbool.h HAVE_STDBOOL_H)
-CHECK_INCLUDE_FILES (windows.h HAVE_WINDOWS_H)
-CHECK_INCLUDE_FILES (io.h HAVE_IO_H)
-CHECK_INCLUDE_FILES (strings.h HAVE_STRINGS_H)
-CHECK_INCLUDE_FILES (unistd.h HAVE_UNISTD_H)
-IF (HAVE_IO_H)
-CHECK_SYMBOL_EXISTS (_access "io.h" HAVE__ACCESS)
-ENDIF (HAVE_IO_H)
-IF (HAVE_WINDOWS_H)
-CHECK_SYMBOL_EXISTS (_sleep "windows.h" HAVE__SLEEP)
-ENDIF(HAVE_WINDOWS_H)
-IF(HAVE_STDBOOL_H)
-CHECK_SYMBOL_EXISTS (_Bool "stdbool.h" HAVE__BOOL)
-ENDIF(HAVE_STDBOOL_H)
-IF(HAVE_UNISTD_H)
-CHECK_SYMBOL_EXISTS (sleep "unistd.h" HAVE_SLEEP)
-CHECK_SYMBOL_EXISTS (usleep "unistd.h" HAVE_USLEEP)
-CHECK_SYMBOL_EXISTS (access "unistd.h" HAVE_ACCESS)
-ENDIF(HAVE_UNISTD_H)
-CHECK_SYMBOL_EXISTS (strlcpy "string.h" HAVE_STRLCPY)
-CHECK_SYMBOL_EXISTS (strlcat "string.h" HAVE_STRLCAT)
-CHECK_SYMBOL_EXISTS (slprintf "string.h" HAVE_SLPRINTF)
-CHECK_SYMBOL_EXISTS (strcasecmp "string.h" HAVE_STRCASECMP)
-CHECK_SYMBOL_EXISTS (strncasecmp "string.h" HAVE_STRNCASECMP)
-CHECK_SYMBOL_EXISTS (_strlwr "string.h" HAVE__STRLWR)
-CHECK_SYMBOL_EXISTS (_strcmpl "string.h" HAVE__STRCMPL)
-CHECK_SYMBOL_EXISTS (_strdup "string.h" HAVE__STRDUP)
-CHECK_SYMBOL_EXISTS (_stricmp "string.h" HAVE__STRICMP)
-CHECK_SYMBOL_EXISTS (_memicmp "string.h" HAVE__MEMICMP)
-CHECK_SYMBOL_EXISTS (strcmpl "string.h" HAVE_STRCMPL)
-CHECK_SYMBOL_EXISTS (strdup "string.h" HAVE_STRDUP)
-CHECK_SYMBOL_EXISTS (stricmp "string.h" HAVE_STRICMP)
-CHECK_SYMBOL_EXISTS (memicmp "string.h" HAVE_MEMICMP)
-CHECK_SYMBOL_EXISTS (strlwr "string.h" HAVE_STRLWR)
-CHECK_SYMBOL_EXISTS (snprintf "stdio.h" HAVE_SNPRINTF)
-CHECK_SYMBOL_EXISTS (_snprintf "stdio.h" HAVE__SNPRINTF)
-CHECK_SYMBOL_EXISTS (mkdir "sys/stat.h" HAVE_SYS_STAT_MKDIR)
-CHECK_SYMBOL_EXISTS (mkdir "direct.h" HAVE_DIRECT_MKDIR)
-CHECK_SYMBOL_EXISTS (_mkdir "direct.h" HAVE_DIRECT__MKDIR)
-
-CONFIGURE_FILE (
-    ${CMAKE_CURRENT_SOURCE_DIR}/autoconf.h.in
-    ${CMAKE_BINARY_DIR}/include/autoconf.h)
-INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/include)
-
-## skip compiler/libc detection and force cmake autoconf:
-#add_definitions(-DUSE_AUTOCONF)
-
 add_subdirectory (cutest)
 add_subdirectory (cJSON)
 add_subdirectory (storage)
diff --git a/autoconf.h.in b/autoconf.h.in
deleted file mode 100644
index f3f197db1..000000000
--- a/autoconf.h.in
+++ /dev/null
@@ -1,36 +0,0 @@
-#pragma once
-#ifndef CMAKE_AUTOCONF_H
-#define CMAKE_AUTOCONF_H
-#cmakedefine HAVE_STDBOOL_H 1
-#cmakedefine HAVE_STRINGS_H 1
-#cmakedefine HAVE_WINDOWS_H 1
-#cmakedefine HAVE_IO_H 1
-#cmakedefine HAVE_UNISTD_H 1
-#cmakedefine HAVE__BOOL 1
-#cmakedefine HAVE_STRCASECMP 1
-#cmakedefine HAVE_STRNCASECMP 1
-#cmakedefine HAVE__STRICMP 1
-#cmakedefine HAVE_SNPRINTF 1
-#cmakedefine HAVE__SNPRINTF 1
-#cmakedefine HAVE_ACCESS 1
-#cmakedefine HAVE__ACCESS 1
-#cmakedefine HAVE_SLEEP 1
-#cmakedefine HAVE_USLEEP 1
-#cmakedefine HAVE__SLEEP 1
-#cmakedefine HAVE_STRDUP 1
-#cmakedefine HAVE__STRDUP 1
-#cmakedefine HAVE_STRICMP 1
-#cmakedefine HAVE__STRCMPL 1
-#cmakedefine HAVE_STRCMPL 1
-#cmakedefine HAVE__MEMICMP 1
-#cmakedefine HAVE_MEMICMP 1
-#cmakedefine HAVE__STRLWR 1
-#cmakedefine HAVE_STRLWR 1
-#cmakedefine HAVE_STRLCPY 1
-#cmakedefine HAVE_STRLCAT 1
-#cmakedefine HAVE_SLPRINTF 1
-#cmakedefine HAVE_SYS_STAT_MKDIR 1
-#cmakedefine HAVE_DIRECT_MKDIR 1
-#cmakedefine HAVE_DIRECT__MKDIR 1
-
-#endif
diff --git a/src/academy.c b/src/academy.c
index f6b70873e..496c1ef8e 100644
--- a/src/academy.c
+++ b/src/academy.c
@@ -35,7 +35,7 @@ bool academy_can_teach(unit *teacher, unit *student, skill_t sk) {
     const struct building_type *btype = bt_find("academy");
     if (active_building(teacher, btype) && active_building(student, btype)) {
         int j = study_cost(student, sk);
-        j = _max(50, j * 2);
+        j = MAX(50, j * 2);
         /* kann Einheit das zahlen? */
         return get_pooled(student, get_resourcetype(R_SILVER), GET_DEFAULT, j) >= j;
         /* sonst nehmen sie nicht am Unterricht teil */
diff --git a/src/alchemy.c b/src/alchemy.c
index 9bc180700..ddbe46b8e 100644
--- a/src/alchemy.c
+++ b/src/alchemy.c
@@ -73,12 +73,12 @@ void herbsearch(unit * u, int max)
     }
 
     if (max)
-        max = _min(max, rherbs(r));
+        max = MIN(max, rherbs(r));
     else
         max = rherbs(r);
     herbsfound = ntimespprob(effsk * u->number,
         (double)rherbs(r) / 100.0F, -0.01F);
-    herbsfound = _min(herbsfound, max);
+    herbsfound = MIN(herbsfound, max);
     rsetherbs(r, (short) (rherbs(r) - herbsfound));
 
     if (herbsfound) {
@@ -156,7 +156,7 @@ static int potion_water_of_life(unit * u, region *r, int amount) {
 }
 
 static int potion_healing(unit * u, int amount) {
-    u->hp = _min(unit_max_hp(u) * u->number, u->hp + 400 * amount);
+    u->hp = MIN(unit_max_hp(u) * u->number, u->hp + 400 * amount);
     return amount;
 }
 
@@ -182,7 +182,7 @@ static int potion_power(unit *u, int amount) {
         amount = use;
     }
     /* Verf�nffacht die HP von max. 10 Personen in der Einheit */
-    u->hp += _min(u->number, 10 * amount) * unit_max_hp(u) * 4;
+    u->hp += MIN(u->number, 10 * amount) * unit_max_hp(u) * 4;
     return amount;
 }
 
@@ -248,7 +248,7 @@ static void free_potiondelay(attrib * a) {
 static int age_potiondelay(attrib * a, void *owner)
 {
     potiondelay *pd = (potiondelay *)a->data.v;
-    unused_arg(owner);
+    UNUSED_ARG(owner);
     pd->amount = do_potion(pd->u, pd->r, pd->ptype, pd->amount);
     return AT_AGE_REMOVE;
 }
diff --git a/src/attributes/dict.c b/src/attributes/dict.c
index 2bba9ea7b..a3f034145 100644
--- a/src/attributes/dict.c
+++ b/src/attributes/dict.c
@@ -103,7 +103,7 @@ static int dict_read(attrib * a, void *owner, gamedata *data)
     float flt;
 
     READ_STR(store, name, sizeof(name));
-    dd->name = _strdup(name);
+    dd->name = strdup(name);
     READ_INT(store, &n);
     dd->type = (dict_type)n;
     switch (dd->type) {
@@ -122,7 +122,7 @@ static int dict_read(attrib * a, void *owner, gamedata *data)
         break;
     case TSTRING:
         READ_STR(store, name, sizeof(name));
-        dd->data.str = _strdup(name);
+        dd->data.str = strdup(name);
         break;
     case TBUILDING:
         result =
@@ -199,7 +199,7 @@ struct attrib *dict_create(const char *name, dict_type type, variant value)
 {
     attrib *a = a_new(&at_dict);
     dict_data *data = (dict_data *)a->data.v;
-    data->name = _strdup(name);
+    data->name = strdup(name);
 
     dict_set(a, type, value);
     return a;
@@ -214,7 +214,7 @@ void dict_set(attrib * a, dict_type type, variant value)
     data->type = type;
     switch (type) {
     case TSTRING:
-        data->data.str = value.v ? _strdup(value.v) : NULL;
+        data->data.str = value.v ? strdup(value.v) : NULL;
         break;
     case TINTEGER:
         data->data.i = value.i;
diff --git a/src/attributes/hate.c b/src/attributes/hate.c
index 98a36a029..17155fc71 100644
--- a/src/attributes/hate.c
+++ b/src/attributes/hate.c
@@ -30,7 +30,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 static int verify_hate(attrib * a, void *owner)
 {
-    unused_arg(owner);
+    UNUSED_ARG(owner);
     if (a->data.v == NULL) {
         return 0;
     }
diff --git a/src/attributes/moved.c b/src/attributes/moved.c
index 3da2a4c3b..c66a5489c 100644
--- a/src/attributes/moved.c
+++ b/src/attributes/moved.c
@@ -27,7 +27,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 static int age_moved(attrib * a, void *owner)
 {
-    unused_arg(owner);
+    UNUSED_ARG(owner);
     --a->data.i;
     return a->data.i > 0;
 }
diff --git a/src/attributes/movement.c b/src/attributes/movement.c
index 874da5eb3..4d79039ef 100644
--- a/src/attributes/movement.c
+++ b/src/attributes/movement.c
@@ -67,7 +67,7 @@ void set_movement(attrib ** alist, int type)
 
 static int age_speedup(attrib * a, void *owner)
 {
-    unused_arg(owner);
+    UNUSED_ARG(owner);
     if (a->data.sa[0] > 0) {
         assert(a->data.sa[0] - a->data.sa[1] >= SHRT_MIN);
         assert(a->data.sa[0] - a->data.sa[1] <= SHRT_MAX);
diff --git a/src/attributes/racename.c b/src/attributes/racename.c
index b408cbf6a..c45fa3815 100644
--- a/src/attributes/racename.c
+++ b/src/attributes/racename.c
@@ -43,7 +43,7 @@ void set_racename(attrib ** palist, const char *name)
     attrib *a = a_find(*palist, &at_racename);
     if (!a && name) {
         a = a_add(palist, a_new(&at_racename));
-        a->data.v = _strdup(name);
+        a->data.v = strdup(name);
     }
     else if (a && !name) {
         a_remove(palist, a);
@@ -51,7 +51,7 @@ void set_racename(attrib ** palist, const char *name)
     else if (a) {
         if (strcmp(a->data.v, name) != 0) {
             free(a->data.v);
-            a->data.v = _strdup(name);
+            a->data.v = strdup(name);
         }
     }
 }
diff --git a/src/attributes/raceprefix.c b/src/attributes/raceprefix.c
index 15f0036c1..a87edfb80 100644
--- a/src/attributes/raceprefix.c
+++ b/src/attributes/raceprefix.c
@@ -41,7 +41,7 @@ void set_prefix(attrib ** ap, const char *str)
         free(a->data.v);
     }
     assert(a->type == &at_raceprefix);
-    a->data.v = _strdup(str);
+    a->data.v = strdup(str);
 }
 
 const char *get_prefix(attrib * a)
@@ -53,7 +53,7 @@ const char *get_prefix(attrib * a)
     str = (char *)a->data.v;
     /* conversion of old prefixes */
     if (strncmp(str, "prefix_", 7) == 0) {
-        ((attrib *)a)->data.v = _strdup(str + 7);
+        ((attrib *)a)->data.v = strdup(str + 7);
         free(str);
         str = (char *)a->data.v;
     }
diff --git a/src/battle.c b/src/battle.c
index ed83871ec..3b34cd162 100644
--- a/src/battle.c
+++ b/src/battle.c
@@ -440,7 +440,7 @@ static int get_row(const side * s, int row, const side * vs)
     /* every entry in the size[] array means someone trying to defend us.
      * 'retreat' is the number of rows falling.
      */
-    result = _max(FIRST_ROW, row - retreat);
+    result = MAX(FIRST_ROW, row - retreat);
 
     return result;
 }
@@ -600,12 +600,12 @@ weapon_skill(const weapon_type * wtype, const unit * u, bool attacking)
             if (u_race(u) == get_race(RC_ORC)) {
                 int sword = effskill(u, SK_MELEE, 0);
                 int spear = effskill(u, SK_SPEAR, 0);
-                skill = _max(sword, spear) - 3;
+                skill = MAX(sword, spear) - 3;
                 if (attacking) {
-                    skill = _max(skill, u_race(u)->at_default);
+                    skill = MAX(skill, u_race(u)->at_default);
                 }
                 else {
-                    skill = _max(skill, u_race(u)->df_default);
+                    skill = MAX(skill, u_race(u)->df_default);
                 }
             }
             else {
@@ -685,7 +685,7 @@ static int CavalryBonus(const unit * u, troop enemy, int type)
         /* only half against trolls */
         if (skl > 0) {
             if (type == BONUS_SKILL) {
-                int dmg = _min(skl, 8);
+                int dmg = MIN(skl, 8);
                 if (u_race(enemy.fighter->unit) == get_race(RC_TROLL)) {
                     dmg = dmg / 4;
                 }
@@ -696,7 +696,7 @@ static int CavalryBonus(const unit * u, troop enemy, int type)
             }
             else {
                 skl = skl / 2;
-                return _min(skl, 4);
+                return MIN(skl, 4);
             }
         }
     }
@@ -1008,7 +1008,7 @@ static void vampirism(troop at, int damage)
         if (gain > 0) {
             int maxhp = unit_max_hp(at.fighter->unit);
             at.fighter->person[at.index].hp =
-                _min(gain + at.fighter->person[at.index].hp, maxhp);
+                MIN(gain + at.fighter->person[at.index].hp, maxhp);
         }
     }
 }
@@ -1203,15 +1203,15 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile)
 
     /* TODO not sure if res could be > 1 here */
     if (magic) {
-        da = (int)(_max(da * res, 0));
+        da = (int)(MAX(da * res, 0));
     }
 
     if (type != AT_COMBATSPELL && type != AT_SPELL) {
         if (rule_damage & DAMAGE_CRITICAL) {
             double kritchance = (sk * 3 - sd) / 200.0;
 
-            kritchance = _max(kritchance, 0.005);
-            kritchance = _min(0.9, kritchance);
+            kritchance = MAX(kritchance, 0.005);
+            kritchance = MIN(0.9, kritchance);
 
             while (chance(kritchance)) {
                 if (bdebug) {
@@ -1238,11 +1238,11 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile)
 
         /* Skilldifferenzbonus */
         if (rule_damage & DAMAGE_SKILL_BONUS) {
-            da += _max(0, (sk - sd) / DAMAGE_QUOTIENT);
+            da += MAX(0, (sk - sd) / DAMAGE_QUOTIENT);
         }
     }
 
-    rda = _max(da - ar, 0);
+    rda = MAX(da - ar, 0);
 
     if ((u_race(du)->battle_flags & BF_INV_NONMAGIC) && !magic)
         rda = 0;
@@ -1275,7 +1275,7 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile)
                 }
                 /* gibt R�stung +effect f�r duration Treffer */
                 if (me->typ == SHIELD_ARMOR) {
-                    rda = _max(rda - me->effect, 0);
+                    rda = MAX(rda - me->effect, 0);
                     me->duration--;
                 }
             }
@@ -1474,7 +1474,7 @@ troop select_enemy(fighter * af, int minrow, int maxrow, int select)
         minrow = FIGHT_ROW;
         maxrow = BEHIND_ROW;
     }
-    minrow = _max(minrow, FIGHT_ROW);
+    minrow = MAX(minrow, FIGHT_ROW);
 
     enemies = count_enemies(b, af, minrow, maxrow, select);
 
@@ -1574,7 +1574,7 @@ static troop select_opponent(battle * b, troop at, int mindist, int maxdist)
         dt = select_enemy(at.fighter, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE);
     }
     else {
-        mindist = _max(mindist, FIGHT_ROW);
+        mindist = MAX(mindist, FIGHT_ROW);
         dt = select_enemy(at.fighter, mindist, maxdist, SELECT_ADVANCE);
     }
 
@@ -1735,7 +1735,7 @@ void do_combatmagic(battle * b, combatmagic_t was)
 
                 level = eff_spelllevel(mage, sp, level, 1);
                 if (sl > 0)
-                    level = _min(sl, level);
+                    level = MIN(sl, level);
                 if (level < 0) {
                     report_failed_spell(b, mage, sp);
                     free_order(ord);
@@ -1822,7 +1822,7 @@ static void do_combatspell(troop at)
 
     level = eff_spelllevel(caster, sp, fi->magic, 1);
     if ((sl = get_combatspelllevel(caster, 1)) > 0)
-        level = _min(level, sl);
+        level = MIN(level, sl);
 
     if (fumble(r, caster, sp, level)) {
         report_failed_spell(b, caster, sp);
@@ -2056,7 +2056,7 @@ void dazzle(battle * b, troop * td)
 
 void damage_building(battle * b, building * bldg, int damage_abs)
 {
-    bldg->size = _max(1, bldg->size - damage_abs);
+    bldg->size = MAX(1, bldg->size - damage_abs);
 
     /* Wenn Burg, dann gucken, ob die Leute alle noch in das Geb�ude passen. */
 
@@ -2332,7 +2332,7 @@ void do_regenerate(fighter * af)
     while (ta.index--) {
         struct person *p = af->person + ta.index;
         p->hp += effskill(au, SK_STAMINA, 0);
-        p->hp = _min(unit_max_hp(au), p->hp);
+        p->hp = MIN(unit_max_hp(au), p->hp);
     }
 }
 
@@ -2391,10 +2391,10 @@ double fleechance(unit * u)
 
     if (u_race(u) == get_race(RC_HALFLING)) {
         c += 0.20;
-        c = _min(c, 0.90);
+        c = MIN(c, 0.90);
     }
     else {
-        c = _min(c, 0.75);
+        c = MIN(c, 0.75);
     }
 
     if (a != NULL)
@@ -2518,7 +2518,7 @@ static void loot_items(fighter * corpse)
         float lootfactor = (float)dead / (float)u->number; /* only loot the dead! */
         int maxloot = (int)((float)itm->number * lootfactor);
         if (maxloot > 0) {
-            int i = _min(10, maxloot);
+            int i = MIN(10, maxloot);
             for (; i != 0; --i) {
                 int loot = maxloot / i;
 
@@ -2599,7 +2599,7 @@ static void battle_effects(battle * b, int dead_players)
 {
     region *r = b->region;
     int dead_peasants =
-        _min(rpeasants(r), (int)(dead_players * PopulationDamage()));
+        MIN(rpeasants(r), (int)(dead_players * PopulationDamage()));
     if (dead_peasants) {
         deathcounts(r, dead_peasants + dead_players);
         add_chaoscount(r, dead_peasants / 2);
@@ -3092,7 +3092,7 @@ static void print_stats(battle * b)
 
     for (s = b->sides; s != b->sides + b->nsides; ++s) {
         if (!ql_empty(s->leader.fighters)) {
-            b->max_tactics = _max(b->max_tactics, s->leader.value);
+            b->max_tactics = MAX(b->max_tactics, s->leader.value);
         }
     }
 
@@ -3258,7 +3258,7 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
     /* change_effect wird in ageing gemacht */
 
     /* Effekte von Artefakten */
-    strongmen = _min(fig->unit->number, trollbelts(u));
+    strongmen = MIN(fig->unit->number, trollbelts(u));
 
     /* Hitpoints, Attack- und Defence-Boni f�r alle Personen */
     for (i = 0; i < fig->alive; i++) {
@@ -3448,7 +3448,7 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
                 else
                     p_bonus += 3;
             } while (rnd >= 97);
-            bonus = _max(p_bonus, bonus);
+            bonus = MAX(p_bonus, bonus);
         }
         tactics += bonus;
     }
@@ -3519,11 +3519,11 @@ static const char *simplename(region * r)
     const char *cp = rname(r, default_locale);
     for (i = 0; *cp && i != 16; ++i, ++cp) {
         int c = *(unsigned char *)cp;
-        while (c && !isalpha(c) && !isxspace(c)) {
+        while (c && !isalpha(c) && !isspace(c)) {
             ++cp;
             c = *(unsigned char *)cp;
         }
-        if (isxspace(c))
+        if (isspace(c))
             name[i] = '_';
         else
             name[i] = *cp;
@@ -3546,10 +3546,10 @@ battle *make_battle(region * r)
         bld->sizeleft = bld->size;
 
     if (battledebug) {
-        char zText[MAX_PATH];
-        char zFilename[MAX_PATH];
+        char zText[4096];
+        char zFilename[4096];
         join_path(basepath(), "battles", zText, sizeof(zText));
-        if (_mkdir(zText) != 0) {
+        if (mkdir(zText, 0777) != 0) {
             log_error("could not create subdirectory for battle logs: %s", zText);
             battledebug = false;
         }
@@ -4104,7 +4104,7 @@ static void battle_flee(battle * b)
                 troop dt;
                 int runners = 0;
                 /* Flucht nicht bei mehr als 600 HP. Damit Wyrme t�tbar bleiben. */
-                int runhp = _min(600, (int)(0.9 + unit_max_hp(u) * hpflee(u->status)));
+                int runhp = MIN(600, (int)(0.9 + unit_max_hp(u) * hpflee(u->status)));
 
                 if (u->ship && fval(u->region->terrain, SEA_REGION)) {
                     /* keine Flucht von Schiffen auf hoher See */
@@ -4147,7 +4147,7 @@ static void battle_flee(battle * b)
                     if (fig->person[dt.index].flags & FL_PANICED) {
                         ispaniced = EFFECT_PANIC_SPELL;
                     }
-                    if (chance(_min(fleechance(u) + ispaniced, 0.90))) {
+                    if (chance(MIN(fleechance(u) + ispaniced, 0.90))) {
                         ++runners;
                         flee(dt);
                     }
diff --git a/src/battle.h b/src/battle.h
index 007bda008..060906958 100644
--- a/src/battle.h
+++ b/src/battle.h
@@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #define H_KRNL_BATTLE
 
 #include <kernel/types.h>
+#include <stdbool.h>
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/src/bind_building.c b/src/bind_building.c
index 3724d4db5..f8cf4e6df 100644
--- a/src/bind_building.c
+++ b/src/bind_building.c
@@ -92,7 +92,7 @@ static int tolua_building_set_info(lua_State * L)
     const char *info = tolua_tostring(L, 2, 0);
     free(self->display);
     if (info)
-        self->display = _strdup(info);
+        self->display = strdup(info);
     else
         self->display = NULL;
     return 0;
diff --git a/src/bind_dict.c b/src/bind_dict.c
index 32d3c498d..40f73690f 100644
--- a/src/bind_dict.c
+++ b/src/bind_dict.c
@@ -106,7 +106,7 @@ static int tolua_dict_set_string(lua_State * L)
     attrib *a = a_find(*self, &at_dict);
     variant val;
 
-    val.v = _strdup(value);
+    val.v = strdup(value);
 
     for (; a && a->type == &at_dict; a = a->next) {
         if (strcmp(dict_name(a), name) == 0) {
diff --git a/src/bind_gmtool.c b/src/bind_gmtool.c
index 3c07bb3b7..e4ae939f9 100644
--- a/src/bind_gmtool.c
+++ b/src/bind_gmtool.c
@@ -133,14 +133,14 @@ static int tolua_selected_regions(lua_State * L)
 
 static int tolua_state_open(lua_State * L)
 {
-    unused_arg(L);
+    UNUSED_ARG(L);
     state_open();
     return 0;
 }
 
 static int tolua_state_close(lua_State * L)
 {
-    unused_arg(L);
+    UNUSED_ARG(L);
     state_close(current_state);
     return 0;
 }
@@ -188,7 +188,7 @@ static void lua_paint_info(struct window *wnd, const struct state *st)
                 break;
             else {
                 size_t len = end - str;
-                int bytes = _min((int)len, size);
+                int bytes = MIN((int)len, size);
                 mvwaddnstr(win, line++, 1, str, bytes);
                 wclrtoeol(win);
                 str = end + 1;
diff --git a/src/bind_monsters.c b/src/bind_monsters.c
index d7a3daab2..bd0ef39e3 100644
--- a/src/bind_monsters.c
+++ b/src/bind_monsters.c
@@ -74,7 +74,7 @@ static int fix_familiars(struct lua_State *L)
                     free(mage->spellbook);
                     mage->spellbook = 0;
 
-                    _snprintf(buffer, sizeof(buffer), "%s_familiar", u_race(u)->_name);
+                    snprintf(buffer, sizeof(buffer), "%s_familiar", u_race(u)->_name);
                     eq = get_equipment(buffer);
                     if (eq) {
                         equip_unit_mask(u, eq, EQUIP_SPELLS);
diff --git a/src/bind_region.c b/src/bind_region.c
index 1296e4a65..2e328dc96 100644
--- a/src/bind_region.c
+++ b/src/bind_region.c
@@ -615,7 +615,7 @@ static int tolua_plane_set_name(lua_State * L)
     const char *str = tolua_tostring(L, 2, 0);
     free(self->name);
     if (str)
-        self->name = _strdup(str);
+        self->name = strdup(str);
     else
         self->name = 0;
     return 0;
diff --git a/src/bind_ship.c b/src/bind_ship.c
index f1c1c412a..95006cf5f 100644
--- a/src/bind_ship.c
+++ b/src/bind_ship.c
@@ -94,7 +94,7 @@ static int tolua_ship_set_display(lua_State * L)
 {
     ship *self = (ship *)tolua_tousertype(L, 1, 0);
     free(self->display);
-    self->display = _strdup(tolua_tostring(L, 2, 0));
+    self->display = strdup(tolua_tostring(L, 2, 0));
     return 0;
 }
 
diff --git a/src/bind_storage.c b/src/bind_storage.c
index a81a3baeb..d2b66f03d 100644
--- a/src/bind_storage.c
+++ b/src/bind_storage.c
@@ -100,7 +100,7 @@ static int tolua_storage_tostring(lua_State * L)
 {
     gamedata *data = (gamedata *)tolua_tousertype(L, 1, 0);
     char name[64];
-    _snprintf(name, sizeof(name), "<gamedata %p ver=%d>", (void *)data, data->version);
+    snprintf(name, sizeof(name), "<gamedata %p ver=%d>", (void *)data, data->version);
     lua_pushstring(L, name);
     return 1;
 }
diff --git a/src/building_action.c b/src/building_action.c
index 5c533f4d0..f72af4412 100644
--- a/src/building_action.c
+++ b/src/building_action.c
@@ -93,7 +93,7 @@ lc_write(const struct attrib *a, const void *owner, struct storage *store)
     const char *fname = data->fname;
     const char *fparam = data->param;
 
-    unused_arg(owner);
+    UNUSED_ARG(owner);
     WRITE_TOK(store, fname);
     WRITE_TOK(store, fparam ? fparam : NULLSTRING);
 }
@@ -116,7 +116,7 @@ static int lc_read(struct attrib *a, void *owner, gamedata *data)
         b = 0;
     }
     else {
-        bd->fname = _strdup(name);
+        bd->fname = strdup(name);
     }
     READ_TOK(store, name, sizeof(name));
     if (strcmp(name, "tnnL") == 0) {
@@ -127,7 +127,7 @@ static int lc_read(struct attrib *a, void *owner, gamedata *data)
     if (strcmp(name, NULLSTRING) == 0)
         bd->param = 0;
     else {
-        bd->param = _strdup(name);
+        bd->param = strdup(name);
     }
     if (result == 0 && !b) {
         return AT_READ_FAIL;
@@ -146,8 +146,8 @@ void building_addaction(building * b, const char *fname, const char *param)
 {
     attrib *a = a_add(&b->attribs, a_new(&at_building_action));
     building_action *data = (building_action *)a->data.v;
-    data->fname = _strdup(fname);
+    data->fname = strdup(fname);
     if (param) {
-        data->param = _strdup(param);
+        data->param = strdup(param);
     }
 }
diff --git a/src/creport.c b/src/creport.c
index eeb2a1202..bd9c97ec6 100644
--- a/src/creport.c
+++ b/src/creport.c
@@ -125,7 +125,7 @@ static const char *translate(const char *key, const char *value)
         }
         else
             t = malloc(sizeof(translation));
-        t->key = _strdup(key);
+        t->key = strdup(key);
         t->value = value;
         t->next = translation_table[kk];
         translation_table[kk] = t;
@@ -361,7 +361,7 @@ static int cr_race(variant var, char *buffer, const void *userdata)
 static int cr_alliance(variant var, char *buffer, const void *userdata)
 {
     const alliance *al = (const alliance *)var.v;
-    unused_arg(userdata);
+    UNUSED_ARG(userdata);
     if (al != NULL) {
         sprintf(buffer, "%d", al->id);
     }
@@ -372,7 +372,7 @@ static int cr_skill(variant var, char *buffer, const void *userdata)
 {
     const faction *report = (const faction *)userdata;
     skill_t sk = (skill_t)var.i;
-    unused_arg(userdata);
+    UNUSED_ARG(userdata);
     if (sk != NOSKILL)
         sprintf(buffer, "\"%s\"",
         translate(mkname("skill", skillnames[sk]), skillname(sk,
@@ -385,7 +385,7 @@ static int cr_skill(variant var, char *buffer, const void *userdata)
 static int cr_order(variant var, char *buffer, const void *userdata)
 {
     order *ord = (order *)var.v;
-    unused_arg(userdata);
+    UNUSED_ARG(userdata);
     if (ord != NULL) {
         char cmd[ORDERSIZE];
         char *wp = buffer;
diff --git a/src/economy.c b/src/economy.c
index 01954ff54..7edbbcb12 100644
--- a/src/economy.c
+++ b/src/economy.c
@@ -337,11 +337,11 @@ static int do_recruiting(recruitment * recruits, int available)
             int number, dec;
             double multi = 2.0 * rc->recruit_multi;
 
-            number = _min(req->qty, (int)(get / multi));
+            number = MIN(req->qty, (int)(get / multi));
             if (rc->recruitcost) {
                 int afford = get_pooled(u, get_resourcetype(R_SILVER), GET_DEFAULT,
                     number * rc->recruitcost) / rc->recruitcost;
-                number = _min(number, afford);
+                number = MIN(number, afford);
             }
             if (u->number + number > UNIT_MAXSIZE) {
                 ADDMSG(&u->faction->msgs, msg_feedback(u, req->ord, "error_unit_size",
@@ -551,7 +551,7 @@ static void recruit(unit * u, struct order *ord, request ** recruitorders)
     if (recruitcost > 0) {
         int pooled =
             get_pooled(u, get_resourcetype(R_SILVER), GET_DEFAULT, recruitcost * n);
-        n = _min(n, pooled / recruitcost);
+        n = MIN(n, pooled / recruitcost);
     }
 
     u->wants = n;
@@ -990,12 +990,12 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want)
     rring = get_resourcetype(R_RING_OF_NIMBLEFINGER);
     if (rring) {
         int dm = i_get(u->items, rring->itype);
-        amount += skill * _min(u->number, dm) * (roqf_factor() - 1);
+        amount += skill * MIN(u->number, dm) * (roqf_factor() - 1);
     }
 
     /* Schaffenstrunk: */
     if ((dm = get_effect(u, oldpotiontype[P_DOMORE])) != 0) {
-        dm = _min(dm, u->number);
+        dm = MIN(dm, u->number);
         change_effect(u, oldpotiontype[P_DOMORE], -dm);
         amount += dm * skill;       /* dm Personen produzieren doppelt */
     }
@@ -1091,7 +1091,7 @@ leveled_allocation(const resource_type * rtype, region * r, allocation * alist)
                 }
             need = norders;
 
-            avail = _min(avail, norders);
+            avail = MIN(avail, norders);
             if (need > 0) {
                 int use = 0;
                 for (al = alist; al; al = al->next)
@@ -1106,7 +1106,7 @@ leveled_allocation(const resource_type * rtype, region * r, allocation * alist)
                             use += x;
                             norders -= want;
                             need -= x;
-                            al->get = _min(al->want, al->get + (int)(x / al->save));
+                            al->get = MIN(al->want, al->get + (int)(x / al->save));
                         }
                     }
                 if (use) {
@@ -1139,7 +1139,7 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist)
             avail = 0;
     }
 
-    avail = _min(avail, norders);
+    avail = MIN(avail, norders);
     for (al = alist; al; al = al->next) {
         if (avail > 0) {
             int want = required(al->want, al->save);
@@ -1149,7 +1149,7 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist)
                 ++x;
             avail -= x;
             norders -= want;
-            al->get = _min(al->want, (int)(x / al->save));
+            al->get = MIN(al->want, (int)(x / al->save));
             if (rdata->produce) {
                 int use = required(al->get, al->save);
                 if (use)
@@ -1625,7 +1625,7 @@ static void buy(unit * u, request ** buyorders, struct order *ord)
         k -= a->data.i;
     }
 
-    n = _min(n, k);
+    n = MIN(n, k);
 
     if (!n) {
         cmistake(u, ord, 102, MSG_COMMERCE);
@@ -1936,7 +1936,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord)
 
     /* Ein H�ndler kann nur 10 G�ter pro Talentpunkt verkaufen. */
 
-    n = _min(n, u->number * 10 * effskill(u, SK_TRADE, 0));
+    n = MIN(n, u->number * 10 * effskill(u, SK_TRADE, 0));
 
     if (!n) {
         cmistake(u, ord, 54, MSG_COMMERCE);
@@ -1966,11 +1966,11 @@ static bool sell(unit * u, request ** sellorders, struct order *ord)
             if (o->type.ltype == ltype && o->unit->faction == u->faction) {
                 int fpool =
                     o->qty - get_pooled(o->unit, itype->rtype, GET_RESERVE, INT_MAX);
-                available -= _max(0, fpool);
+                available -= MAX(0, fpool);
             }
         }
 
-        n = _min(n, available);
+        n = MIN(n, available);
 
         if (n <= 0) {
             cmistake(u, ord, 264, MSG_COMMERCE);
@@ -1995,7 +1995,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord)
             k -= a->data.i;
         }
 
-        n = _min(n, k);
+        n = MIN(n, k);
         assert(n >= 0);
         /* die Menge der verkauften G�ter merken */
         a->data.i += n;
@@ -2052,7 +2052,7 @@ static void expandstealing(region * r, request * stealorders)
             n = 10;
         }
         if (n > 0) {
-            n = _min(n, g_requests[j].unit->wants);
+            n = MIN(n, g_requests[j].unit->wants);
             use_pooled(u, rsilver, GET_ALL, n);
             g_requests[j].unit->n = n;
             change_money(g_requests[j].unit, n);
@@ -2106,8 +2106,8 @@ static void plant(unit * u, int raw)
         return;
     }
 
-    n = _min(skill * u->number, n);
-    n = _min(raw, n);
+    n = MIN(skill * u->number, n);
+    n = MIN(raw, n);
     /* F�r jedes Kraut Talent*10% Erfolgschance. */
     for (i = n; i > 0; i--) {
         if (rng_int() % 10 < skill)
@@ -2152,14 +2152,14 @@ static void planttrees(unit * u, int raw)
     }
 
     /* wenn eine Anzahl angegeben wurde, nur soviel verbrauchen */
-    raw = _min(raw, skill * u->number);
+    raw = MIN(raw, skill * u->number);
     n = get_pooled(u, rtype, GET_DEFAULT, raw);
     if (n == 0) {
         ADDMSG(&u->faction->msgs,
             msg_feedback(u, u->thisorder, "resource_missing", "missing", rtype));
         return;
     }
-    n = _min(raw, n);
+    n = MIN(raw, n);
 
     /* F�r jeden Samen Talent*10% Erfolgschance. */
     for (i = n; i > 0; i--) {
@@ -2209,7 +2209,7 @@ static void breedtrees(unit * u, int raw)
     }
 
     /* wenn eine Anzahl angegeben wurde, nur soviel verbrauchen */
-    raw = _min(skill * u->number, raw);
+    raw = MIN(skill * u->number, raw);
     n = get_pooled(u, rtype, GET_DEFAULT, raw);
     /* Samen pr�fen */
     if (n == 0) {
@@ -2217,7 +2217,7 @@ static void breedtrees(unit * u, int raw)
             msg_feedback(u, u->thisorder, "resource_missing", "missing", rtype));
         return;
     }
-    n = _min(raw, n);
+    n = MIN(raw, n);
 
     /* F�r jeden Samen Talent*5% Erfolgschance. */
     for (i = n; i > 0; i--) {
@@ -2259,7 +2259,7 @@ static void breedhorses(unit * u)
     }
     effsk = effskill(u, SK_HORSE_TRAINING, 0);
     n = u->number * effsk;
-    n = _min(n, horses);
+    n = MIN(n, horses);
 
     for (c = 0; c < n; c++) {
         if (rng_int() % 100 < effsk) {
@@ -2508,7 +2508,7 @@ static void steal_cmd(unit * u, struct order *ord, request ** stealorders)
         }
     }
 
-    i = _min(u->number, i_get(u->items, rring->itype));
+    i = MIN(u->number, i_get(u->items, rring->itype));
     if (i > 0) {
         n *= STEALINCOME * (u->number + i * (roqf_factor() - 1));
     }
@@ -2530,7 +2530,7 @@ static void steal_cmd(unit * u, struct order *ord, request ** stealorders)
 
     /* Nur soviel PRODUCEEXP wie auch tatsaechlich gemacht wurde */
 
-    produceexp(u, SK_STEALTH, _min(n, u->number));
+    produceexp(u, SK_STEALTH, MIN(n, u->number));
 }
 
 /* ------------------------------------------------------------- */
@@ -2554,7 +2554,7 @@ static void expandentertainment(region * r)
         entertaining -= o->qty;
 
         /* Nur soviel PRODUCEEXP wie auch tats�chlich gemacht wurde */
-        produceexp(u, SK_ENTERTAINMENT, _min(u->n, u->number));
+        produceexp(u, SK_ENTERTAINMENT, MIN(u->n, u->number));
         add_income(u, IC_ENTERTAIN, o->qty, u->n);
         fset(u, UFL_LONGACTION | UFL_NOTMOVING);
     }
@@ -2605,7 +2605,7 @@ void entertain_cmd(unit * u, struct order *ord)
 
     max_e = getuint();
     if (max_e != 0) {
-        u->wants = _min(u->wants, max_e);
+        u->wants = MIN(u->wants, max_e);
     }
     o = nextentertainer++;
     o->unit = u;
@@ -2665,7 +2665,7 @@ expandwork(region * r, request * work_begin, request * work_end, int maxwork)
         if (blessedharvest_ct) {
             int happy =
                 (int)curse_geteffect(get_curse(r->attribs, blessedharvest_ct));
-            happy = _min(happy, jobs);
+            happy = MIN(happy, jobs);
             earnings += happy;
         }
     }
@@ -2819,10 +2819,10 @@ void tax_cmd(unit * u, struct order *ord, request ** taxorders)
         max = INT_MAX;
     }
     if (!playerrace(u_race(u))) {
-        u->wants = _min(income(u), max);
+        u->wants = MIN(income(u), max);
     }
     else {
-        u->wants = _min(n * effskill(u, SK_TAXING, 0) * taxperlevel, max);
+        u->wants = MIN(n * effskill(u, SK_TAXING, 0) * taxperlevel, max);
     }
 
     u2 = is_guarded(r, u);
@@ -2893,12 +2893,12 @@ void loot_cmd(unit * u, struct order *ord, request ** lootorders)
         max = INT_MAX;
     }
     if (!playerrace(u_race(u))) {
-        u->wants = _min(income(u), max);
+        u->wants = MIN(income(u), max);
     }
     else {
         /* For player start with 20 Silver +10 every 5 level of close combat skill*/
-        int skbonus = (_max(effskill(u, SK_MELEE, 0), effskill(u, SK_SPEAR, 0)) * 2 / 10) + 2;
-        u->wants = _min(n * skbonus * 10, max);
+        int skbonus = (MAX(effskill(u, SK_MELEE, 0), effskill(u, SK_SPEAR, 0)) * 2 / 10) + 2;
+        u->wants = MIN(n * skbonus * 10, max);
     }
 
     o = (request *)calloc(1, sizeof(request));
diff --git a/src/give.c b/src/give.c
index 524a27017..4f8417bf2 100644
--- a/src/give.c
+++ b/src/give.c
@@ -156,7 +156,7 @@ struct order *ord)
 
     assert(itype != NULL);
     n = get_pooled(src, item2resource(itype), GET_SLACK | GET_POOLED_SLACK, want);
-    n = _min(want, n);
+    n = MIN(want, n);
     r = n;
     if (dest && src->faction != dest->faction
         && src->faction->age < GiveRestriction()) {
@@ -772,7 +772,7 @@ void give_cmd(unit * u, order * ord)
                 msg_feedback(u, ord, "race_noregroup", "race", u_race(u)));
             return;
         }
-        n = _min(u->number, n);
+        n = MIN(u->number, n);
         msg = u2 ? give_men(n, u, u2, ord) : disband_men(n, u, ord);
         if (msg) {
             ADDMSG(&u->faction->msgs, msg);
diff --git a/src/give.test.c b/src/give.test.c
index f2b0d60a9..b6c845450 100644
--- a/src/give.test.c
+++ b/src/give.test.c
@@ -244,7 +244,7 @@ static void test_give_men_requires_contact(CuTest * tc) {
     CuAssertIntEquals(tc, 1, env.dst->number);
     CuAssertIntEquals(tc, 1, env.src->number);
 
-    _snprintf(cmd, sizeof(cmd), "%s ALLES PERSONEN", itoa36(env.dst->no));
+    snprintf(cmd, sizeof(cmd), "%s ALLES PERSONEN", itoa36(env.dst->no));
     ord = create_order(K_GIVE, env.f1->locale, cmd);
     test_clear_messages(env.f1);
     give_cmd(env.src, ord);
@@ -316,7 +316,7 @@ static void test_give_cmd(CuTest * tc) {
 
     i_change(&env.src->items, env.itype, 10);
 
-    _snprintf(cmd, sizeof(cmd), "%s 5 %s", itoa36(env.dst->no), LOC(env.f1->locale, env.itype->rtype->_name));
+    snprintf(cmd, sizeof(cmd), "%s 5 %s", itoa36(env.dst->no), LOC(env.f1->locale, env.itype->rtype->_name));
     ord = create_order(K_GIVE, env.f1->locale, cmd);
     assert(ord);
     give_cmd(env.src, ord);
@@ -338,7 +338,7 @@ static void test_give_herbs(CuTest * tc) {
     setup_give(&env);
     i_change(&env.src->items, env.itype, 10);
 
-    _snprintf(cmd, sizeof(cmd), "%s %s", itoa36(env.dst->no), LOC(env.f1->locale, parameters[P_HERBS]));
+    snprintf(cmd, sizeof(cmd), "%s %s", itoa36(env.dst->no), LOC(env.f1->locale, parameters[P_HERBS]));
     ord = create_order(K_GIVE, env.f1->locale, cmd);
     assert(ord);
 
diff --git a/src/gmtool.c b/src/gmtool.c
index 7aab2fea7..a8881abd9 100644
--- a/src/gmtool.c
+++ b/src/gmtool.c
@@ -427,7 +427,7 @@ static void paint_info_region(window * wnd, const state * st)
     int line = 0, maxline = getmaxy(win) - 2;
     map_region *mr = cursor_region(&st->display, &st->cursor);
 
-    unused_arg(st);
+    UNUSED_ARG(st);
     werase(win);
     wxborder(win);
     if (mr && mr->r) {
@@ -1398,7 +1398,7 @@ int
 curses_readline(struct lua_State *L, char *buffer, size_t size,
 const char *prompt)
 {
-    unused_arg(L);
+    UNUSED_ARG(L);
     askstring(hstatus, prompt, buffer, size);
     return buffer[0] != 0;
 }
diff --git a/src/guard.h b/src/guard.h
index 4fb6cbf56..101369f40 100644
--- a/src/guard.h
+++ b/src/guard.h
@@ -2,6 +2,9 @@
 
 #ifndef H_GUARD
 #define H_GUARD
+
+#include <stdbool.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/src/items.c b/src/items.c
index 6fbf957b3..6e995edaa 100644
--- a/src/items.c
+++ b/src/items.c
@@ -122,7 +122,7 @@ struct order *ord)
         double force;
         spell *sp = find_spell("antimagiczone");
         attrib **ap = &r->attribs;
-        unused_arg(ord);
+        UNUSED_ARG(ord);
         assert(sp);
 
         /* Reduziert die St�rke jedes Spruchs um effect */
diff --git a/src/items/artrewards.c b/src/items/artrewards.c
index 602841d23..23ab2119e 100644
--- a/src/items/artrewards.c
+++ b/src/items/artrewards.c
@@ -45,7 +45,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 static int age_peaceimmune(attrib * a, void *owner)
 {
-    unused_arg(owner);
+    UNUSED_ARG(owner);
     return (--a->data.i > 0) ? AT_AGE_KEEP : AT_AGE_REMOVE;
 }
 
diff --git a/src/items/demonseye.c b/src/items/demonseye.c
index ffc1c5179..563a16047 100644
--- a/src/items/demonseye.c
+++ b/src/items/demonseye.c
@@ -38,8 +38,8 @@ summon_igjarjuk(struct unit *u, const struct item_type *itype, int amount,
 struct order *ord)
 {
     struct plane *p = rplane(u->region);
-    unused_arg(amount);
-    unused_arg(itype);
+    UNUSED_ARG(amount);
+    UNUSED_ARG(itype);
     if (p != NULL) {
         ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "use_realworld_only", ""));
         return EUNUSABLE;
diff --git a/src/items/speedsail.c b/src/items/speedsail.c
index 8bdaa41ab..cb40e9a8c 100644
--- a/src/items/speedsail.c
+++ b/src/items/speedsail.c
@@ -42,8 +42,8 @@ use_speedsail(struct unit *u, const struct item_type *itype, int amount,
 struct order *ord)
 {
     struct plane *p = rplane(u->region);
-    unused_arg(amount);
-    unused_arg(itype);
+    UNUSED_ARG(amount);
+    UNUSED_ARG(itype);
     if (p != NULL) {
         ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "use_realworld_only", ""));
     }
diff --git a/src/items/weapons.c b/src/items/weapons.c
index 1806e61a0..a23110a81 100644
--- a/src/items/weapons.c
+++ b/src/items/weapons.c
@@ -106,7 +106,7 @@ int *casualties)
     }
 
     enemies = count_enemies(b, af, FIGHT_ROW, FIGHT_ROW, SELECT_ADVANCE);
-    enemies = _min(enemies, CATAPULT_ATTACKS);
+    enemies = MIN(enemies, CATAPULT_ATTACKS);
     if (enemies == 0) {
         return true;                /* allow further attacks */
     }
diff --git a/src/items/xerewards.c b/src/items/xerewards.c
index ab5226a32..a6d1ad2ea 100644
--- a/src/items/xerewards.c
+++ b/src/items/xerewards.c
@@ -72,7 +72,7 @@ struct order *ord)
     }
 
     for (i = 0; i != amount; ++i) {
-        sp += _max(25, max_spellpoints(u->region, u) / 2);
+        sp += MAX(25, max_spellpoints(u->region, u) / 2);
         change_spellpoints(u, sp);
     }
 
diff --git a/src/json.c b/src/json.c
index 10322fe3f..0a78a3fa9 100644
--- a/src/json.c
+++ b/src/json.c
@@ -73,7 +73,7 @@ int json_export(stream * out, int flags) {
         cJSON_AddItemToObject(root, "planes", json = cJSON_CreateObject());
         for (p = planes; p; p = p->next) {
             cJSON *data;
-            _snprintf(id, sizeof(id), "%d", p->id);
+            snprintf(id, sizeof(id), "%d", p->id);
             cJSON_AddItemToObject(json, id, data = cJSON_CreateObject());
             cJSON_AddNumberToObject(data, "x", p->minx);
             cJSON_AddNumberToObject(data, "y", p->miny);
@@ -85,7 +85,7 @@ int json_export(stream * out, int flags) {
         cJSON_AddItemToObject(root, "regions", json = cJSON_CreateObject());
         for (r = regions; r; r = r->next) {
             cJSON *data;
-            _snprintf(id, sizeof(id), "%d", r->uid);
+            snprintf(id, sizeof(id), "%d", r->uid);
             cJSON_AddItemToObject(json, id, data = cJSON_CreateObject());
             cJSON_AddNumberToObject(data, "x", r->x);
             cJSON_AddNumberToObject(data, "y", r->y);
diff --git a/src/kernel/alliance.c b/src/kernel/alliance.c
index 36d054323..b53c46dc7 100644
--- a/src/kernel/alliance.c
+++ b/src/kernel/alliance.c
@@ -82,7 +82,7 @@ alliance *new_alliance(int id, const char *name) {
     al = calloc(1, sizeof(alliance));
     al->id = id;
     if (name) {
-        al->name = _strdup(name);
+        al->name = strdup(name);
     }
     else {
         al->flags |= ALF_NON_ALLIED;
@@ -446,7 +446,7 @@ void alliance_setname(alliance * self, const char *name)
 {
     free(self->name);
     if (name)
-        self->name = _strdup(name);
+        self->name = strdup(name);
     else
         self->name = NULL;
 }
diff --git a/src/kernel/ally.c b/src/kernel/ally.c
index 5a5a5b1c3..759d556f4 100644
--- a/src/kernel/ally.c
+++ b/src/kernel/ally.c
@@ -76,7 +76,7 @@ int AllianceAuto(void)
     const char *str = config_get("alliance.auto");
     value = 0;
     if (str != NULL) {
-        char *sstr = _strdup(str);
+        char *sstr = strdup(str);
         char *tok = strtok(sstr, " ");
         while (tok) {
             value |= ally_flag(tok, -1);
@@ -136,7 +136,7 @@ int HelpMask(void)
     if (config_changed(&config)) {
         const char *str = config_get("rules.help.mask");
         if (str != NULL) {
-            char *sstr = _strdup(str);
+            char *sstr = strdup(str);
             char *tok = strtok(sstr, " ");
             while (tok) {
                 rule |= ally_flag(tok, -1);
@@ -156,7 +156,7 @@ static int AllianceRestricted(void)
     const char *str = config_get("alliance.restricted");
     int rule = 0;
     if (str != NULL) {
-        char *sstr = _strdup(str);
+        char *sstr = strdup(str);
         char *tok = strtok(sstr, " ");
         while (tok) {
             rule |= ally_flag(tok, -1);
diff --git a/src/kernel/build.c b/src/kernel/build.c
index b5a1b3417..dff51cf6c 100644
--- a/src/kernel/build.c
+++ b/src/kernel/build.c
@@ -123,11 +123,11 @@ static void destroy_road(unit * u, int nmax, struct order *ord)
         }
 
         road = rroad(r, d);
-        n = _min(n, road);
+        n = MIN(n, road);
         if (n != 0) {
             region *r2 = rconnect(r, d);
             int willdo = effskill(u, SK_ROAD_BUILDING, 0) * u->number;
-            willdo = _min(willdo, n);
+            willdo = MIN(willdo, n);
             if (willdo == 0) {
                 /* TODO: error message */
             }
@@ -327,7 +327,7 @@ void build_road(unit * u, int size, direction_t d)
     }
 
     if (size > 0)
-        left = _min(size, left);
+        left = MIN(size, left);
     /* baumaximum anhand der rohstoffe */
     if (u_race(u) == get_race(RC_STONEGOLEM)) {
         n = u->number * GOLEM_STONE;
@@ -339,7 +339,7 @@ void build_road(unit * u, int size, direction_t d)
             return;
         }
     }
-    left = _min(n, left);
+    left = MIN(n, left);
 
     /* n = maximum by skill. try to maximize it */
     n = u->number * effsk;
@@ -347,7 +347,7 @@ void build_road(unit * u, int size, direction_t d)
         const resource_type *ring = get_resourcetype(R_RING_OF_NIMBLEFINGER);
         item *itm = ring ? *i_find(&u->items, ring->itype) : 0;
         if (itm != NULL && itm->number > 0) {
-            int rings = _min(u->number, itm->number);
+            int rings = MIN(u->number, itm->number);
             n = n * ((roqf_factor() - 1) * rings + u->number) / u->number;
         }
     }
@@ -355,15 +355,15 @@ void build_road(unit * u, int size, direction_t d)
         int dm = get_effect(u, oldpotiontype[P_DOMORE]);
         if (dm != 0) {
             int todo = (left - n + effsk - 1) / effsk;
-            todo = _min(todo, u->number);
-            dm = _min(dm, todo);
+            todo = MIN(todo, u->number);
+            dm = MIN(dm, todo);
             change_effect(u, oldpotiontype[P_DOMORE], -dm);
             n += dm * effsk;
         }                           /* Auswirkung Schaffenstrunk */
     }
 
     /* make minimum of possible and available: */
-    n = _min(left, n);
+    n = MIN(left, n);
 
     /* n is now modified by several special effects, so we have to
      * minimize it again to make sure the road will not grow beyond
@@ -380,7 +380,7 @@ void build_road(unit * u, int size, direction_t d)
     else {
         use_pooled(u, get_resourcetype(R_STONE), GET_DEFAULT, n);
         /* Nur soviel PRODUCEEXP wie auch tatsaechlich gemacht wurde */
-        produceexp(u, SK_ROAD_BUILDING, _min(n, u->number));
+        produceexp(u, SK_ROAD_BUILDING, MIN(n, u->number));
     }
     ADDMSG(&u->faction->msgs, msg_message("buildroad",
         "region unit size", r, u, n));
@@ -486,7 +486,7 @@ int build(unit * u, const construction * ctype, int completed, int want)
 
         if (dm != 0) {
             /* Auswirkung Schaffenstrunk */
-            dm = _min(dm, u->number);
+            dm = MIN(dm, u->number);
             change_effect(u, oldpotiontype[P_DOMORE], -dm);
             skills += dm * effsk;
         }
@@ -545,7 +545,7 @@ int build(unit * u, const construction * ctype, int completed, int want)
             item *itm = ring ? *i_find(&u->items, ring->itype) : 0;
             int i = itm ? itm->number : 0;
             if (i > 0) {
-                int rings = _min(u->number, i);
+                int rings = MIN(u->number, i);
                 n = n * ((roqf_factor() - 1) * rings + u->number) / u->number;
             }
         }
@@ -553,7 +553,7 @@ int build(unit * u, const construction * ctype, int completed, int want)
         if (want < n) n = want;
 
         if (type->maxsize > 0) {
-            n = _min(type->maxsize - completed, n);
+            n = MIN(type->maxsize - completed, n);
             if (type->improvement == NULL) {
                 want = n;
             }
@@ -626,7 +626,7 @@ int build(unit * u, const construction * ctype, int completed, int want)
         completed = completed + n;
     }
     /* Nur soviel PRODUCEEXP wie auch tatsaechlich gemacht wurde */
-    produceexp(u, ctype->skill, _min(made, u->number));
+    produceexp(u, ctype->skill, MIN(made, u->number));
 
     return made;
 }
@@ -671,7 +671,7 @@ int maxbuild(const unit * u, const construction * cons)
             return 0;
         }
         else
-            maximum = _min(maximum, have / need);
+            maximum = MIN(maximum, have / need);
     }
     return maximum;
 }
@@ -879,7 +879,7 @@ static void build_ship(unit * u, ship * sh, int want)
     }
 
     if (sh->damage && can) {
-        int repair = _min(sh->damage, can * DAMAGE_SCALE);
+        int repair = MIN(sh->damage, can * DAMAGE_SCALE);
         n += repair / DAMAGE_SCALE;
         if (repair % DAMAGE_SCALE)
             ++n;
@@ -923,7 +923,7 @@ order * ord)
         return;
     }
     if (want > 0)
-        want = _min(want, msize);
+        want = MIN(want, msize);
     else
         want = msize;
 
@@ -982,7 +982,7 @@ void continue_ship(unit * u, int want)
         return;
     }
     if (want > 0)
-        want = _min(want, msize);
+        want = MIN(want, msize);
     else
         want = msize;
 
diff --git a/src/kernel/building.c b/src/kernel/building.c
index 8d76df030..fa7fe8688 100644
--- a/src/kernel/building.c
+++ b/src/kernel/building.c
@@ -127,7 +127,7 @@ building_type *bt_get_or_create(const char *name)
         building_type *btype = bt_find_i(name);
         if (btype == NULL) {
             btype = calloc(sizeof(building_type), 1);
-            btype->_name = _strdup(name);
+            btype->_name = strdup(name);
             btype->auraregen = 1.0;
             btype->maxsize = -1;
             btype->capacity = 1;
@@ -143,7 +143,7 @@ int buildingcapacity(const building * b)
 {
     if (b->type->capacity >= 0) {
         if (b->type->maxcapacity >= 0) {
-            return _min(b->type->maxcapacity, b->size * b->type->capacity);
+            return MIN(b->type->maxcapacity, b->size * b->type->capacity);
         }
         return b->size * b->type->capacity;
     }
@@ -420,7 +420,7 @@ building *new_building(const struct building_type * btype, region * r,
     }
     assert(bname);
     slprintf(buffer, sizeof(buffer), "%s %s", bname, itoa36(b->no));
-    b->name = _strdup(bname);
+    b->name = strdup(bname);
     return b;
 }
 
@@ -619,7 +619,7 @@ void building_setname(building * self, const char *name)
 {
     free(self->name);
     if (name)
-        self->name = _strdup(name);
+        self->name = strdup(name);
     else
         self->name = NULL;
 }
@@ -779,7 +779,7 @@ default_wage(const region * r, const faction * f, const race * rc, int in_turn)
         /* Godcurse: Income -10 */
         ctype = ct_find("godcursezone");
         if (ctype && curse_active(get_curse(r->attribs, ctype))) {
-            wage = _max(0, wage - 10);
+            wage = MAX(0, wage - 10);
         }
 
         /* Bei einer D�rre verdient man nur noch ein Viertel  */
diff --git a/src/kernel/building.h b/src/kernel/building.h
index 92b006b98..235c2d806 100644
--- a/src/kernel/building.h
+++ b/src/kernel/building.h
@@ -23,6 +23,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include <util/variant.h>
 
 #include <stddef.h>
+#include <stdbool.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/src/kernel/building.test.c b/src/kernel/building.test.c
index d15c82c8e..3b296a6fe 100644
--- a/src/kernel/building.test.c
+++ b/src/kernel/building.test.c
@@ -22,7 +22,7 @@ static void test_register_building(CuTest * tc)
     test_cleanup();
 
     btype = (building_type *)calloc(sizeof(building_type), 1);
-    btype->_name = _strdup("herp");
+    btype->_name = strdup("herp");
     CuAssertIntEquals(tc, true, bt_changed(&cache));
     CuAssertIntEquals(tc, false, bt_changed(&cache));
     bt_register(btype);
diff --git a/src/kernel/config.c b/src/kernel/config.c
index f33303ead..1f3cd92b2 100644
--- a/src/kernel/config.c
+++ b/src/kernel/config.c
@@ -92,6 +92,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include <limits.h>
 #include <time.h>
 #include <errno.h>
+#include <sys/stat.h>
 
 struct settings global = {
     "Eressea",                    /* gamename */
@@ -362,7 +363,7 @@ void init_locale(struct locale *lang)
             str = "gwyrrd illaun draig cerddor tybied";
         }
 
-        sstr = _strdup(str);
+        sstr = strdup(str);
         tok = strtok(sstr, " ");
         while (tok) {
             const char *name;
@@ -473,7 +474,7 @@ int check_param(const struct param *p, const char *key, const char *searchvalue)
     if (!value) {
         return 0;
     }
-    char *p_value = _strdup(value);
+    char *p_value = strdup(value);
     const char *delimiter = " ,;";
     char *v = strtok(p_value, delimiter);
 
@@ -536,7 +537,7 @@ static const char * relpath(char *buf, size_t sz, const char *path) {
 static const char *g_datadir;
 const char *datapath(void)
 {
-    static char zText[MAX_PATH];
+    static char zText[4096];
     if (g_datadir)
         return g_datadir;
     return relpath(zText, sizeof(zText), "data");
@@ -550,7 +551,7 @@ void set_datapath(const char *path)
 static const char *g_reportdir;
 const char *reportpath(void)
 {
-    static char zText[MAX_PATH];
+    static char zText[4096];
     if (g_reportdir)
         return g_reportdir;
     return relpath(zText, sizeof(zText), "reports");
@@ -563,12 +564,12 @@ void set_reportpath(const char *path)
 
 int create_directories(void) {
     int err;
-    err = _mkdir(datapath());
+    err = mkdir(datapath(), 0777);
     if (err) {
         if (errno == EEXIST) errno = 0;
         else return err;
     }
-    err = _mkdir(reportpath());
+    err = mkdir(reportpath(), 0777);
     if (err && errno == EEXIST) {
         errno = 0;
     }
diff --git a/src/kernel/config.h b/src/kernel/config.h
index 91d5d576f..096d54da4 100644
--- a/src/kernel/config.h
+++ b/src/kernel/config.h
@@ -25,6 +25,7 @@ extern "C" {
 
     /* this should always be the first thing included after platform.h */
 #include <stddef.h>
+#include <stdbool.h>
 #include "types.h"
 struct param;
 
diff --git a/src/kernel/connection.c b/src/kernel/connection.c
index 6eccf1f0c..405b013ee 100644
--- a/src/kernel/connection.c
+++ b/src/kernel/connection.c
@@ -131,7 +131,7 @@ static connection **get_borders_i(const region * r1, const region * r2)
     int key = reg_hashkey(r1);
     int k2 = reg_hashkey(r2);
 
-    key = _min(k2, key) % BORDER_MAXHASH;
+    key = MIN(k2, key) % BORDER_MAXHASH;
     bp = &borders[key];
     while (*bp) {
         connection *b = *bp;
@@ -258,31 +258,31 @@ void b_write(const connection * b, storage * store)
 
 bool b_transparent(const connection * b, const struct faction *f)
 {
-    unused_arg(b);
-    unused_arg(f);
+    UNUSED_ARG(b);
+    UNUSED_ARG(f);
     return true;
 }
 
 bool b_opaque(const connection * b, const struct faction * f)
 {
-    unused_arg(b);
-    unused_arg(f);
+    UNUSED_ARG(b);
+    UNUSED_ARG(f);
     return false;
 }
 
 bool b_blockall(const connection * b, const unit * u, const region * r)
 {
-    unused_arg(u);
-    unused_arg(r);
-    unused_arg(b);
+    UNUSED_ARG(u);
+    UNUSED_ARG(r);
+    UNUSED_ARG(b);
     return true;
 }
 
 bool b_blocknone(const connection * b, const unit * u, const region * r)
 {
-    unused_arg(u);
-    unused_arg(r);
-    unused_arg(b);
+    UNUSED_ARG(u);
+    UNUSED_ARG(r);
+    UNUSED_ARG(b);
     return false;
 }
 
@@ -294,39 +294,39 @@ bool b_rvisible(const connection * b, const region * r)
 bool b_fvisible(const connection * b, const struct faction * f,
     const region * r)
 {
-    unused_arg(r);
-    unused_arg(f);
-    unused_arg(b);
+    UNUSED_ARG(r);
+    UNUSED_ARG(f);
+    UNUSED_ARG(b);
     return true;
 }
 
 bool b_uvisible(const connection * b, const unit * u)
 {
-    unused_arg(u);
-    unused_arg(b);
+    UNUSED_ARG(u);
+    UNUSED_ARG(b);
     return true;
 }
 
 bool b_rinvisible(const connection * b, const region * r)
 {
-    unused_arg(r);
-    unused_arg(b);
+    UNUSED_ARG(r);
+    UNUSED_ARG(b);
     return false;
 }
 
 bool b_finvisible(const connection * b, const struct faction * f,
     const region * r)
 {
-    unused_arg(r);
-    unused_arg(f);
-    unused_arg(b);
+    UNUSED_ARG(r);
+    UNUSED_ARG(f);
+    UNUSED_ARG(b);
     return false;
 }
 
 bool b_uinvisible(const connection * b, const unit * u)
 {
-    unused_arg(u);
-    unused_arg(b);
+    UNUSED_ARG(u);
+    UNUSED_ARG(b);
     return false;
 }
 
@@ -380,9 +380,9 @@ static const char *b_namewall(const connection * b, const region * r,
 {
     const char *bname = "wall";
 
-    unused_arg(f);
-    unused_arg(r);
-    unused_arg(b);
+    UNUSED_ARG(f);
+    UNUSED_ARG(r);
+    UNUSED_ARG(b);
     if (gflags & GF_ARTICLE)
         bname = "a_wall";
     if (gflags & GF_PURE)
@@ -421,9 +421,9 @@ border_type bt_noway = {
 static const char *b_namefogwall(const connection * b, const region * r,
     const struct faction *f, int gflags)
 {
-    unused_arg(f);
-    unused_arg(b);
-    unused_arg(r);
+    UNUSED_ARG(f);
+    UNUSED_ARG(b);
+    UNUSED_ARG(r);
     if (gflags & GF_PURE)
         return "fogwall";
     if (gflags & GF_ARTICLE)
@@ -434,7 +434,7 @@ static const char *b_namefogwall(const connection * b, const region * r,
 static bool
 b_blockfogwall(const connection * b, const unit * u, const region * r)
 {
-    unused_arg(b);
+    UNUSED_ARG(b);
     if (!u)
         return true;
     return (bool)(effskill(u, SK_PERCEPTION, r) > 4);    /* Das ist die alte Nebelwand */
@@ -459,8 +459,8 @@ static const char *b_nameillusionwall(const connection * b, const region * r,
     const struct faction *f, int gflags)
 {
     int fno = b->data.i;
-    unused_arg(b);
-    unused_arg(r);
+    UNUSED_ARG(b);
+    UNUSED_ARG(r);
     if (gflags & GF_PURE)
         return (f && fno == f->no) ? "illusionwall" : "wall";
     if (gflags & GF_ARTICLE) {
@@ -496,7 +496,7 @@ static const char *b_nameroad(const connection * b, const region * r,
     int local = (r == b->from) ? b->data.sa[0] : b->data.sa[1];
     static char buffer[64];
 
-    unused_arg(f);
+    UNUSED_ARG(f);
     if (gflags & GF_PURE)
         return "road";
     if (gflags & GF_ARTICLE) {
@@ -512,7 +512,7 @@ static const char *b_nameroad(const connection * b, const region * r,
             }
         }
         else {
-            int percent = _max(1, 100 * local / r->terrain->max_road);
+            int percent = MAX(1, 100 * local / r->terrain->max_road);
             if (local) {
                 slprintf(buffer, sizeof(buffer), LOC(f->locale, mkname("border",
                     "a_road_percent")), percent);
diff --git a/src/kernel/connection.h b/src/kernel/connection.h
index 7eef0f52a..80177c638 100644
--- a/src/kernel/connection.h
+++ b/src/kernel/connection.h
@@ -20,7 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #define H_KRNL_BORDER
 
 #include <util/variant.h>
-
+#include <stdbool.h>
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/src/kernel/curse.c b/src/kernel/curse.c
index 123f858f5..22b87e738 100644
--- a/src/kernel/curse.c
+++ b/src/kernel/curse.c
@@ -109,7 +109,7 @@ int curse_age(attrib * a, void *owner)
     curse *c = (curse *)a->data.v;
     int result = 0;
 
-    unused_arg(owner);
+    UNUSED_ARG(owner);
     c_clearflag(c, CURSE_ISNEW);
 
     if (c_flags(c) & CURSE_NOAGE) {
@@ -122,7 +122,7 @@ int curse_age(attrib * a, void *owner)
         c->duration = 0;
     }
     else if (c->duration != INT_MAX) {
-        c->duration = _max(0, c->duration - 1);
+        c->duration = MAX(0, c->duration - 1);
     }
     return (c->duration > 0) ? AT_AGE_KEEP : AT_AGE_REMOVE;
 }
@@ -348,7 +348,7 @@ const curse_type *ct_find(const char *c)
                 return type;
             }
             else {
-                size_t k = _min(c_len, strlen(type->cname));
+                size_t k = MIN(c_len, strlen(type->cname));
                 if (!memcmp(c, type->cname, k)) {
                     return type;
                 }
@@ -507,7 +507,7 @@ int get_cursedmen(unit * u, const curse * c)
         cursedmen = c->data.i;
     }
 
-    return _min(u->number, cursedmen);
+    return MIN(u->number, cursedmen);
 }
 
 /* setzt die Anzahl der betroffenen Personen auf cursedmen */
@@ -596,7 +596,7 @@ curse *create_curse(unit * magician, attrib ** ap, const curse_type * ct,
     /* es gibt schon eins diese Typs */
     if (c && ct->mergeflags != NO_MERGE) {
         if (ct->mergeflags & M_DURATION) {
-            c->duration = _max(c->duration, duration);
+            c->duration = MAX(c->duration, duration);
         }
         if (ct->mergeflags & M_SUMDURATION) {
             c->duration += duration;
@@ -605,10 +605,10 @@ curse *create_curse(unit * magician, attrib ** ap, const curse_type * ct,
             c->effect += effect;
         }
         if (ct->mergeflags & M_MAXEFFECT) {
-            c->effect = _max(c->effect, effect);
+            c->effect = MAX(c->effect, effect);
         }
         if (ct->mergeflags & M_VIGOUR) {
-            c->vigour = _max(vigour, c->vigour);
+            c->vigour = MAX(vigour, c->vigour);
         }
         if (ct->mergeflags & M_VIGOUR_ADD) {
             c->vigour = vigour + c->vigour;
@@ -792,9 +792,9 @@ message *cinfo_simple(const void *obj, objtype_t typ, const struct curse * c,
 {
     struct message *msg;
 
-    unused_arg(typ);
-    unused_arg(self);
-    unused_arg(obj);
+    UNUSED_ARG(typ);
+    UNUSED_ARG(self);
+    UNUSED_ARG(obj);
 
     msg = msg_message(mkname("curseinfo", c->type->cname), "id", c->no);
     if (msg == NULL) {
diff --git a/src/kernel/curse.h b/src/kernel/curse.h
index 29498f4d2..4cff4f9a1 100644
--- a/src/kernel/curse.h
+++ b/src/kernel/curse.h
@@ -22,6 +22,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include <util/variant.h>
 #include "objtypes.h"
 
+#include <stdbool.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/src/kernel/equipment.c b/src/kernel/equipment.c
index 8266ada9a..1587e7531 100644
--- a/src/kernel/equipment.c
+++ b/src/kernel/equipment.c
@@ -47,7 +47,7 @@ equipment *create_equipment(const char *eqname)
         int i = eq ? strcmp(eq->name, eqname) : 1;
         if (i > 0) {
             eq = (equipment *)calloc(1, sizeof(equipment));
-            eq->name = _strdup(eqname);
+            eq->name = strdup(eqname);
             eq->next = *eqp;
             memset(eq->skills, 0, sizeof(eq->skills));
             *eqp = eq;
@@ -78,7 +78,7 @@ void equipment_setskill(equipment * eq, skill_t sk, const char *value)
 {
     if (eq != NULL) {
         if (value != NULL) {
-            eq->skills[sk] = _strdup(value);
+            eq->skills[sk] = strdup(value);
         }
         else if (eq->skills[sk]) {
             free(eq->skills[sk]);
@@ -98,7 +98,7 @@ void equipment_addspell(equipment * eq, const char * name, int level)
         lazy_spell *ls = malloc(sizeof(lazy_spell));
         ls->sp = NULL;
         ls->level = level;
-        ls->name = _strdup(name);
+        ls->name = strdup(name);
         ql_push(&eq->spells, ls);
     }
 }
@@ -115,7 +115,7 @@ equipment_setitem(equipment * eq, const item_type * itype, const char *value)
             if (idata == NULL) {
                 idata = (itemdata *)malloc(sizeof(itemdata));
                 idata->itype = itype;
-                idata->value = _strdup(value);
+                idata->value = strdup(value);
                 idata->next = eq->items;
                 eq->items = idata;
             }
diff --git a/src/kernel/faction.c b/src/kernel/faction.c
index d332bf604..2c6d4d244 100755
--- a/src/kernel/faction.c
+++ b/src/kernel/faction.c
@@ -274,7 +274,7 @@ faction *addfaction(const char *email, const char *password,
     fhash(f);
 
     slprintf(buf, sizeof(buf), "%s %s", LOC(loc, "factiondefault"), itoa36(f->no));
-    f->name = _strdup(buf);
+    f->name = strdup(buf);
 
     if (!f->race) {
         log_warning("creating a faction that has no race", itoa36(f->no));
@@ -523,7 +523,7 @@ void faction_setname(faction * self, const char *name)
 {
     free(self->name);
     if (name)
-        self->name = _strdup(name);
+        self->name = strdup(name);
 }
 
 const char *faction_getemail(const faction * self)
@@ -535,7 +535,7 @@ void faction_setemail(faction * self, const char *email)
 {
     free(self->email);
     if (email)
-        self->email = _strdup(email);
+        self->email = strdup(email);
 }
 
 const char *faction_getbanner(const faction * self)
@@ -547,7 +547,7 @@ void faction_setbanner(faction * self, const char *banner)
 {
     free(self->banner);
     if (banner)
-        self->banner = _strdup(banner);
+        self->banner = strdup(banner);
 }
 
 void faction_setpassword(faction * f, const char *pwhash)
@@ -555,7 +555,7 @@ void faction_setpassword(faction * f, const char *pwhash)
     assert(pwhash);
     // && pwhash[0] == '$');
     free(f->_password);
-    f->_password = _strdup(pwhash);
+    f->_password = strdup(pwhash);
 }
 
 bool valid_race(const struct faction *f, const struct race *rc)
diff --git a/src/kernel/faction.h b/src/kernel/faction.h
index 82ae89ea4..de55ad1fe 100644
--- a/src/kernel/faction.h
+++ b/src/kernel/faction.h
@@ -22,6 +22,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "skill.h"
 #include "types.h"
 #include <modules/score.h>
+#include <stdbool.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/src/kernel/group.c b/src/kernel/group.c
index 8753531a3..06f2f9f49 100755
--- a/src/kernel/group.c
+++ b/src/kernel/group.c
@@ -57,8 +57,8 @@ group *new_group(faction * f, const char *name, int gid)
         gp = &(*gp)->next;
     *gp = g;
 
-    maxgid = _max(gid, maxgid);
-    g->name = _strdup(name);
+    maxgid = MAX(gid, maxgid);
+    g->name = strdup(name);
     g->gid = gid;
 
     g->nexthash = ghash[index];
diff --git a/src/kernel/item.c b/src/kernel/item.c
index 53fff79ab..441346be8 100644
--- a/src/kernel/item.c
+++ b/src/kernel/item.c
@@ -156,7 +156,7 @@ const char *resourcename(const resource_type * rtype, int flags)
         }
         if (flags & NMF_PLURAL) {
             static char name[64]; // FIXME: static return value
-            _snprintf(name, sizeof(name), "%s_p", rtype->_name);
+            snprintf(name, sizeof(name), "%s_p", rtype->_name);
             return name;
         }
         return rtype->_name;
@@ -186,7 +186,7 @@ resource_type *rt_get_or_create(const char *name) {
             perror("resource_type allocation failed");
         }
         else {
-            rtype->_name = _strdup(name);
+            rtype->_name = strdup(name);
             rt_register(rtype);
             return rt_find(name);
         }
@@ -282,8 +282,8 @@ weapon_type *new_weapontype(item_type * itype,
 
     wtype = calloc(sizeof(weapon_type), 1);
     if (damage) {
-        wtype->damage[0] = _strdup(damage[0]);
-        wtype->damage[1] = _strdup(damage[1]);
+        wtype->damage[0] = strdup(damage[0]);
+        wtype->damage[1] = strdup(damage[1]);
     }
     wtype->defmod = defmod;
     wtype->flags |= wflags;
@@ -342,7 +342,7 @@ void it_set_appearance(item_type *itype, const char *appearance) {
     assert(itype);
     assert(itype->rtype);
     if (appearance) {
-        itype->_appearance[0] = _strdup(appearance);
+        itype->_appearance[0] = strdup(appearance);
         itype->_appearance[1] = strcat(strcpy((char *)malloc(strlen((char *)appearance) + 3), (char *)appearance), "_p");
     } else {
         itype->_appearance[0] = 0;
@@ -676,9 +676,9 @@ struct order *ord)
     direction_t d;
     message *msg = msg_message("meow", "");
 
-    unused_arg(ord);
-    unused_arg(amount);
-    unused_arg(itype);
+    UNUSED_ARG(ord);
+    UNUSED_ARG(amount);
+    UNUSED_ARG(itype);
 
     add_message(&u->region->msgs, msg);
     for (d = 0; d < MAXDIRECTIONS; d++) {
@@ -717,7 +717,7 @@ struct order *ord)
         c = create_curse(u, &u->attribs, ct_find("skillmod"), power,
             duration, effect, u->number);
         c->data.i = SK_TACTICS;
-        unused_arg(ord);
+        UNUSED_ARG(ord);
     }
     use_pooled(u, itype->rtype, GET_DEFAULT, amount);
     ADDMSG(&u->faction->msgs, msg_message("use_tacticcrystal",
@@ -746,14 +746,14 @@ mod_elves_only(const unit * u, const region * r, skill_t sk, int value)
 {
     if (u_race(u) == get_race(RC_ELF))
         return value;
-    unused_arg(r);
+    UNUSED_ARG(r);
     return -118;
 }
 
 static int
 mod_dwarves_only(const unit * u, const region * r, skill_t sk, int value)
 {
-    unused_arg(r);
+    UNUSED_ARG(r);
     if (u_race(u) == get_race(RC_DWARF) || (u_race(u)->flags & RCF_IRONGOLEM)) {
         return value;
     }
@@ -764,7 +764,7 @@ static int heal(unit * user, int effect)
 {
     int req = unit_max_hp(user) * user->number - user->hp;
     if (req > 0) {
-        req = _min(req, effect);
+        req = MIN(req, effect);
         effect -= req;
         user->hp += req;
     }
diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c
index d12238566..509470406 100644
--- a/src/kernel/jsonconf.c
+++ b/src/kernel/jsonconf.c
@@ -224,7 +224,7 @@ static void json_terrain_production(cJSON *json, terrain_production *prod) {
         if (dst) {
             free(*dst);
             assert(child->type == cJSON_String);
-            *dst = _strdup(child->valuestring);
+            *dst = strdup(child->valuestring);
         }
     }
 }
@@ -453,7 +453,7 @@ static void json_race(cJSON *json, race *rc) {
         switch (child->type) {
         case cJSON_String:
             if (strcmp(child->string, "damage") == 0) {
-                rc->def_damage = _strdup(child->valuestring);
+                rc->def_damage = strdup(child->valuestring);
             }
             break;
         case cJSON_Number:
@@ -534,7 +534,7 @@ static void disable_feature(const char *str) {
         enable_keyword(k, false);
         return;
     }
-    _snprintf(name, sizeof(name), "%s.enabled", str);
+    snprintf(name, sizeof(name), "%s.enabled", str);
     log_info("disable feature %s\n", name);
     config_set(name, "0");
 }
@@ -594,7 +594,7 @@ static void json_spells(cJSON *json) {
                     sp->fumble = (fumble_f)get_function(item->valuestring);
                 }
                 else if (strcmp(item->string, "syntax") == 0) {
-                    sp->syntax = _strdup(item->valuestring);
+                    sp->syntax = strdup(item->valuestring);
                 }
             }
         }
@@ -796,10 +796,10 @@ static void json_settings(cJSON *json) {
         else {
             char value[32];
             if (child->type == cJSON_Number && child->valuedouble && child->valueint<child->valuedouble) {
-                _snprintf(value, sizeof(value), "%f", child->valuedouble);
+                snprintf(value, sizeof(value), "%f", child->valuedouble);
             }
             else {
-                _snprintf(value, sizeof(value), "%d", child->valueint);
+                snprintf(value, sizeof(value), "%d", child->valueint);
             }
             config_set(child->string, value);
         }
diff --git a/src/kernel/messages.c b/src/kernel/messages.c
index 566e9bdef..89278624f 100644
--- a/src/kernel/messages.c
+++ b/src/kernel/messages.c
@@ -212,7 +212,7 @@ caddmessage(region * r, faction * f, const char *s, msg_t mtype, int level)
 {
     message *m = NULL;
 
-    unused_arg(level);
+    UNUSED_ARG(level);
     switch (mtype) {
     case MSG_INCOME:
         assert(f);
@@ -275,7 +275,7 @@ message * msg_error(const unit * u, struct order *ord, int mno) {
 message * cmistake(const unit * u, struct order *ord, int mno, int mtype)
 {
     message * result;
-    unused_arg(mtype);
+    UNUSED_ARG(mtype);
     result = msg_error(u, ord, mno);
     ADDMSG(&u->faction->msgs, result);
     return result;
diff --git a/src/kernel/order.c b/src/kernel/order.c
index 3fd1dc92f..776190b67 100644
--- a/src/kernel/order.c
+++ b/src/kernel/order.c
@@ -405,7 +405,7 @@ order *parse_order(const char *s, const struct locale * lang)
             }
         }
         if (kwd != NOKEYWORD) {
-            while (isxspace(*(unsigned char *)sptr)) ++sptr;
+            while (isspace(*(unsigned char *)sptr)) ++sptr;
             s = sptr;
             return create_order_i(kwd, s, persistent, lang);
         }
diff --git a/src/kernel/plane.c b/src/kernel/plane.c
index 7e9650d13..0b2fdc0d3 100644
--- a/src/kernel/plane.c
+++ b/src/kernel/plane.c
@@ -234,7 +234,7 @@ plane *create_new_plane(int id, const char *name, int minx, int maxx, int miny,
     pl->next = NULL;
     pl->id = id;
     if (name)
-        pl->name = _strdup(name);
+        pl->name = strdup(name);
     pl->minx = minx;
     pl->maxx = maxx;
     pl->miny = miny;
diff --git a/src/kernel/pool.c b/src/kernel/pool.c
index 5609d211f..702f86e0f 100644
--- a/src/kernel/pool.c
+++ b/src/kernel/pool.c
@@ -168,7 +168,7 @@ int count)
         use = have;
     else if (rtype->itype && mode & (GET_SLACK | GET_RESERVE)) {
         int reserve = get_reservation(u, rtype->itype);
-        int slack = _max(0, have - reserve);
+        int slack = MAX(0, have - reserve);
         if (mode & GET_RESERVE)
             use = have - slack;
         else if (mode & GET_SLACK)
@@ -209,18 +209,18 @@ use_pooled(unit * u, const resource_type * rtype, unsigned int mode, int count)
     }
 
     if ((mode & GET_SLACK) && (mode & GET_RESERVE)) {
-        n = _min(use, have);
+        n = MIN(use, have);
     }
     else if (rtype->itype) {
         int reserve = get_reservation(u, rtype->itype);
-        int slack = _max(0, have - reserve);
+        int slack = MAX(0, have - reserve);
         if (mode & GET_RESERVE) {
             n = have - slack;
-            n = _min(use, n);
+            n = MIN(use, n);
             change_reservation(u, rtype->itype, -n);
         }
         else if (mode & GET_SLACK) {
-            n = _min(use, slack);
+            n = MIN(use, slack);
         }
     }
     if (n > 0) {
diff --git a/src/kernel/race.c b/src/kernel/race.c
index decc3b7bb..a78a9e340 100644
--- a/src/kernel/race.c
+++ b/src/kernel/race.c
@@ -241,7 +241,7 @@ race *rc_create(const char *zName)
         log_error("race '%s' has an invalid name. remove spaces\n", zName);
         assert(strchr(zName, ' ') == NULL);
     }
-    rc->_name = _strdup(zName);
+    rc->_name = strdup(zName);
     rc->precombatspell = NULL;
 
     rc->attack[0].type = AT_COMBATSPELL;
@@ -288,7 +288,7 @@ const char* rc_name(const race * rc, name_t n, char *name, size_t size) {
     default: assert(!"invalid name_t enum in rc_name_s");
     }
     if (postfix) {
-        _snprintf(name, size, "race::%s%s", rc->_name, postfix);
+        snprintf(name, size, "race::%s%s", rc->_name, postfix);
         return name;
     }
     return NULL;
diff --git a/src/kernel/region.c b/src/kernel/region.c
index d937f8b68..cade135c7 100644
--- a/src/kernel/region.c
+++ b/src/kernel/region.c
@@ -138,7 +138,7 @@ int region_maxworkers(const region *r)
 {
     int size = production(r);
     int treespace = (rtrees(r, 2) + rtrees(r, 1) / 2) * TREESIZE;
-    return _max(size - treespace, _min(size / 10, 200));
+    return MAX(size - treespace, MIN(size / 10, 200));
 }
 
 int deathcount(const region * r)
@@ -403,7 +403,7 @@ koor_distance_wrap_xy(int x1, int y1, int x2, int y2, int width, int height)
     int dx = x1 - x2;
     int dy = y1 - y2;
     int result, dist;
-    int mindist = _min(width, height) >> 1;
+    int mindist = MIN(width, height) >> 1;
 
     /* Bei negativem dy am Ursprung spiegeln, das veraendert
      * den Abstand nicht
@@ -426,13 +426,13 @@ koor_distance_wrap_xy(int x1, int y1, int x2, int y2, int width, int height)
         if (result <= mindist)
             return result;
     }
-    dist = _max(dx, height - dy);
+    dist = MAX(dx, height - dy);
     if (dist >= 0 && dist < result) {
         result = dist;
         if (result <= mindist)
             return result;
     }
-    dist = _max(width - dx, dy);
+    dist = MAX(width - dx, dy);
     if (dist >= 0 && dist < result)
         result = dist;
     return result;
@@ -1215,7 +1215,7 @@ void terraform_region(region * r, const terrain_type * terrain)
         if (!fval(r, RF_CHAOTIC)) {
             int peasants;
             peasants = (region_maxworkers(r) * (20 + dice_rand("6d10"))) / 100;
-            rsetpeasants(r, _max(100, peasants));
+            rsetpeasants(r, MAX(100, peasants));
             rsetmoney(r, rpeasants(r) * ((wage(r, NULL, NULL,
                 INT_MAX) + 1) + rng_int() % 5));
         }
@@ -1395,7 +1395,7 @@ faction *update_owners(region * r)
                     else if (f || new_owner->faction != region_get_last_owner(r)) {
                         alliance *al = region_get_alliance(r);
                         if (al && new_owner->faction->alliance == al) {
-                            int morale = _max(0, region_get_morale(r) - MORALE_TRANSFER);
+                            int morale = MAX(0, region_get_morale(r) - MORALE_TRANSFER);
                             region_set_morale(r, morale, turn);
                         }
                         else {
@@ -1418,7 +1418,7 @@ faction *update_owners(region * r)
 void region_setinfo(struct region *r, const char *info)
 {
     free(r->display);
-    r->display = info ? _strdup(info) : 0;
+    r->display = info ? strdup(info) : 0;
 }
 
 const char *region_getinfo(const region * r)
@@ -1430,7 +1430,7 @@ void region_setname(struct region *r, const char *name)
 {
     if (r->land) {
         free(r->land->name);
-        r->land->name = name ? _strdup(name) : 0;
+        r->land->name = name ? strdup(name) : 0;
     }
 }
 
diff --git a/src/kernel/region.h b/src/kernel/region.h
index fcc5f08b0..9fa1a2daa 100644
--- a/src/kernel/region.h
+++ b/src/kernel/region.h
@@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #define H_KRNL_REGION
 
 #include <stddef.h>
+#include <stdbool.h>
 #include "types.h"
 #include "direction.h"
 
diff --git a/src/kernel/resources.c b/src/kernel/resources.c
index e064150e6..e32c7ad55 100644
--- a/src/kernel/resources.c
+++ b/src/kernel/resources.c
@@ -111,7 +111,7 @@ static void terraform_default(struct rawmaterial *res, const region * r)
     res->amount = (int)(res->amount * modifier);  /* random adjustment, +/- 91% */
     if (res->amount < 1)
         res->amount = 1;
-    unused_arg(r);
+    UNUSED_ARG(r);
 }
 
 #ifdef RANDOM_CHANGE
@@ -205,7 +205,7 @@ struct rawmaterial_type *rmt_create(const struct resource_type *rtype,
     const char *name)
 {
     rawmaterial_type *rmtype = malloc(sizeof(rawmaterial_type));
-    rmtype->name = _strdup(name);
+    rmtype->name = strdup(name);
     rmtype->rtype = rtype;
     rmtype->terraform = terraform_default;
     rmtype->update = NULL;
diff --git a/src/kernel/save.c b/src/kernel/save.c
index 2f157af41..de6f8aac1 100644
--- a/src/kernel/save.c
+++ b/src/kernel/save.c
@@ -436,7 +436,7 @@ void read_planes(gamedata *data) {
         }
         pl->id = id;
         READ_STR(store, name, sizeof(name));
-        pl->name = _strdup(name);
+        pl->name = strdup(name);
         READ_INT(store, &pl->minx);
         READ_INT(store, &pl->maxx);
         READ_INT(store, &pl->miny);
@@ -668,7 +668,7 @@ unit *read_unit(struct gamedata *data)
     if (unicode_utf8_trim(obuf)!=0) {
 		log_warning("trim unit %s name to '%s'", itoa36(u->no), obuf);
 	}
-    u->_name = obuf[0] ? _strdup(obuf) : 0;
+    u->_name = obuf[0] ? strdup(obuf) : 0;
     if (lomem) {
         READ_STR(data->store, NULL, 0);
     }
@@ -677,7 +677,7 @@ unit *read_unit(struct gamedata *data)
 		if (unicode_utf8_trim(obuf)!=0) {
 			log_warning("trim unit %s info to '%s'", itoa36(u->no), obuf);
 		}
-        u->display = obuf[0] ? _strdup(obuf) : 0;
+        u->display = obuf[0] ? strdup(obuf) : 0;
     }
     READ_INT(data->store, &number);
     set_number(u, number);
@@ -933,7 +933,7 @@ static region *readregion(struct gamedata *data, int x, int y)
 		if (unicode_utf8_trim(name)!=0) {
 			log_warning("trim region %d name to '%s'", uid, name);
 		};
-        r->land->name = _strdup(name);
+        r->land->name = strdup(name);
     }
     if (r->land) {
         int i;
@@ -1034,7 +1034,7 @@ static region *readregion(struct gamedata *data, int x, int y)
         read_items(data->store, &r->land->items);
         if (data->version >= REGIONOWNER_VERSION) {
             READ_INT(data->store, &n);
-            region_set_morale(r, _max(0, (short)n), -1);
+            region_set_morale(r, MAX(0, (short)n), -1);
             read_owner(data, &r->land->ownership);
         }
     }
@@ -1192,7 +1192,7 @@ static char * getpasswd(int fno) {
                 assert(line[slen] == '\n');
                 line[slen] = 0;
                 fclose(F);
-                return _strdup(line + len + 1);
+                return strdup(line + len + 1);
             }
         }
         fclose(F);
@@ -1285,12 +1285,12 @@ faction *read_faction(struct gamedata * data)
 	if (unicode_utf8_trim(name)!=0) {
 		log_warning("trim faction %s name to '%s'", itoa36(f->no), name);
 	};
-    f->name = _strdup(name);
+    f->name = strdup(name);
     READ_STR(data->store, name, sizeof(name));
 	if (unicode_utf8_trim(name)!=0) {
 		log_warning("trim faction %s banner to '%s'", itoa36(f->no), name);
 	};
-    f->banner = _strdup(name);
+    f->banner = strdup(name);
 
     log_debug("   - Lese Partei %s (%s)", f->name, itoa36(f->no));
 
@@ -1528,7 +1528,7 @@ struct building *read_building(gamedata *data) {
     if (unicode_utf8_trim(name)!=0) {
 		log_warning("trim building %s name to '%s'", itoa36(b->no), name);
 	}
-    b->name = _strdup(name);
+    b->name = strdup(name);
     if (lomem) {
         READ_STR(store, NULL, 0);
     }
@@ -1537,7 +1537,7 @@ struct building *read_building(gamedata *data) {
         if (unicode_utf8_trim(name)!=0) {
             log_warning("trim building %s info to '%s'", itoa36(b->no), name);
         }
-        b->display = _strdup(name);
+        b->display = strdup(name);
     }
     READ_INT(store, &b->size);
     READ_STR(store, name, sizeof(name));
@@ -1581,7 +1581,7 @@ ship *read_ship(struct gamedata *data)
     if (unicode_utf8_trim(name)!=0) {
 		log_warning("trim ship %s name to '%s'", itoa36(sh->no), name);
 	}
-    sh->name = _strdup(name);
+    sh->name = strdup(name);
     if (lomem) {
         READ_STR(store, NULL, 0);
     }
@@ -1590,7 +1590,7 @@ ship *read_ship(struct gamedata *data)
         if (unicode_utf8_trim(name)!=0) {
             log_warning("trim ship %s info to '%s'", itoa36(sh->no), name);
         }
-        sh->display = _strdup(name);
+        sh->display = strdup(name);
     }
     READ_STR(store, name, sizeof(name));
     sh->type = st_find(name);
diff --git a/src/kernel/save.test.c b/src/kernel/save.test.c
index 6a2758a1d..c05ce4455 100644
--- a/src/kernel/save.test.c
+++ b/src/kernel/save.test.c
@@ -91,7 +91,7 @@ static void test_readwrite_faction(CuTest * tc)
     test_setup();
     f = test_create_faction(0);
     free(f->name);
-    f->name = _strdup("  Hodor  ");
+    f->name = strdup("  Hodor  ");
     CuAssertStrEquals(tc, "  Hodor  ", f->name);
     mstream_init(&data.strm);
     gamedata_init(&data, &store, RELEASE_VERSION);
@@ -120,7 +120,7 @@ static void test_readwrite_region(CuTest * tc)
     test_setup();
     r = test_create_region(0, 0, 0);
     free(r->land->name);
-    r->land->name = _strdup("  Hodor  ");
+    r->land->name = strdup("  Hodor  ");
     CuAssertStrEquals(tc, "  Hodor  ", r->land->name);
     mstream_init(&data.strm);
     gamedata_init(&data, &store, RELEASE_VERSION);
@@ -150,7 +150,7 @@ static void test_readwrite_building(CuTest * tc)
     r = test_create_region(0, 0, 0);
     b = test_create_building(r, 0);
     free(b->name);
-    b->name = _strdup("  Hodor  ");
+    b->name = strdup("  Hodor  ");
     CuAssertStrEquals(tc, "  Hodor  ", b->name);
     mstream_init(&data.strm);
     gamedata_init(&data, &store, RELEASE_VERSION);
@@ -183,7 +183,7 @@ static void test_readwrite_ship(CuTest * tc)
     r = test_create_region(0, 0, 0);
     sh = test_create_ship(r, 0);
     free(sh->name);
-    sh->name = _strdup("  Hodor  ");
+    sh->name = strdup("  Hodor  ");
     CuAssertStrEquals(tc, "  Hodor  ", sh->name);
     mstream_init(&data.strm);
     gamedata_init(&data, &store, RELEASE_VERSION);
diff --git a/src/kernel/ship.c b/src/kernel/ship.c
index 6898630ff..817d54970 100644
--- a/src/kernel/ship.c
+++ b/src/kernel/ship.c
@@ -109,7 +109,7 @@ ship_type *st_get_or_create(const char * name) {
     ship_type * st = st_find_i(name);
     if (!st) {
         st = (ship_type *)calloc(sizeof(ship_type), 1);
-        st->_name = _strdup(name);
+        st->_name = strdup(name);
         st->storm = 1.0;
         ql_push(&shiptypes, (void *)st);
     }
@@ -202,7 +202,7 @@ ship *new_ship(const ship_type * stype, region * r, const struct locale *lang)
     }
     assert(sname);
     slprintf(buffer, sizeof(buffer), "%s %s", sname, itoa36(sh->no));
-    sh->name = _strdup(buffer);
+    sh->name = strdup(buffer);
     shash(sh);
     if (r) {
         addlist(&r->ships, sh);
@@ -333,8 +333,8 @@ int shipspeed(const ship * sh, const unit * u)
         int crew = crew_skill(sh);
         int crew_bonus = (crew / sh->type->sumskill / 2) - 1;
         if (crew_bonus > 0) {
-            bonus = _min(bonus, crew_bonus);
-            bonus = _min(bonus, sh->type->range_max - sh->type->range);
+            bonus = MIN(bonus, crew_bonus);
+            bonus = MIN(bonus, sh->type->range_max - sh->type->range);
         }
         else {
             bonus = 0;
@@ -458,7 +458,7 @@ void write_ship_reference(const struct ship *sh, struct storage *store)
 void ship_setname(ship * self, const char *name)
 {
     free(self->name);
-    self->name = name ? _strdup(name) : 0;
+    self->name = name ? strdup(name) : 0;
 }
 
 const char *ship_getname(const ship * self)
diff --git a/src/kernel/spell.c b/src/kernel/spell.c
index 8e14ec2c0..3201a6677 100644
--- a/src/kernel/spell.c
+++ b/src/kernel/spell.c
@@ -78,7 +78,7 @@ spell * create_spell(const char * name, unsigned int id)
     len = cb_new_kv(name, len, &sp, sizeof(sp), buffer);
     if (cb_insert(&cb_spells, buffer, len) == CB_SUCCESS) {
         sp->id = id ? id : hashstring(name);
-        sp->sname = _strdup(name);
+        sp->sname = strdup(name);
         add_spell(&spells, sp);
         return sp;
     }
diff --git a/src/kernel/spellbook.c b/src/kernel/spellbook.c
index da8fcd563..13f8a04f7 100644
--- a/src/kernel/spellbook.c
+++ b/src/kernel/spellbook.c
@@ -16,7 +16,7 @@
 spellbook * create_spellbook(const char * name)
 {
     spellbook *result = (spellbook *)malloc(sizeof(spellbook));
-    result->name = name ? _strdup(name) : 0;
+    result->name = name ? strdup(name) : 0;
     result->spells = 0;
     return result;
 }
diff --git a/src/kernel/terrain.c b/src/kernel/terrain.c
index ac4a49fe9..ca72e3060 100644
--- a/src/kernel/terrain.c
+++ b/src/kernel/terrain.c
@@ -110,7 +110,7 @@ terrain_type * get_or_create_terrain(const char *name) {
     if (!terrain) {
         terrain = (terrain_type *)calloc(sizeof(terrain_type), 1);
         if (terrain) {
-            terrain->_name = _strdup(name);
+            terrain->_name = strdup(name);
             terrain->next = registered_terrains;
             registered_terrains = terrain;
             if (strcmp("plain", name) == 0) {
diff --git a/src/kernel/unit.c b/src/kernel/unit.c
index f06c4c252..29766d4ef 100644
--- a/src/kernel/unit.c
+++ b/src/kernel/unit.c
@@ -123,7 +123,7 @@ unit *findunitr(const region * r, int n)
 // TODO: deprecated, replace with findunit(n)
 unit *findunitg(int n, const region * hint)
 {
-    unused_arg(hint);
+    UNUSED_ARG(hint);
     /* Abfangen von Syntaxfehlern. */
     if (n <= 0)
         return NULL;
@@ -511,7 +511,7 @@ int a_readprivate(attrib * a, void *owner, gamedata *data)
     struct storage *store = data->store;
     char lbuf[DISPLAYSIZE];
     READ_STR(store, lbuf, sizeof(lbuf));
-    a->data.v = _strdup(lbuf);
+    a->data.v = strdup(lbuf);
     return (a->data.v) ? AT_READ_OK : AT_READ_FAIL;
 }
 
@@ -562,7 +562,7 @@ void usetprivate(unit * u, const char *str)
     if (a->data.v) {
         free(a->data.v);
     }
-    a->data.v = _strdup(str);
+    a->data.v = strdup(str);
 }
 
 /*********************/
@@ -809,8 +809,8 @@ void set_level(unit * u, skill_t sk, int value)
 static int leftship_age(struct attrib *a, void *owner)
 {
     /* must be aged, so it doesn't affect report generation (cansee) */
-    unused_arg(a);
-    unused_arg(owner);
+    UNUSED_ARG(a);
+    UNUSED_ARG(owner);
     return AT_AGE_REMOVE;         /* remove me */
 }
 
@@ -1390,7 +1390,7 @@ int invisible(const unit * target, const unit * viewer)
     else {
         int hidden = item_invis(target);
         if (hidden) {
-            hidden = _min(hidden, target->number);
+            hidden = MIN(hidden, target->number);
             if (viewer) {
                 const resource_type *rtype = get_resourcetype(R_AMULET_OF_TRUE_SEEING);
                 hidden -= i_get(viewer->items, rtype->itype);
@@ -1533,7 +1533,7 @@ unit *create_unit(region * r, faction * f, int number, const struct race *urace,
     u->hp = unit_max_hp(u) * number;
 
     if (dname) {
-        u->_name = _strdup(dname);
+        u->_name = strdup(dname);
     }
     else if (urace->generate_name || playerrace(urace)) {
         name_unit(u);
@@ -1640,7 +1640,7 @@ void unit_setname(unit * u, const char *name)
 {
     free(u->_name);
     if (name && name[0])
-        u->_name = _strdup(name);
+        u->_name = strdup(name);
     else
         u->_name = NULL;
 }
@@ -1654,7 +1654,7 @@ void unit_setinfo(unit * u, const char *info)
 {
     free(u->display);
     if (info)
-        u->display = _strdup(info);
+        u->display = strdup(info);
     else
         u->display = NULL;
 }
diff --git a/src/kernel/unit.test.c b/src/kernel/unit.test.c
index 752627144..f242dbb1c 100644
--- a/src/kernel/unit.test.c
+++ b/src/kernel/unit.test.c
@@ -146,7 +146,7 @@ static void test_unit_name(CuTest *tc) {
     test_create_world();
     u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0));
     unit_setname(u, "Hodor");
-    _snprintf(name, sizeof(name), "Hodor (%s)", itoa36(u->no));
+    snprintf(name, sizeof(name), "Hodor (%s)", itoa36(u->no));
     CuAssertStrEquals(tc, name, unitname(u));
     test_cleanup();
 }
@@ -164,12 +164,12 @@ static void test_unit_name_from_race(CuTest *tc) {
     locale_setstring(lang, rc_name_s(u->_race, NAME_SINGULAR), "Mensch");
     locale_setstring(lang, rc_name_s(u->_race, NAME_PLURAL), "Menschen");
 
-    _snprintf(name, sizeof(name), "Mensch (%s)", itoa36(u->no));
+    snprintf(name, sizeof(name), "Mensch (%s)", itoa36(u->no));
     CuAssertStrEquals(tc, name, unitname(u));
     CuAssertStrEquals(tc, "Mensch", unit_getname(u));
 
     u->number = 2;
-    _snprintf(name, sizeof(name), "Menschen (%s)", itoa36(u->no));
+    snprintf(name, sizeof(name), "Menschen (%s)", itoa36(u->no));
     CuAssertStrEquals(tc, name, unitname(u));
     CuAssertStrEquals(tc, "Menschen", unit_getname(u));
 
@@ -243,9 +243,9 @@ static void test_default_name(CuTest *tc) {
 }
 
 static int cb_skillmod(const unit *u, const region *r, skill_t sk, int level) {
-    unused_arg(u);
-    unused_arg(r);
-    unused_arg(sk);
+    UNUSED_ARG(u);
+    UNUSED_ARG(r);
+    UNUSED_ARG(sk);
     return level + 3;
 }
 
@@ -398,7 +398,7 @@ static void test_unit_description(CuTest *tc) {
     u = test_create_unit(test_create_faction(rc), test_create_region(0,0,0));
     CuAssertPtrEquals(tc, 0, u->display);
     CuAssertStrEquals(tc, 0, u_description(u, u->faction->locale));
-    u->display = _strdup("Hodor");
+    u->display = strdup("Hodor");
     CuAssertStrEquals(tc, "Hodor", u_description(u, NULL));
     CuAssertStrEquals(tc, "Hodor", u_description(u, u->faction->locale));
     test_cleanup();
diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c
index 640a28940..2f38cdab3 100644
--- a/src/kernel/xmlreader.c
+++ b/src/kernel/xmlreader.c
@@ -94,8 +94,8 @@ static xmlChar *xml_cleanup_string(xmlChar * str)
 
     while (*read) {
         /* eat leading whitespace */
-        if (*read && isxspace(*read)) {
-            while (*read && isxspace(*read)) {
+        if (*read && isspace(*read)) {
+            while (*read && isspace(*read)) {
                 ++read;
             }
             *write++ = ' ';
@@ -379,7 +379,7 @@ static int parse_calendar(xmlDocPtr doc)
             first_turn = xml_ivalue(calendar, "start", first_turn);
             if (propValue) {
                 free(agename);
-                agename = _strdup(mkname("calendar", (const char *)propValue));
+                agename = strdup(mkname("calendar", (const char *)propValue));
                 xmlFree(propValue);
             }
 
@@ -398,7 +398,7 @@ static int parse_calendar(xmlDocPtr doc)
                     xmlNodePtr week = nsetWeeks->nodeTab[i];
                     xmlChar *propValue = xmlGetProp(week, BAD_CAST "name");
                     if (propValue) {
-                        weeknames[i] = _strdup(mkname("calendar", (const char *)propValue));
+                        weeknames[i] = strdup(mkname("calendar", (const char *)propValue));
                         weeknames2[i] = malloc(strlen(weeknames[i]) + 3);
                         sprintf(weeknames2[i], "%s_d", weeknames[i]);
                         xmlFree(propValue);
@@ -421,7 +421,7 @@ static int parse_calendar(xmlDocPtr doc)
                     xmlChar *propValue = xmlGetProp(season, BAD_CAST "name");
                     if (propValue) {
                         seasonnames[i] =
-                            _strdup(mkname("calendar", (const char *)propValue));
+                            strdup(mkname("calendar", (const char *)propValue));
                         xmlFree(propValue);
                     }
                 }
@@ -451,7 +451,7 @@ static int parse_calendar(xmlDocPtr doc)
                             xmlFree(newyear);
                             newyear = NULL;
                         }
-                        monthnames[i] = _strdup(mkname("calendar", (const char *)propValue));
+                        monthnames[i] = strdup(mkname("calendar", (const char *)propValue));
                         xmlFree(propValue);
                     }
                     if (nsetSeasons) {
@@ -663,7 +663,7 @@ static weapon_type *xml_readweapon(xmlXPathContextPtr xpath, item_type * itype)
         xmlFree(propValue);
 
         propValue = xmlGetProp(node, BAD_CAST "value");
-        wtype->damage[pos] = _strdup((const char *)propValue); // TODO: this is a memory leak
+        wtype->damage[pos] = strdup((const char *)propValue); // TODO: this is a memory leak
         if (k == 0)
             wtype->damage[1 - pos] = wtype->damage[pos];
         xmlFree(propValue);
@@ -1426,13 +1426,13 @@ static int parse_spells(xmlDocPtr doc)
 
             propValue = xmlGetProp(node, BAD_CAST "parameters");
             if (propValue) {
-                sp->parameter = _strdup((const char *)propValue);
+                sp->parameter = strdup((const char *)propValue);
                 xmlFree(propValue);
             }
 
             propValue = xmlGetProp(node, BAD_CAST "syntax");
             if (propValue) {
-                sp->syntax = _strdup((const char *)propValue);
+                sp->syntax = strdup((const char *)propValue);
                 xmlFree(propValue);
             }
 #ifdef TODO /* no longer need it, spellbooks! */
@@ -1628,7 +1628,7 @@ static int parse_races(xmlDocPtr doc)
 
         propValue = xmlGetProp(node, BAD_CAST "damage");
         assert(propValue != NULL);
-        rc->def_damage = _strdup((const char *)propValue);
+        rc->def_damage = strdup((const char *)propValue);
         xmlFree(propValue);
 
         rc->magres = (float)xml_fvalue(node, "magres", rc->magres);
@@ -1869,7 +1869,7 @@ static int parse_races(xmlDocPtr doc)
 
             propValue = xmlGetProp(node, BAD_CAST "damage");
             if (propValue != NULL) {
-                attack->data.dice = _strdup((const char *)propValue);
+                attack->data.dice = strdup((const char *)propValue);
                 xmlFree(propValue);
             }
             else {
@@ -1932,7 +1932,7 @@ static int parse_messages(xmlDocPtr doc)
                     (const char *)propType);
                 xmlFree(propName);
                 xmlFree(propType);
-                argv[k] = _strdup(zBuffer);
+                argv[k] = strdup(zBuffer);
             }
             argv[result->nodesetval->nodeNr] = NULL;
         }
diff --git a/src/laws.c b/src/laws.c
index e0bae8e41..7baadcf29 100644
--- a/src/laws.c
+++ b/src/laws.c
@@ -209,7 +209,7 @@ static void live(region * r)
             }
             /* bestes Talent raussuchen */
             if (sb != NULL) {
-                int weeks = _min(effect, u->number);
+                int weeks = MIN(effect, u->number);
                 reduce_skill(u, sb, weeks);
                 ADDMSG(&u->faction->msgs, msg_message("dumbeffect",
                     "unit weeks skill", u, weeks, (skill_t)sb->id));
@@ -267,7 +267,7 @@ static void calculate_emigration(region * r)
             int max_emigration = MAX_EMIGRATION(rp2 - maxp2);
 
             if (max_emigration > 0) {
-                max_emigration = _min(max_emigration, max_immigrants);
+                max_emigration = MIN(max_emigration, max_immigrants);
                 r->land->newpeasants += max_emigration;
                 rc->land->newpeasants -= max_emigration;
                 max_immigrants -= max_emigration;
@@ -318,7 +318,7 @@ int peasant_luck_effect(int peasants, int luck, int maxp, double variance)
     double mean;
     if (luck == 0) return 0;
 
-    mean = peasant_luck_factor() * peasant_growth_factor() * _min(luck, peasants);
+    mean = peasant_luck_factor() * peasant_growth_factor() * MIN(luck, peasants);
     mean *= ((peasants / (double)maxp < .9) ? 1 : PEASANTFORCE);
 
     births = RAND_ROUND(normalvariate(mean, variance * mean));
@@ -357,7 +357,7 @@ static void peasants(region * r)
 
     /* Alle werden satt, oder halt soviele für die es auch Geld gibt */
 
-    satiated = _min(peasants, money / maintenance_cost(NULL));
+    satiated = MIN(peasants, money / maintenance_cost(NULL));
     rsetmoney(r, money - satiated * maintenance_cost(NULL));
 
     /* Von denjenigen, die nicht satt geworden sind, verhungert der
@@ -366,7 +366,7 @@ static void peasants(region * r)
 
      /* Es verhungert maximal die unterernährten Bevölkerung. */
 
-    n = _min(peasants - satiated, rpeasants(r));
+    n = MIN(peasants - satiated, rpeasants(r));
     dead += (int)(0.5 + n * PEASANT_STARVATION_CHANCE);
 
     if (dead > 0) {
@@ -447,7 +447,7 @@ static void horses(region * r)
 
     /* Logistisches Wachstum, Optimum bei halbem Maximalbesatz. */
     maxhorses = region_maxworkers(r) / 10;
-    maxhorses = _max(0, maxhorses);
+    maxhorses = MAX(0, maxhorses);
     horses = rhorses(r);
     if (horses > 0) {
         if (is_cursed(r->attribs, C_CURSED_BY_THE_GODS, 0)) {
@@ -481,7 +481,7 @@ static void horses(region * r)
         if (r2 && fval(r2->terrain, WALK_INTO)) {
             int pt = (rhorses(r) * HORSEMOVE) / 100;
             pt = (int)normalvariate(pt, pt / 4.0);
-            pt = _max(0, pt);
+            pt = MAX(0, pt);
             if (fval(r2, RF_MIGRATION))
                 rsethorses(r2, rhorses(r2) + pt);
             else {
@@ -594,7 +594,7 @@ growing_trees(region * r, const int current_season, const int last_weeks_season)
         a = a_find(r->attribs, &at_germs);
         if (a && last_weeks_season == SEASON_SPRING) {
             /* ungekeimte Samen bleiben erhalten, Sprößlinge wachsen */
-            sprout = _min(a->data.sa[1], rtrees(r, 1));
+            sprout = MIN(a->data.sa[1], rtrees(r, 1));
             /* aus dem gesamt Sprößlingepool abziehen */
             rsettrees(r, 1, rtrees(r, 1) - sprout);
             /* zu den Bäumen hinzufügen */
@@ -614,7 +614,7 @@ growing_trees(region * r, const int current_season, const int last_weeks_season)
 
         /* Grundchance 1.0% */
         /* Jeder Elf in der Region erhöht die Chance marginal */
-        elves = _min(elves, production(r) / 8);
+        elves = MIN(elves, production(r) / 8);
         if (elves) {
             seedchance += 1.0 - pow(0.99999, elves * RESOURCE_QUANTITY);
         }
@@ -680,7 +680,7 @@ growing_trees(region * r, const int current_season, const int last_weeks_season)
 
         /* Raubbau abfangen, es dürfen nie mehr Samen wachsen, als aktuell
          * in der Region sind */
-        seeds = _min(a->data.sa[0], rtrees(r, 0));
+        seeds = MIN(a->data.sa[0], rtrees(r, 0));
         sprout = 0;
 
         for (i = 0; i < seeds; i++) {
@@ -700,7 +700,7 @@ growing_trees(region * r, const int current_season, const int last_weeks_season)
          * der Region entfernt werden können, da Jungbäume in der gleichen
          * Runde nachwachsen, wir also nicht mehr zwischen diesjährigen und
          * 'alten' Jungbäumen unterscheiden könnten */
-        sprout = _min(a->data.sa[1], rtrees(r, 1));
+        sprout = MIN(a->data.sa[1], rtrees(r, 1));
         grownup_trees = 0;
 
         for (i = 0; i < sprout; i++) {
@@ -740,7 +740,7 @@ void immigration(void)
     for (r = regions; r; r = r->next) {
         if (r->land && r->land->newpeasants) {
             int rp = rpeasants(r) + r->land->newpeasants;
-            rsetpeasants(r, _max(0, rp));
+            rsetpeasants(r, MAX(0, rp));
         }
         /* Genereate some (0-6 depending on the income) peasants out of nothing */
         /* if less than 50 are in the region and there is space and no monster or demon units in the region */
@@ -843,7 +843,7 @@ void demographics(void)
                 calculate_emigration(r);
                 peasants(r);
                 if (r->age > 20) {
-                    double mwp = _max(region_maxworkers(r), 1);
+                    double mwp = MAX(region_maxworkers(r), 1);
                     double prob =
                         pow(rpeasants(r) / (mwp * wage(r, NULL, NULL, turn) * 0.13), 4.0)
                         * PLAGUE_CHANCE;
@@ -1280,7 +1280,7 @@ static void remove_idle_players(void)
     }
     log_info(" - beseitige Spieler, die sich nach der Anmeldung nicht gemeldet haben...");
 
-    age = calloc(_max(4, turn + 1), sizeof(int));
+    age = calloc(MAX(4, turn + 1), sizeof(int));
     for (fp = &factions; *fp;) {
         faction *f = *fp;
         if (!is_monsters(f)) {
@@ -1621,7 +1621,7 @@ int display_cmd(unit * u, struct order *ord)
 
         free(*s);
         if (s2) {
-            *s = _strdup(s2);
+            *s = strdup(s2);
             if (strlen(s2) >= DISPLAYSIZE) {
                 (*s)[DISPLAYSIZE] = 0;
             }
@@ -1665,7 +1665,7 @@ static int rename_cmd(unit * u, order * ord, char **s, const char *s2)
     unicode_utf8_trim(name);
 
     free(*s);
-    *s = _strdup(name);
+    *s = strdup(name);
     return 0;
 }
 
@@ -2154,7 +2154,7 @@ int banner_cmd(unit * u, struct order *ord)
     const char * s = getstrtoken();
 
     free(u->faction->banner);
-    u->faction->banner = s ? _strdup(s) : 0;
+    u->faction->banner = s ? strdup(s) : 0;
     add_message(&u->faction->msgs, msg_message("changebanner", "value",
         u->faction->banner));
 
@@ -2356,23 +2356,23 @@ static void display_race(unit * u, const race * rc)
         }
     }
     if (rc->battle_flags & BF_EQUIPMENT) {
-        if (wrptr(&bufp, &size, _snprintf(bufp, size, " %s", LOC(f->locale, "stat_equipment"))) != 0)
+        if (wrptr(&bufp, &size, snprintf(bufp, size, " %s", LOC(f->locale, "stat_equipment"))) != 0)
             WARN_STATIC_BUFFER();
     }
     if (rc->battle_flags & BF_RES_PIERCE) {
-        if (wrptr(&bufp, &size, _snprintf(bufp, size, " %s", LOC(f->locale, "stat_pierce"))) != 0)
+        if (wrptr(&bufp, &size, snprintf(bufp, size, " %s", LOC(f->locale, "stat_pierce"))) != 0)
             WARN_STATIC_BUFFER();
     }
     if (rc->battle_flags & BF_RES_CUT) {
-        if (wrptr(&bufp, &size, _snprintf(bufp, size, " %s", LOC(f->locale, "stat_cut"))) != 0)
+        if (wrptr(&bufp, &size, snprintf(bufp, size, " %s", LOC(f->locale, "stat_cut"))) != 0)
             WARN_STATIC_BUFFER();
     }
     if (rc->battle_flags & BF_RES_BASH) {
-        if (wrptr(&bufp, &size, _snprintf(bufp, size, " %s", LOC(f->locale, "stat_bash"))) != 0)
+        if (wrptr(&bufp, &size, snprintf(bufp, size, " %s", LOC(f->locale, "stat_bash"))) != 0)
             WARN_STATIC_BUFFER();
     }
 
-    if (wrptr(&bufp, &size, _snprintf(bufp, size, " %d %s", at_count, LOC(f->locale, (at_count == 1) ? "stat_attack" : "stat_attacks"))) != 0)
+    if (wrptr(&bufp, &size, snprintf(bufp, size, " %d %s", at_count, LOC(f->locale, (at_count == 1) ? "stat_attack" : "stat_attacks"))) != 0)
         WARN_STATIC_BUFFER();
 
     for (a = 0; a < RACE_ATTACKS; a++) {
@@ -2385,12 +2385,12 @@ static void display_race(unit * u, const race * rc)
             switch (rc->attack[a].type) {
             case AT_STANDARD:
                 bytes =
-                    (size_t)_snprintf(bufp, size, "%s (%s)",
+                    (size_t)snprintf(bufp, size, "%s (%s)",
                         LOC(f->locale, "attack_standard"), rc->def_damage);
                 break;
             case AT_NATURAL:
                 bytes =
-                    (size_t)_snprintf(bufp, size, "%s (%s)",
+                    (size_t)snprintf(bufp, size, "%s (%s)",
                         LOC(f->locale, "attack_natural"), rc->attack[a].data.dice);
                 break;
             case AT_SPELL:
@@ -2398,11 +2398,11 @@ static void display_race(unit * u, const race * rc)
             case AT_DRAIN_ST:
             case AT_DRAIN_EXP:
             case AT_DAZZLE:
-                bytes = (size_t)_snprintf(bufp, size, "%s", LOC(f->locale, "attack_magical"));
+                bytes = (size_t)snprintf(bufp, size, "%s", LOC(f->locale, "attack_magical"));
                 break;
             case AT_STRUCTURAL:
                 bytes =
-                    (size_t)_snprintf(bufp, size, "%s (%s)",
+                    (size_t)snprintf(bufp, size, "%s (%s)",
                         LOC(f->locale, "attack_structural"), rc->attack[a].data.dice);
                 break;
             default:
@@ -2670,7 +2670,7 @@ int combatspell_cmd(unit * u, struct order *ord)
     if (findparam(s, u->faction->locale) == P_LEVEL) {
         /* Merken, setzen kommt erst später */
         level = getint();
-        level = _max(0, level);
+        level = MAX(0, level);
         s = gettoken(token, sizeof(token));
     }
 
@@ -2903,14 +2903,14 @@ static void age_stonecircle(building *b) {
                 float effect = 100;
                 /* the mage reactivates the circle */
                 c = create_curse(mage, &rt->attribs, ct_astralblock,
-                    (float)_max(1, sk), _max(1, sk / 2), effect, 0);
+                    (float)MAX(1, sk), MAX(1, sk / 2), effect, 0);
                 ADDMSG(&r->msgs,
                     msg_message("astralshield_activate", "region unit", r, mage));
             }
             else {
                 int sk = effskill(mage, SK_MAGIC, 0);
-                c->duration = _max(c->duration, sk / 2);
-                c->vigour = _max(c->vigour, (float)sk);
+                c->duration = MAX(c->duration, sk / 2);
+                c->vigour = MAX(c->vigour, (float)sk);
             }
         }
     }
@@ -2955,12 +2955,12 @@ static void ageing(void)
             /* Goliathwasser */
             int i = get_effect(u, oldpotiontype[P_STRONG]);
             if (i > 0) {
-                change_effect(u, oldpotiontype[P_STRONG], -1 * _min(u->number, i));
+                change_effect(u, oldpotiontype[P_STRONG], -1 * MIN(u->number, i));
             }
             /* Berserkerblut */
             i = get_effect(u, oldpotiontype[P_BERSERK]);
             if (i > 0) {
-                change_effect(u, oldpotiontype[P_BERSERK], -1 * _min(u->number, i));
+                change_effect(u, oldpotiontype[P_BERSERK], -1 * MIN(u->number, i));
             }
 
             if (is_cursed(u->attribs, C_OLDRACE, 0)) {
@@ -3034,7 +3034,7 @@ static int maxunits(const faction * f)
     if (flimit == 0) {
         return alimit;
     }
-    return _min(alimit, flimit);
+    return MIN(alimit, flimit);
 }
 
 int checkunitnumber(const faction * f, int add)
@@ -3130,7 +3130,7 @@ void new_units(void)
 
                     s = gettoken(token, sizeof(token));
                     if (s && s[0]) {
-                        name = _strdup(s);
+                        name = strdup(s);
                     }
                     u2 = create_unit(r, u->faction, 0, u->faction->race, alias, name, u);
                     if (name != NULL)
@@ -3361,7 +3361,7 @@ void monthly_healing(void)
 
             p *= heal_factor(u);
             if (u->hp < umhp) {
-                double maxheal = _max(u->number, umhp / 20.0);
+                double maxheal = MAX(u->number, umhp / 20.0);
                 int addhp;
                 if (active_building(u, bt_find("inn"))) {
                     p *= 1.5;
@@ -3376,7 +3376,7 @@ void monthly_healing(void)
                     ++addhp;
 
                 /* Aufaddieren der geheilten HP. */
-                u->hp = _min(u->hp + addhp, umhp);
+                u->hp = MIN(u->hp + addhp, umhp);
 
                 /* soll man an negativer regeneration sterben können? */
                 assert(u->hp > 0);
@@ -3701,7 +3701,7 @@ int claim_cmd(unit * u, struct order *ord)
     if (itype) {
         item **iclaim = i_find(&u->faction->items, itype);
         if (iclaim && *iclaim) {
-            n = _min(n, (*iclaim)->number);
+            n = MIN(n, (*iclaim)->number);
             i_change(iclaim, itype, -n);
             i_change(&u->items, itype, n);
         }
@@ -3962,7 +3962,7 @@ int armedmen(const unit * u, bool siege_weapons)
                 if (n >= u->number)
                     break;
             }
-            n = _min(n, u->number);
+            n = MIN(n, u->number);
         }
     }
     return n;
@@ -3998,9 +3998,9 @@ int siege_cmd(unit * u, order * ord)
     rt_catapult = rt_find("catapult");
 
     d = i_get(u->items, rt_catapult->itype);
-    d = _min(u->number, d);
+    d = MIN(u->number, d);
     pooled = get_pooled(u, rt_catapultammo, GET_DEFAULT, d);
-    d = _min(pooled, d);
+    d = MIN(pooled, d);
     if (effskill(u, SK_CATAPULT, 0) >= 1) {
         katapultiere = d;
         d *= effskill(u, SK_CATAPULT, 0);
@@ -4027,11 +4027,11 @@ int siege_cmd(unit * u, order * ord)
      * einheiten wieder abgesucht werden muessen! */
 
     usetsiege(u, b);
-    b->besieged += _max(bewaffnete, katapultiere);
+    b->besieged += MAX(bewaffnete, katapultiere);
 
     /* definitiver schaden eingeschraenkt */
 
-    d = _min(d, b->size - 1);
+    d = MIN(d, b->size - 1);
 
     /* meldung, schaden anrichten */
     if (d && !curse_active(get_curse(b->attribs, magicwalls_ct))) {
@@ -4270,7 +4270,7 @@ void processorders(void)
 void update_subscriptions(void)
 {
     FILE *F;
-    char zText[MAX_PATH];
+    char zText[4096];
 
     join_path(basepath(), "subscriptions", zText, sizeof(zText));
     F = fopen(zText, "r");
diff --git a/src/laws.h b/src/laws.h
index 0adb010d2..f05c11ab4 100755
--- a/src/laws.h
+++ b/src/laws.h
@@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #define H_GC_LAWS
 
 #include <kernel/types.h>
+#include <stdbool.h>
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/src/laws.test.c b/src/laws.test.c
index 1bec0e6b4..b5471243a 100644
--- a/src/laws.test.c
+++ b/src/laws.test.c
@@ -531,7 +531,7 @@ static void test_pay_cmd_other_building(CuTest *tc) {
     config_set("rules.region_owner_pay_building", "lighthouse");
     update_owners(b->region);
 
-    _snprintf(cmd, sizeof(cmd), "NOT %s", itoa36(b->no));
+    snprintf(cmd, sizeof(cmd), "NOT %s", itoa36(b->no));
     ord = create_order(K_PAY, f->locale, cmd);
     assert(ord);
     CuAssertPtrEquals(tc, fix.u1, building_owner(b));
diff --git a/src/lighthouse.c b/src/lighthouse.c
index 09c9b7d11..d29d58b71 100644
--- a/src/lighthouse.c
+++ b/src/lighthouse.c
@@ -83,8 +83,8 @@ int lighthouse_range(const building * b, const faction * f)
                     }
                     else if (f == NULL || u->faction == f) {
                         int sk = effskill(u, SK_PERCEPTION, 0) / 3;
-                        d = _max(d, sk);
-                        d = _min(maxd, d);
+                        d = MAX(d, sk);
+                        d = MIN(maxd, d);
                         if (d == maxd)
                             break;
                     }
diff --git a/src/lighthouse.h b/src/lighthouse.h
index 3bf970bf1..f2974ddf1 100644
--- a/src/lighthouse.h
+++ b/src/lighthouse.h
@@ -19,6 +19,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #ifndef LIGHTHOUSE_H
 #define LIGHTHOUSE_H
 
+#include <stdbool.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/src/listbox.c b/src/listbox.c
index 332041454..057240fad 100644
--- a/src/listbox.c
+++ b/src/listbox.c
@@ -27,7 +27,7 @@ insert_selection(list_selection ** p_sel, list_selection * prev,
 const char *str, void *payload)
 {
     list_selection *sel = calloc(sizeof(list_selection), 1);
-    sel->str = _strdup(str);
+    sel->str = strdup(str);
     sel->data = payload;
     if (*p_sel) {
         list_selection *s;
diff --git a/src/magic.c b/src/magic.c
index 2299e6523..dc56ad5ff 100644
--- a/src/magic.c
+++ b/src/magic.c
@@ -118,7 +118,7 @@ static double MagicPower(double force)
     if (force > 0) {
         const char *str = config_get("magic.power");
         double value = str ? atof(str) : 1.0;
-        return _max(value * force, 1.0f);
+        return MAX(value * force, 1.0f);
     }
     return 0;
 }
@@ -146,7 +146,7 @@ static void
 a_writeicastle(const attrib * a, const void *owner, struct storage *store)
 {
     icastle_data *data = (icastle_data *)a->data.v;
-    unused_arg(owner);
+    UNUSED_ARG(owner);
     WRITE_TOK(store, data->type->_name);
     WRITE_INT(store, data->time);
 }
@@ -543,7 +543,7 @@ int get_combatspelllevel(const unit * u, int nr)
     assert(nr < MAXCOMBATSPELLS);
     if (m) {
         int level = effskill(u, SK_MAGIC, 0);
-        return _min(m->combatspells[nr].level, level);
+        return MIN(m->combatspells[nr].level, level);
     }
     return -1;
 }
@@ -679,7 +679,7 @@ int change_spellpoints(unit * u, int mp)
     }
 
     /* verhindere negative Magiepunkte */
-    sp = _max(m->spellpoints + mp, 0);
+    sp = MAX(m->spellpoints + mp, 0);
     m->spellpoints = sp;
 
     return sp;
@@ -739,7 +739,7 @@ int max_spellpoints(const region * r, const unit * u)
     if (n > 0) {
         msp = (msp * n) / 100;
     }
-    return _max((int)msp, 0);
+    return MAX((int)msp, 0);
 }
 
 int change_maxspellpoints(unit * u, int csp)
@@ -774,7 +774,7 @@ int countspells(unit * u, int step)
     count = m->spellcount + step;
 
     /* negative Werte abfangen. */
-    m->spellcount = _max(0, count);
+    m->spellcount = MAX(0, count);
 
     return m->spellcount;
 }
@@ -867,7 +867,7 @@ int eff_spelllevel(unit * u, const spell * sp, int cast_level, int range)
             }
             else if (sp->components[k].cost == SPC_LEVEL) {
                 costtyp = SPC_LEVEL;
-                cast_level = _min(cast_level, maxlevel);
+                cast_level = MIN(cast_level, maxlevel);
                 /* bei Typ Linear müssen die Kosten in Höhe der Stufe vorhanden
                  * sein, ansonsten schlägt der Spruch fehl */
             }
@@ -885,7 +885,7 @@ int eff_spelllevel(unit * u, const spell * sp, int cast_level, int range)
         if (sb) {
             spellbook_entry * sbe = spellbook_get(sb, sp);
             if (sbe) {
-                return _min(cast_level, sbe->level);
+                return MIN(cast_level, sbe->level);
             }
         }
         log_error("spell %s is not in the spellbook for %s\n", sp->sname, unitname(u));
@@ -1103,7 +1103,7 @@ spellpower(region * r, unit * u, const spell * sp, int cast_level, struct order
             }
         }
     }
-    return _max(force, 0);
+    return MAX(force, 0);
 }
 
 /* ------------------------------------------------------------- */
@@ -1278,8 +1278,8 @@ target_resists_magic(unit * magician, void *obj, int objtyp, int t_bonus)
         break;
     }
 
-    probability = _max(0.02, probability + t_bonus * 0.01);
-    probability = _min(0.98, probability);
+    probability = MAX(0.02, probability + t_bonus * 0.01);
+    probability = MIN(0.98, probability);
 
     /* gibt true, wenn die Zufallszahl kleiner als die chance ist und
      * false, wenn sie gleich oder größer ist, dh je größer die
@@ -1421,7 +1421,7 @@ static void do_fumble(castorder * co)
 
     case 2:
         /* temporary skill loss */
-        duration = _max(rng_int() % level / 2, 2);
+        duration = MAX(rng_int() % level / 2, 2);
         effect = level / -2.0;
         c = create_curse(u, &u->attribs, ct_find("skillmod"), level,
             duration, effect, 1);
@@ -1529,14 +1529,14 @@ void regenerate_aura(void)
                     reg_aura -= regen;
                     if (chance(reg_aura))
                         ++regen;
-                    regen = _max(1, regen);
-                    regen = _min((auramax - aura), regen);
+                    regen = MAX(1, regen);
+                    regen = MIN((auramax - aura), regen);
 
                     aura += regen;
                     ADDMSG(&u->faction->msgs, msg_message("regenaura",
                         "unit region amount", u, r, regen));
                 }
-                set_spellpoints(u, _min(aura, auramax));
+                set_spellpoints(u, MIN(aura, auramax));
             }
         }
     }
@@ -1853,7 +1853,7 @@ static int addparam_string(const char *const param[], spllprm ** spobjp)
 
     spobj->flag = 0;
     spobj->typ = SPP_STRING;
-    spobj->data.xs = _strdup(param[0]);
+    spobj->data.xs = strdup(param[0]);
     return 1;
 }
 
@@ -2428,7 +2428,7 @@ static int age_unit(attrib * a, void *owner)
 /* if unit is gone or dead, remove the attribute */
 {
     unit *u = (unit *)a->data.v;
-    unused_arg(owner);
+    UNUSED_ARG(owner);
     return (u != NULL && u->number > 0) ? AT_AGE_KEEP : AT_AGE_REMOVE;
 }
 
@@ -2567,7 +2567,7 @@ static castorder *cast_cmd(unit * u, order * ord)
     /* für Syntax ' STUFE x REGION y z ' */
     if (param == P_LEVEL) {
         int p = getint();
-        level = _min(p, level);
+        level = MIN(p, level);
         if (level < 1) {
             /* Fehler "Das macht wenig Sinn" */
             syntax_error(u, ord);
@@ -2597,7 +2597,7 @@ static castorder *cast_cmd(unit * u, order * ord)
      * hier nach REGION nochmal auf STUFE prüfen */
     if (param == P_LEVEL) {
         int p = getint();
-        level = _min(p, level);
+        level = MIN(p, level);
         if (level < 1) {
             /* Fehler "Das macht wenig Sinn" */
             syntax_error(u, ord);
@@ -2728,7 +2728,7 @@ static castorder *cast_cmd(unit * u, order * ord)
              * löschen, zaubern kann er noch */
             range *= 2;
             set_order(&caster->thisorder, NULL);
-            level = _min(level, effskill(caster, SK_MAGIC, 0) / 2);
+            level = MIN(level, effskill(caster, SK_MAGIC, 0) / 2);
         }
     }
     /* Weitere Argumente zusammenbasteln */
@@ -2751,7 +2751,7 @@ static castorder *cast_cmd(unit * u, order * ord)
                     break;
                 }
             }
-            params[p++] = _strdup(s);
+            params[p++] = strdup(s);
         }
         params[p] = 0;
         args =
diff --git a/src/magic.h b/src/magic.h
index 59ef92475..964783c32 100644
--- a/src/magic.h
+++ b/src/magic.h
@@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #define H_KRNL_MAGIC
 
 #include <kernel/types.h>
+#include <stdbool.h>
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/src/market.test.c b/src/market.test.c
index 43e070b5e..6f1d74b88 100644
--- a/src/market.test.c
+++ b/src/market.test.c
@@ -46,7 +46,7 @@ static void test_market_curse(CuTest * tc)
     config_set("rules.region_owners", "1");
 
     btype = (building_type *)calloc(1, sizeof(building_type));
-    btype->_name = _strdup("market");
+    btype->_name = strdup("market");
     bt_register(btype);
 
     terrain = get_terrain("plain");
diff --git a/src/modules/arena.c b/src/modules/arena.c
index a912d273a..fbc3f0673 100644
--- a/src/modules/arena.c
+++ b/src/modules/arena.c
@@ -99,9 +99,9 @@ order * ord)
     if (u->building != arena_tower(u->faction->magiegebiet) && leave_fail(u)) {
         return -1;
     }
-    unused_arg(amount);
-    unused_arg(ord);
-    unused_arg(itype);
+    UNUSED_ARG(amount);
+    UNUSED_ARG(ord);
+    UNUSED_ARG(itype);
     assert(!"not implemented");
     return 0;
 }
@@ -120,9 +120,9 @@ enter_arena(unit * u, const item_type * itype, int amount, order * ord)
     region *r = u->region;
     unit *u2;
     int fee = 2000;
-    unused_arg(ord);
-    unused_arg(amount);
-    unused_arg(itype);
+    UNUSED_ARG(ord);
+    UNUSED_ARG(amount);
+    UNUSED_ARG(itype);
     if (u->faction->score > fee * 5) {
         score_t score = u->faction->score / 5;
         if (score < INT_MAX) {
@@ -212,7 +212,7 @@ static int caldera_handle(trigger * t, void *data)
     else {
         log_error("could not perform caldera::handle()\n");
     }
-    unused_arg(data);
+    UNUSED_ARG(data);
     return 0;
 }
 
diff --git a/src/modules/autoseed.c b/src/modules/autoseed.c
index 5420406c0..54fd7411e 100644
--- a/src/modules/autoseed.c
+++ b/src/modules/autoseed.c
@@ -199,7 +199,7 @@ newfaction *read_newfactions(const char *filename)
             free(nf);
             continue;
         }
-        nf->password = _strdup(password);
+        nf->password = strdup(password);
         nf->race = rc_find(race);
         nf->subscription = subscription;
         if (alliances != NULL) {
@@ -962,8 +962,8 @@ int build_island_e3(newfaction ** players, int x, int y, int numfactions, int mi
                 q = region_quality(r, rn);
                 if (q >= MIN_QUALITY && nfactions < numfactions && *players) {
                     starting_region(players, r, rn);
-                    minq = _min(minq, q);
-                    maxq = _max(maxq, q);
+                    minq = MIN(minq, q);
+                    maxq = MAX(maxq, q);
                     ++nfactions;
                 }
             }
@@ -977,8 +977,8 @@ int build_island_e3(newfaction ** players, int x, int y, int numfactions, int mi
                 q = region_quality(r, rn);
                 if (q >= MIN_QUALITY * 4 / 3 && nfactions < numfactions && *players) {
                     starting_region(players, r, rn);
-                    minq = _min(minq, q);
-                    maxq = _max(maxq, q);
+                    minq = MIN(minq, q);
+                    maxq = MAX(maxq, q);
                     ++nfactions;
                 }
             }
diff --git a/src/modules/museum.c b/src/modules/museum.c
index e934a71a4..af37019d0 100644
--- a/src/modules/museum.c
+++ b/src/modules/museum.c
@@ -310,7 +310,7 @@ order * ord)
     unit *warden = findunit(atoi36("mwar"));
     int unit_cookie;
 
-    unused_arg(amount);
+    UNUSED_ARG(amount);
 
     /* Pr�fen ob in Eingangshalle */
     if (u->region->x != 9525 || u->region->y != 9525) {
@@ -365,7 +365,7 @@ order * ord)
     region *r = u->region;
     plane *pl = rplane(r);
 
-    unused_arg(amount);
+    UNUSED_ARG(amount);
 
     /* Pruefen ob in normaler Plane und nur eine Person */
     if (pl != get_homeplane()) {
@@ -417,8 +417,8 @@ static const char *b_namequestportal(const connection * b, const region * r,
 {
     const char *bname;
     int lock = b->data.i;
-    unused_arg(b);
-    unused_arg(r);
+    UNUSED_ARG(b);
+    UNUSED_ARG(r);
 
     if (gflags & GF_ARTICLE) {
         if (lock > 0) {
diff --git a/src/modules/score.c b/src/modules/score.c
index 8213b8985..0776d6507 100644
--- a/src/modules/score.c
+++ b/src/modules/score.c
@@ -67,7 +67,7 @@ void score(void)
     region *r;
     faction *fc;
     score_t allscores = 0;
-    char path[MAX_PATH];
+    char path[4096];
 
     for (fc = factions; fc; fc = fc->next)
         fc->score = 0;
diff --git a/src/monsters.c b/src/monsters.c
index db34bff2c..b613f48cc 100644
--- a/src/monsters.c
+++ b/src/monsters.c
@@ -100,7 +100,7 @@ static void reduce_weight(unit * u)
     int horses = get_resource(u, get_resourcetype(R_HORSE));
 
     if (horses > 0) {
-        horses = _min(horses, (u->number * 2));
+        horses = MIN(horses, (u->number * 2));
         change_resource(u, get_resourcetype(R_HORSE), -horses);
     }
 
@@ -129,7 +129,7 @@ static void reduce_weight(unit * u)
             if (itype->weight >= 10 && itype->rtype->wtype == 0
                 && itype->rtype->atype == 0) {
                 if (itype->capacity < itype->weight) {
-                    int reduce = _min(itm->number, -((capacity - weight) / itype->weight));
+                    int reduce = MIN(itm->number, -((capacity - weight) / itype->weight));
                     give_peasants(u, itm->type, reduce);
                     weight -= reduce * itype->weight;
                 }
@@ -144,7 +144,7 @@ static void reduce_weight(unit * u)
         const item_type *itype = itm->type;
         weight += itm->number * itype->weight;
         if (itype->capacity < itype->weight) {
-            int reduce = _min(itm->number, -((capacity - weight) / itype->weight));
+            int reduce = MIN(itm->number, -((capacity - weight) / itype->weight));
             give_peasants(u, itm->type, reduce);
             weight -= reduce * itype->weight;
         }
@@ -1027,7 +1027,7 @@ static void eaten_by_monster(unit * u)
     n = (int)(n * multi);
     if (n > 0) {
         n = lovar(n);
-        n = _min(rpeasants(u->region), n);
+        n = MIN(rpeasants(u->region), n);
 
         if (n > 0) {
             deathcounts(u->region, n);
@@ -1047,7 +1047,7 @@ static void absorbed_by_monster(unit * u)
 
     if (n > 0) {
         n = lovar(n);
-        n = _min(rpeasants(u->region), n);
+        n = MIN(rpeasants(u->region), n);
         if (n > 0) {
             rsetpeasants(u->region, rpeasants(u->region) - n);
             scale_number(u, u->number + n);
@@ -1062,7 +1062,7 @@ static int scareaway(region * r, int anzahl)
     int n, p, diff = 0, emigrants[MAXDIRECTIONS];
     direction_t d;
 
-    anzahl = _min(_max(1, anzahl), rpeasants(r));
+    anzahl = MIN(MAX(1, anzahl), rpeasants(r));
 
     /* Wandern am Ende der Woche (normal) oder wegen Monster. Die
      * Wanderung wird erst am Ende von demographics () ausgefuehrt.
@@ -1074,7 +1074,7 @@ static int scareaway(region * r, int anzahl)
 
     p = rpeasants(r);
     assert(p >= 0 && anzahl >= 0);
-    for (n = _min(p, anzahl); n; n--) {
+    for (n = MIN(p, anzahl); n; n--) {
         direction_t dir = (direction_t)(rng_int() % MAXDIRECTIONS);
         region *rc = rconnect(r, dir);
 
@@ -1102,7 +1102,7 @@ static void scared_by_monster(unit * u)
     }
     if (n > 0) {
         n = lovar(n);
-        n = _min(rpeasants(u->region), n);
+        n = MIN(rpeasants(u->region), n);
         if (n > 0) {
             n = scareaway(u->region, n);
             if (n > 0) {
diff --git a/src/morale.c b/src/morale.c
index 8dc22ccb5..1bdf2363d 100644
--- a/src/morale.c
+++ b/src/morale.c
@@ -73,7 +73,7 @@ void morale_update(region *r) {
 void morale_change(region *r, int value) {
     int morale = region_get_morale(r);
     if (morale > 0) {
-        morale = _max(0, morale - value);
+        morale = MAX(0, morale - value);
         region_set_morale(r, morale, turn);
     }
 }
diff --git a/src/move.c b/src/move.c
index 126557d58..62300beb1 100644
--- a/src/move.c
+++ b/src/move.c
@@ -151,8 +151,8 @@ static void shiptrail_finalize(attrib * a)
 static int shiptrail_age(attrib * a, void *owner)
 {
     traveldir *t = (traveldir *)(a->data.v);
-    unused_arg(owner);
 
+    (void)owner;
     t->age--;
     return (t->age > 0) ? AT_AGE_KEEP : AT_AGE_REMOVE;
 }
@@ -267,12 +267,12 @@ static int ridingcapacity(unit * u)
      ** tragen nichts (siehe walkingcapacity). Ein Wagen zählt nur, wenn er
      ** von zwei Pferden gezogen wird */
 
-    animals = _min(animals, effskill(u, SK_RIDING, 0) * u->number * 2);
+    animals = MIN(animals, effskill(u, SK_RIDING, 0) * u->number * 2);
     if (fval(u_race(u), RCF_HORSE))
         animals += u->number;
 
     /* maximal diese Pferde können zum Ziehen benutzt werden */
-    vehicles = _min(animals / HORSESNEEDED, vehicles);
+    vehicles = MIN(animals / HORSESNEEDED, vehicles);
 
     return vehicles * vcap + animals * acap;
 }
@@ -291,7 +291,7 @@ int walkingcapacity(const struct unit *u)
     /* Das Gewicht, welches die Pferde tragen, plus das Gewicht, welches
      * die Leute tragen */
 
-    pferde_fuer_wagen = _min(animals, effskill(u, SK_RIDING, 0) * u->number * 4);
+    pferde_fuer_wagen = MIN(animals, effskill(u, SK_RIDING, 0) * u->number * 4);
     if (fval(u_race(u), RCF_HORSE)) {
         animals += u->number;
         people = 0;
@@ -301,7 +301,7 @@ int walkingcapacity(const struct unit *u)
     }
 
     /* maximal diese Pferde können zum Ziehen benutzt werden */
-    wagen_mit_pferden = _min(vehicles, pferde_fuer_wagen / HORSESNEEDED);
+    wagen_mit_pferden = MIN(vehicles, pferde_fuer_wagen / HORSESNEEDED);
 
     n = wagen_mit_pferden * vcap;
 
@@ -311,7 +311,7 @@ int walkingcapacity(const struct unit *u)
         wagen_ohne_pferde = vehicles - wagen_mit_pferden;
 
         /* Genug Trolle, um die Restwagen zu ziehen? */
-        wagen_mit_trollen = _min(u->number / 4, wagen_ohne_pferde);
+        wagen_mit_trollen = MIN(u->number / 4, wagen_ohne_pferde);
 
         /* Wagenkapazität hinzuzählen */
         n += wagen_mit_trollen * vcap;
@@ -335,7 +335,7 @@ int walkingcapacity(const struct unit *u)
         int belts = i_get(u->items, rbelt->itype);
         if (belts) {
             int multi = config_get_int("rules.trollbelt.multiplier", STRENGTHMULTIPLIER);
-            n += _min(people, belts) * (multi - 1) * u_race(u)->capacity;
+            n += MIN(people, belts) * (multi - 1) * u_race(u)->capacity;
         }
     }
 
@@ -366,7 +366,7 @@ static int canwalk(unit * u)
     effsk = effskill(u, SK_RIDING, 0);
     maxwagen = effsk * u->number * 2;
     if (u_race(u) == get_race(RC_TROLL)) {
-        maxwagen = _max(maxwagen, u->number / 4);
+        maxwagen = MAX(maxwagen, u->number / 4);
     }
     maxpferde = effsk * u->number * 4 + u->number;
 
@@ -505,7 +505,7 @@ static double overload(const region * r, ship * sh)
 
         double ovl = n / (double)sh->type->cargo;
         if (mcabins)
-            ovl = _max(ovl, p / (double)mcabins);
+            ovl = MAX(ovl, p / (double)mcabins);
         return ovl;
     }
 }
@@ -752,7 +752,7 @@ double damage_overload(double overload)
     badness = overload - overload_worse();
     if (badness >= 0) {
         assert(overload_worst() > overload_worse() || !"overload.worst must be > overload.worse");
-        damage += _min(badness, overload_worst() - overload_worse()) *
+        damage += MIN(badness, overload_worst() - overload_worse()) *
             (overload_max_damage() - damage) /
             (overload_worst() - overload_worse());
     }
@@ -946,7 +946,7 @@ static unit *bewegung_blockiert_von(unit * reisender, region * r)
                 guard_count += u->number;
                 double prob_u = (sk - stealth) * skill_prob;
                 /* amulet counts at most once */
-                prob_u += _min(1, _min(u->number, i_get(u->items, ramulet->itype))) * amulet_prob;
+                prob_u += MIN(1, MIN(u->number, i_get(u->items, ramulet->itype))) * amulet_prob;
                 if (u->building && (u->building->type == castle_bt) && u == building_owner(u->building))
                     prob_u += castle_prob*buildingeffsize(u->building, 0);
                 if (prob_u >= prob) {
@@ -1985,7 +1985,7 @@ static void sail(unit * u, order * ord, region_list ** routep, bool drifting)
                             const luxury_type *ltype = resource2luxury(itm->type->rtype);
                             if (ltype != NULL && itm->number > 0) {
                                 int st = itm->number * effskill(harbourmaster, SK_TRADE, 0) / 50;
-                                st = _min(itm->number, st);
+                                st = MIN(itm->number, st);
 
                                 if (st > 0) {
                                     i_change(&u2->items, itm->type, -st);
diff --git a/src/move.h b/src/move.h
index 14c040493..4d0b4e9f2 100644
--- a/src/move.h
+++ b/src/move.h
@@ -16,11 +16,12 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 **/
 
+#include "direction.h"
+#include <stdbool.h>
+
 #ifndef H_KRNL_MOVEMENT
 #define H_KRNL_MOVEMENT
 
-#include "direction.h"
-
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/src/names.c b/src/names.c
index cf1cdb910..248084828 100644
--- a/src/names.c
+++ b/src/names.c
@@ -365,7 +365,7 @@ static void dracoid_name(unit * u)
     size_t sz;
 
     /* ignore u */
-    unused_arg(u);
+    UNUSED_ARG(u);
     /* Wieviele Mittelteile? */
 
     mid_syllabels = rng_int() % 4;
@@ -425,8 +425,8 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars)
         }
     }
 
-    /* Buchstaben pro Teilk�rzel = _max(1,max/AnzWort) */
-    bpt = (c > 0) ? _max(1, maxchars / c) : 1;
+    /* Buchstaben pro Teilk�rzel = MAX(1,max/AnzWort) */
+    bpt = (c > 0) ? MAX(1, maxchars / c) : 1;
 
     /* Einzelne W�rter anspringen und jeweils die ersten BpT kopieren */
 
diff --git a/src/platform.h b/src/platform.h
index c781021ae..2f114cec5 100644
--- a/src/platform.h
+++ b/src/platform.h
@@ -1,179 +1,15 @@
-/*
-Copyright (c) 1998-2015, Enno Rehling <enno@eressea.de>
-                         Katja Zedel <katze@felidae.kn-bremen.de
-                         Christian Schlittchen <corwin@amber.kn-bremen.de>
+#pragma once
 
-Permission to use, copy, modify, and/or distribute this software for any
-purpose with or without fee is hereby granted, provided that the above
-copyright notice and this permission notice appear in all copies.
+#ifndef UNILIB_H
+#define UNILIB_H
 
-THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-**/
-
-#ifndef PLATFORM_H
-#define PLATFORM_H
-
-#ifdef NDEBUG
-#define LOMEM
+#ifndef MAX_PATH
+# define MAX_PATH 4096
 #endif
 
-// enable X/Open 7 extensions (like strdup):
-#ifndef _XOPEN_SOURCE
-#define _XOPEN_SOURCE 700
-#endif
+#define UNUSED_ARG(a) (void)(a)
 
-// enable bsd string extensions, since glibc 2.12 (_BSD_SOURCE is dead):
-#ifndef _POSIX_C_SOURCE
-#define _POSIX_C_SOURCE 200809L
-#endif
-
-#ifndef USE_AUTOCONF
-#define USE_AUTOCONF
-
-#ifdef _MSC_VER
-#undef USE_AUTOCONF
-#define HAVE_STDBOOL_H
-#define HAVE_DIRECT__MKDIR
-#define HAVE__ACCESS
-
-#define VC_EXTRALEAN
-#define WIN32_LEAN_AND_MEAN
-#pragma warning(push)
-#pragma warning(disable:4820 4255 4668)
-# include <windows.h>
-# include <io.h>
-#pragma warning(pop)
-# undef MOUSE_MOVED
-# define STDIO_CP 1252          /* log.c, convert to console character set */
-# pragma warning (disable: 4201 4214 4514 4115 4711)
-#if _MSC_VER >= 1900
-# pragma warning(disable: 4710)
-/* warning C4710: function not inlined */
-# pragma warning(disable: 4456)
-/* warning C4456 : declaration of <name> hides previous local declaration */
-# pragma warning(disable: 4457)
-/* warning C4457: declaration of <name> hides function parameter */
-# pragma warning(disable: 4459)
-/* warning C4459: declaration of <name> hides global declaration */
-#endif
-# pragma warning(disable: 4056)
-/* warning C4056: overflow in floating point constant arithmetic */
-# pragma warning(disable: 4201)
-/* warning C4201: nonstandard extension used : nameless struct/union */
-# pragma warning(disable: 4214)
-/* warning C4214: nonstandard extension used : bit field types other than int */
-# pragma warning(disable: 4100)
-/* warning C4100: <name> : unreferenced formal parameter */
-# pragma warning(disable: 4996)
-/* <name> is not defined as a preprocessor macro, replacing with '0' for '#if/#elif' */
-# pragma warning(disable: 4668)
-/* <type>: <num> bytes padding after data member <member> */
-# pragma warning(disable: 4820)
-
-/* warning C4100: <name> was declared deprecated */
-#ifndef _CRT_SECURE_NO_DEPRECATE
-#define _CRT_SECURE_NO_DEPRECATE
-#endif
-
-/*
- * http://msdn2.microsoft.com/en-us/library/ms235505(VS.80).aspx
- * Defining _CRT_DISABLE_PERFCRIT_LOCKS forces all I/O operations to assume a 
- * single-threaded I/O model and use the _nolock forms of the functions. 
- */
-#ifndef _CRT_DISABLE_PERFCRIT_LOCKS
-#define _CRT_DISABLE_PERFCRIT_LOCKS
-#endif
-
-#elif __GNUC__
-#undef USE_AUTOCONF
-#define HAVE_SNPRINTF
-#define HAVE_SYS_STAT_MKDIR
-#define HAVE_STRDUP
-#define HAVE_UNISTD_H
-#endif
-#endif
-
-#ifdef USE_AUTOCONF
-// unknown toolchain, using autoconf
-#include <autoconf.h>
-#endif
-
-#define unused_arg (void)
-
-#define iswxspace(c) (c==160 || iswspace(c))
-#define isxspace(c) (c==160 || isspace(c))
-
-#define TOLUA_CAST (char*)
-
-#if !defined(MAX_PATH)
-#if defined(PATH_MAX)
-# define MAX_PATH PATH_MAX
-#else
-# define MAX_PATH 256
-#endif
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#if defined(HAVE_STDBOOL_H)
-# include <stdbool.h>
-#else
-# ifndef HAVE__BOOL
-#  ifdef __cplusplus
-typedef bool _Bool;
-#  else
-typedef unsigned char _Bool;
-#  endif
-# endif
-# define bool _Bool
-# define false 0
-# define true 1
-# define __bool_true_false_are_defined 1
-#endif
-
-#ifndef HAVE__ACCESS
-#ifdef HAVE_ACCESS
-#define _access(path, mode) access(path, mode)
-#endif
-#endif
-
-#if defined(HAVE_DIRECT__MKDIR)
-#include <direct.h>
-#elif defined(HAVE_DIRECT_MKDIR)
-#include <direct.h>
-#define _mkdir(a) mkdir(a)
-#elif defined(HAVE_SYS_STAT_MKDIR)
-#include <sys/stat.h>
-#define _mkdir(a) mkdir(a, 0777)
-#endif
-
-#ifndef _min
-#define _min(a,b) ((a) < (b) ? (a) : (b))
-#endif
-#ifndef _max
-#define _max(a,b) ((a) > (b) ? (a) : (b))
-#endif
-
-#if !defined(HAVE__STRDUP)
-#if defined(HAVE_STRDUP)
-#undef _strdup
-#define _strdup strdup
-#endif
-#endif
-
-#if !defined(HAVE__SNPRINTF)
-#if defined(HAVE_SNPRINTF)
-#define _snprintf snprintf
-#endif
-#endif
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#define MAX(a, b) (((a) > (b)) ? (a) : (b))
 
 #endif
-
diff --git a/src/prefix.c b/src/prefix.c
index a6564b6e8..1a22e6982 100644
--- a/src/prefix.c
+++ b/src/prefix.c
@@ -30,7 +30,7 @@ int add_raceprefix(const char *prefix)
         race_prefixes = tmp;
         size *= 2;
     }
-    race_prefixes[next++] = _strdup(prefix);
+    race_prefixes[next++] = strdup(prefix);
     race_prefixes[next] = NULL;
     return 0;
 }
diff --git a/src/races/dragons.c b/src/races/dragons.c
index 222d63c89..aa79a783a 100644
--- a/src/races/dragons.c
+++ b/src/races/dragons.c
@@ -22,7 +22,7 @@
 /* util includes */
 #include <util/rng.h>
 
-#define age_chance(a,b,p) (_max(0,a-b)*p)
+#define age_chance(a,b,p) (MAX(0,a-b)*p)
 
 #define DRAGONAGE                   27
 #define WYRMAGE                     68
diff --git a/src/races/races.c b/src/races/races.c
index 2c6cfffa9..8af9cf2ed 100644
--- a/src/races/races.c
+++ b/src/races/races.c
@@ -42,7 +42,7 @@ static void oldfamiliars(unit * u)
     char fname[64];
     /* these familiars have no special skills.
      */
-    _snprintf(fname, sizeof(fname), "%s_familiar", u_race(u)->_name);
+    snprintf(fname, sizeof(fname), "%s_familiar", u_race(u)->_name);
     create_mage(u, M_GRAY);
     equip_unit(u, get_equipment(fname));
 }
diff --git a/src/races/zombies.c b/src/races/zombies.c
index 3e9303b38..ea26298b2 100644
--- a/src/races/zombies.c
+++ b/src/races/zombies.c
@@ -33,7 +33,7 @@
 #define UNDEAD_BREAKUP              25  /* chance dafuer */
 #define UNDEAD_BREAKUP_FRACTION     (25+rng_int()%70)   /* anteil der weg geht */
 
-#define age_chance(a,b,p) (_max(0,a-b)*p)
+#define age_chance(a,b,p) (MAX(0,a-b)*p)
 
 void make_undead_unit(unit * u)
 {
@@ -70,7 +70,7 @@ void age_undead(unit * u)
 void age_skeleton(unit * u)
 {
     if (is_monsters(u->faction) && rng_int() % 100 < age_chance(u->age, 27, 1)) {
-        int n = _max(1, u->number / 2);
+        int n = MAX(1, u->number / 2);
         double q = (double)u->hp / (double)(unit_max_hp(u) * u->number);
         u_setrace(u, get_race(RC_SKELETON_LORD));
         u->irace = NULL;
@@ -82,7 +82,7 @@ void age_skeleton(unit * u)
 void age_zombie(unit * u)
 {
     if (is_monsters(u->faction) && rng_int() % 100 < age_chance(u->age, 27, 1)) {
-        int n = _max(1, u->number / 2);
+        int n = MAX(1, u->number / 2);
         double q = (double)u->hp / (double)(unit_max_hp(u) * u->number);
         u_setrace(u, get_race(RC_ZOMBIE_LORD));
         u->irace = NULL;
@@ -94,7 +94,7 @@ void age_zombie(unit * u)
 void age_ghoul(unit * u)
 {
     if (is_monsters(u->faction) && rng_int() % 100 < age_chance(u->age, 27, 1)) {
-        int n = _max(1, u->number / 2);
+        int n = MAX(1, u->number / 2);
         double q = (double)u->hp / (double)(unit_max_hp(u) * u->number);
         u_setrace(u, get_race(RC_GHOUL_LORD));
         u->irace = NULL;
diff --git a/src/randenc.c b/src/randenc.c
index 536210b1f..ab51d64b1 100644
--- a/src/randenc.c
+++ b/src/randenc.c
@@ -785,7 +785,7 @@ static void rotting_herbs(void)
                 if (fval(itm->type, ITF_HERB)) {
                     double nv = normalvariate(k, k / 4);
                     int inv = (int)nv;
-                    int delta = _min(n, inv);
+                    int delta = MIN(n, inv);
                     if (!i_change(itmp, itm->type, -delta)) {
                         continue;
                     }
@@ -814,7 +814,7 @@ void randomevents(void)
         while (*blist) {
             building *b = *blist;
             if (fval(b->type, BTF_DECAY) && !building_owner(b)) {
-                b->size -= _max(1, (b->size * 20) / 100);
+                b->size -= MAX(1, (b->size * 20) / 100);
                 if (b->size == 0) {
                     remove_building(blist, r->buildings);
                 }
diff --git a/src/report.c b/src/report.c
index 0c7697fe5..9b5e243b4 100644
--- a/src/report.c
+++ b/src/report.c
@@ -269,17 +269,17 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc
 
     /* Reihenfolge beachten: Erst REGION, dann STUFE! */
     if (sp->sptyp & FARCASTING) {
-        bytes = _snprintf(bufp, size, " [%s x y]", LOC(lang, parameters[P_REGION]));
+        bytes = snprintf(bufp, size, " [%s x y]", LOC(lang, parameters[P_REGION]));
         if (wrptr(&bufp, &size, bytes) != 0)
             WARN_STATIC_BUFFER();
     }
     if (sp->sptyp & SPELLLEVEL) {
-        bytes = _snprintf(bufp, size, " [%s n]", LOC(lang, parameters[P_LEVEL]));
+        bytes = snprintf(bufp, size, " [%s n]", LOC(lang, parameters[P_LEVEL]));
         if (wrptr(&bufp, &size, bytes) != 0)
             WARN_STATIC_BUFFER();
     }
 
-    bytes = (int)_snprintf(bufp, size, " \"%s\"", spell_name(sp, lang));
+    bytes = (int)snprintf(bufp, size, " \"%s\"", spell_name(sp, lang));
     if (wrptr(&bufp, &size, bytes) != 0)
         WARN_STATIC_BUFFER();
 
@@ -305,12 +305,12 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc
         if (cp == 'u') {
             targetp = targets + 1;
             locp = LOC(lang, targetp->vars);
-            bytes = (int)_snprintf(bufp, size, " <%s>", locp);
+            bytes = (int)snprintf(bufp, size, " <%s>", locp);
             if (*params == '+') {
                 ++params;
                 if (wrptr(&bufp, &size, bytes) != 0)
                     WARN_STATIC_BUFFER();
-                bytes = (int)_snprintf(bufp, size, " [<%s> ...]", locp);
+                bytes = (int)snprintf(bufp, size, " [<%s> ...]", locp);
             }
             if (wrptr(&bufp, &size, bytes) != 0)
                 WARN_STATIC_BUFFER();
@@ -318,12 +318,12 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc
         else if (cp == 's') {
             targetp = targets + 2;
             locp = LOC(lang, targetp->vars);
-            bytes = (int)_snprintf(bufp, size, " <%s>", locp);
+            bytes = (int)snprintf(bufp, size, " <%s>", locp);
             if (*params == '+') {
                 ++params;
                 if (wrptr(&bufp, &size, bytes) != 0)
                     WARN_STATIC_BUFFER();
-                bytes = (int)_snprintf(bufp, size, " [<%s> ...]", locp);
+                bytes = (int)snprintf(bufp, size, " [<%s> ...]", locp);
             }
             if (wrptr(&bufp, &size, bytes) != 0)
                 WARN_STATIC_BUFFER();
@@ -342,12 +342,12 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc
         else if (cp == 'b') {
             targetp = targets + 3;
             locp = LOC(lang, targetp->vars);
-            bytes = (int)_snprintf(bufp, size, " <%s>", locp);
+            bytes = (int)snprintf(bufp, size, " <%s>", locp);
             if (*params == '+') {
                 ++params;
                 if (wrptr(&bufp, &size, bytes) != 0)
                     WARN_STATIC_BUFFER();
-                bytes = (int)_snprintf(bufp, size, " [<%s> ...]", locp);
+                bytes = (int)snprintf(bufp, size, " [<%s> ...]", locp);
             }
             if (wrptr(&bufp, &size, bytes) != 0)
                 WARN_STATIC_BUFFER();
@@ -382,17 +382,17 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc
                     if (targetp->param && targetp->vars) {
                         locp = LOC(lang, targetp->vars);
                         bytes =
-                            (int)_snprintf(bufp, size, " %s <%s>", parameters[targetp->param],
+                            (int)snprintf(bufp, size, " %s <%s>", parameters[targetp->param],
                                 locp);
                         if (multi) {
                             if (wrptr(&bufp, &size, bytes) != 0)
                                 WARN_STATIC_BUFFER();
-                            bytes = (int)_snprintf(bufp, size, " [<%s> ...]", locp);
+                            bytes = (int)snprintf(bufp, size, " [<%s> ...]", locp);
                         }
                     }
                     else {
                         bytes =
-                            (int)_snprintf(bufp, size, " %s", parameters[targetp->param]);
+                            (int)snprintf(bufp, size, " %s", parameters[targetp->param]);
                     }
                     if (wrptr(&bufp, &size, bytes) != 0)
                         WARN_STATIC_BUFFER();
@@ -422,10 +422,10 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc
             }
             if (*params == '?') {
                 ++params;
-                bytes = (int)_snprintf(bufp, size, " [<%s>]", locp);
+                bytes = (int)snprintf(bufp, size, " [<%s>]", locp);
             }
             else {
-                bytes = (int)_snprintf(bufp, size, " <%s>", locp);
+                bytes = (int)snprintf(bufp, size, " <%s>", locp);
             }
             if (wrptr(&bufp, &size, bytes) != 0)
                 WARN_STATIC_BUFFER();
@@ -494,18 +494,18 @@ void nr_spell(struct stream *out, spellbook_entry * sbe, const struct locale *la
             bufp = buf;
             if (sp->sptyp & SPELLLEVEL) {
                 bytes =
-                    _snprintf(bufp, size, "  %d %s", itemanz, LOC(lang, resourcename(rtype,
+                    snprintf(bufp, size, "  %d %s", itemanz, LOC(lang, resourcename(rtype,
                         itemanz != 1)));
                 if (wrptr(&bufp, &size, bytes) != 0)
                     WARN_STATIC_BUFFER();
                 if (costtyp == SPC_LEVEL || costtyp == SPC_LINEAR) {
-                    bytes = _snprintf(bufp, size, " * %s", LOC(lang, "nr_level"));
+                    bytes = snprintf(bufp, size, " * %s", LOC(lang, "nr_level"));
                     if (wrptr(&bufp, &size, bytes) != 0)
                         WARN_STATIC_BUFFER();
                 }
             }
             else {
-                bytes = _snprintf(bufp, size, "%d %s", itemanz, LOC(lang, resourcename(rtype, itemanz != 1)));
+                bytes = snprintf(bufp, size, "%d %s", itemanz, LOC(lang, resourcename(rtype, itemanz != 1)));
                 if (wrptr(&bufp, &size, bytes) != 0) {
                     WARN_STATIC_BUFFER();
                 }
@@ -929,7 +929,7 @@ static void describe(struct stream *out, const region * r, faction * f)
             }
             if (!e) {
                 e = calloc(sizeof(struct edge), 1);
-                e->name = _strdup(name);
+                e->name = strdup(name);
                 e->transparent = transparent;
                 e->next = edges;
                 edges = e;
@@ -945,13 +945,13 @@ static void describe(struct stream *out, const region * r, faction * f)
         WARN_STATIC_BUFFER();
 
     if (r->seen.mode == seen_travel) {
-        bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "see_travel"));
+        bytes = snprintf(bufp, size, " (%s)", LOC(f->locale, "see_travel"));
     }
     else if (r->seen.mode == seen_neighbour) {
-        bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "see_neighbour"));
+        bytes = snprintf(bufp, size, " (%s)", LOC(f->locale, "see_neighbour"));
     }
     else if (r->seen.mode == seen_lighthouse) {
-        bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "see_lighthouse"));
+        bytes = snprintf(bufp, size, " (%s)", LOC(f->locale, "see_lighthouse"));
     }
     else {
         bytes = 0;
@@ -974,7 +974,7 @@ static void describe(struct stream *out, const region * r, faction * f)
     saplings = rtrees(r, 1);
     if (production(r)) {
         if (trees > 0 || saplings > 0) {
-            bytes = _snprintf(bufp, size, ", %d/%d ", trees, saplings);
+            bytes = snprintf(bufp, size, ", %d/%d ", trees, saplings);
             if (wrptr(&bufp, &size, bytes) != 0)
                 WARN_STATIC_BUFFER();
 
@@ -1004,7 +1004,7 @@ static void describe(struct stream *out, const region * r, faction * f)
 
         for (n = 0; n < numresults; ++n) {
             if (result[n].number >= 0 && result[n].level >= 0) {
-                bytes = _snprintf(bufp, size, ", %d %s/%d", result[n].number,
+                bytes = snprintf(bufp, size, ", %d %s/%d", result[n].number,
                     LOC(f->locale, result[n].name), result[n].level);
                 if (wrptr(&bufp, &size, bytes) != 0)
                     WARN_STATIC_BUFFER();
@@ -1015,14 +1015,14 @@ static void describe(struct stream *out, const region * r, faction * f)
     /* peasants & silver */
     if (rpeasants(r)) {
         int n = rpeasants(r);
-        bytes = _snprintf(bufp, size, ", %d", n);
+        bytes = snprintf(bufp, size, ", %d", n);
         if (wrptr(&bufp, &size, bytes) != 0)
             WARN_STATIC_BUFFER();
 
         if (r->land->ownership) {
             const char *str =
                 LOC(f->locale, mkname("morale", itoa10(region_get_morale(r))));
-            bytes = _snprintf(bufp, size, " %s", str);
+            bytes = snprintf(bufp, size, " %s", str);
             if (wrptr(&bufp, &size, bytes) != 0)
                 WARN_STATIC_BUFFER();
         }
@@ -1041,7 +1041,7 @@ static void describe(struct stream *out, const region * r, faction * f)
         }
     }
     if (rmoney(r) && r->seen.mode >= seen_travel) {
-        bytes = _snprintf(bufp, size, ", %d ", rmoney(r));
+        bytes = snprintf(bufp, size, ", %d ", rmoney(r));
         if (wrptr(&bufp, &size, bytes) != 0)
             WARN_STATIC_BUFFER();
         bytes =
@@ -1053,7 +1053,7 @@ static void describe(struct stream *out, const region * r, faction * f)
     /* Pferde */
 
     if (rhorses(r)) {
-        bytes = _snprintf(bufp, size, ", %d ", rhorses(r));
+        bytes = snprintf(bufp, size, ", %d ", rhorses(r));
         if (wrptr(&bufp, &size, bytes) != 0)
             WARN_STATIC_BUFFER();
         bytes =
@@ -1141,7 +1141,7 @@ static void describe(struct stream *out, const region * r, faction * f)
                     if (wrptr(&bufp, &size, bytes) != 0)
                         WARN_STATIC_BUFFER();
                     f_regionid(r2, f, regname, sizeof(regname));
-                    bytes = _snprintf(bufp, size, trailinto(r2, f->locale), regname);
+                    bytes = snprintf(bufp, size, trailinto(r2, f->locale), regname);
                     if (wrptr(&bufp, &size, bytes) != 0)
                         WARN_STATIC_BUFFER();
                 }
@@ -1453,7 +1453,7 @@ report_template(const char *filename, report_context * ctx, const char *bom)
 
                 bufp = buf;
                 size = sizeof(buf) - 1;
-                bytes = _snprintf(bufp, size, "%s %s;    %s [%d,%d$",
+                bytes = snprintf(bufp, size, "%s %s;    %s [%d,%d$",
                     LOC(u->faction->locale, parameters[P_UNIT]),
                     itoa36(u->no), unit_getname(u), u->number, get_money(u));
                 if (wrptr(&bufp, &size, bytes) != 0)
@@ -1631,7 +1631,7 @@ static void allies(struct stream *out, const faction * f)
     if (f->allies) {
         int bytes;
         size_t size = sizeof(buf);
-        bytes = _snprintf(buf, size, "%s ", LOC(f->locale, "faction_help"));
+        bytes = snprintf(buf, size, "%s ", LOC(f->locale, "faction_help"));
         size -= bytes;
         show_allies(f, f->allies, buf + bytes, size);
         paragraph(out, buf, 0, 0, 0);
@@ -1642,7 +1642,7 @@ static void allies(struct stream *out, const faction * f)
         if (g->allies) {
             int bytes;
             size_t size = sizeof(buf);
-            bytes = _snprintf(buf, size, "%s %s ", g->name, LOC(f->locale, "group_help"));
+            bytes = snprintf(buf, size, "%s %s ", g->name, LOC(f->locale, "group_help"));
             size -= bytes;
             show_allies(f, g->allies, buf + bytes, size);
             paragraph(out, buf, 0, 0, 0);
@@ -1781,12 +1781,12 @@ nr_ship(struct stream *out, const region *r, const ship * sh, const faction * f,
         getshipweight(sh, &n, &p);
         n = (n + 99) / 100;         /* 1 Silber = 1 GE */
 
-        bytes = _snprintf(bufp, size, "%s, %s, (%d/%d)", shipname(sh),
+        bytes = snprintf(bufp, size, "%s, %s, (%d/%d)", shipname(sh),
             LOC(f->locale, sh->type->_name), n, shipcapacity(sh) / 100);
     }
     else {
         bytes =
-            _snprintf(bufp, size, "%s, %s", shipname(sh), LOC(f->locale,
+            snprintf(bufp, size, "%s, %s", shipname(sh), LOC(f->locale,
                 sh->type->_name));
     }
     if (wrptr(&bufp, &size, bytes) != 0)
@@ -1794,7 +1794,7 @@ nr_ship(struct stream *out, const region *r, const ship * sh, const faction * f,
 
     assert(sh->type->construction->improvement == NULL);  /* sonst ist construction::size nicht ship_type::maxsize */
     if (sh->size != sh->type->construction->maxsize) {
-        bytes = _snprintf(bufp, size, ", %s (%d/%d)",
+        bytes = snprintf(bufp, size, ", %s (%d/%d)",
             LOC(f->locale, "nr_undercons"), sh->size,
             sh->type->construction->maxsize);
         if (wrptr(&bufp, &size, bytes) != 0)
@@ -1803,7 +1803,7 @@ nr_ship(struct stream *out, const region *r, const ship * sh, const faction * f,
     if (sh->damage) {
         int percent = ship_damage_percent(sh);
         bytes =
-            _snprintf(bufp, size, ", %d%% %s", percent, LOC(f->locale, "nr_damaged"));
+            snprintf(bufp, size, ", %d%% %s", percent, LOC(f->locale, "nr_damaged"));
         if (wrptr(&bufp, &size, bytes) != 0)
             WARN_STATIC_BUFFER();
     }
@@ -1852,7 +1852,7 @@ nr_building(struct stream *out, const region *r, const building *b, const factio
     lang = f->locale;
     newline(out);
     bytes =
-        _snprintf(bufp, size, "%s, %s %d, ", buildingname(b), LOC(lang,
+        snprintf(bufp, size, "%s, %s %d, ", buildingname(b), LOC(lang,
             "nr_size"), b->size);
     if (wrptr(&bufp, &size, bytes) != 0)
         WARN_STATIC_BUFFER();
@@ -1867,7 +1867,7 @@ nr_building(struct stream *out, const region *r, const building *b, const factio
         if (owner && owner->faction == f) {
             /* illusion. report real type */
             name = LOC(lang, bname);
-            bytes = _snprintf(bufp, size, " (%s)", name);
+            bytes = snprintf(bufp, size, " (%s)", name);
             if (wrptr(&bufp, &size, bytes) != 0)
                 WARN_STATIC_BUFFER();
         }
@@ -2168,7 +2168,7 @@ report_plaintext(const char *filename, report_context * ctx,
 
     bufp = buf;
     size = sizeof(buf) - 1;
-    bytes = _snprintf(buf, size, "%s:", LOC(f->locale, "nr_options"));
+    bytes = snprintf(buf, size, "%s:", LOC(f->locale, "nr_options"));
     if (wrptr(&bufp, &size, bytes) != 0)
         WARN_STATIC_BUFFER();
     for (op = 0; op != MAXOPTIONS; op++) {
@@ -2220,14 +2220,14 @@ report_plaintext(const char *filename, report_context * ctx,
 
             newline(out);
             centre(out, LOC(f->locale, pname), true);
-            _snprintf(buf, sizeof(buf), "%s %d", LOC(f->locale, "nr_level"),
+            snprintf(buf, sizeof(buf), "%s %d", LOC(f->locale, "nr_level"),
                 ptype->level);
             centre(out, buf, true);
             newline(out);
 
             bufp = buf;
             size = sizeof(buf) - 1;
-            bytes = _snprintf(bufp, size, "%s: ", LOC(f->locale, "nr_herbsrequired"));
+            bytes = snprintf(bufp, size, "%s: ", LOC(f->locale, "nr_herbsrequired"));
             if (wrptr(&bufp, &size, bytes) != 0)
                 WARN_STATIC_BUFFER();
 
diff --git a/src/report.test.c b/src/report.test.c
index 202458db5..ab7c377ce 100644
--- a/src/report.test.c
+++ b/src/report.test.c
@@ -140,7 +140,7 @@ static void cleanup_spell_fixture(spell_fixture *spf) {
 
 static void set_parameter(spell_fixture spell, char *value) {
     free(spell.sp->parameter);
-    spell.sp->parameter = _strdup(value);
+    spell.sp->parameter = strdup(value);
 }
 
 static void check_spell_syntax(CuTest *tc, char *msg, spell_fixture *spell, char *syntax) {
@@ -211,14 +211,14 @@ static void test_write_spell_syntax(CuTest *tc) {
 
     set_parameter(spell, "bc");
     free(spell.sp->syntax);
-    spell.sp->syntax = _strdup("hodor");
+    spell.sp->syntax = strdup("hodor");
     check_spell_syntax(tc, "bc hodor", &spell, "  ZAUBERE \"Testzauber\" <bnr> <Hodor>");
     free(spell.sp->syntax);
     spell.sp->syntax = 0;
 
     set_parameter(spell, "c?");
     free(spell.sp->syntax);
-    spell.sp->syntax = _strdup("hodor");
+    spell.sp->syntax = strdup("hodor");
     check_spell_syntax(tc, "c?", &spell, "  ZAUBERE \"Testzauber\" [<Hodor>]");
     free(spell.sp->syntax);
     spell.sp->syntax = 0;
diff --git a/src/reports.c b/src/reports.c
index 52278d270..b31ecac19 100644
--- a/src/reports.c
+++ b/src/reports.c
@@ -529,7 +529,7 @@ size_t size)
                 if (a_otherfaction && alliedunit(u, f, HELP_FSTEALTH)) {
                     faction *f = get_otherfaction(a_otherfaction);
                     int result =
-                        _snprintf(bufp, size, ", %s (%s)", factionname(f),
+                        snprintf(bufp, size, ", %s (%s)", factionname(f),
                         factionname(u->faction));
                     if (wrptr(&bufp, &size, result) != 0)
                         WARN_STATIC_BUFFER();
@@ -544,7 +544,7 @@ size_t size)
 
     bufp = STRLCPY(bufp, ", ", size);
 
-    if (wrptr(&bufp, &size, _snprintf(bufp, size, "%d ", u->number)))
+    if (wrptr(&bufp, &size, snprintf(bufp, size, "%d ", u->number)))
         WARN_STATIC_BUFFER();
 
     pzTmp = get_racename(u->attribs);
@@ -641,7 +641,7 @@ size_t size)
         bufp = STRLCPY(bufp, ", ", size);
 
         if (!dh) {
-            result = _snprintf(bufp, size, "%s: ", LOC(f->locale, "nr_inventory"));
+            result = snprintf(bufp, size, "%s: ", LOC(f->locale, "nr_inventory"));
             if (wrptr(&bufp, &size, result) != 0)
                 WARN_STATIC_BUFFER();
             dh = 1;
@@ -650,7 +650,7 @@ size_t size)
             bufp = STRLCPY(bufp, ic, size);
         }
         else {
-            if (wrptr(&bufp, &size, _snprintf(bufp, size, "%d %s", in, ic)))
+            if (wrptr(&bufp, &size, snprintf(bufp, size, "%d %s", in, ic)))
                 WARN_STATIC_BUFFER();
         }
     }
@@ -661,7 +661,7 @@ size_t size)
         if (book) {
             quicklist *ql = book->spells;
             int qi, header, maxlevel = effskill(u, SK_MAGIC, 0);
-            int result = _snprintf(bufp, size, ". Aura %d/%d", get_spellpoints(u), max_spellpoints(u->region, u));
+            int result = snprintf(bufp, size, ". Aura %d/%d", get_spellpoints(u), max_spellpoints(u->region, u));
             if (wrptr(&bufp, &size, result) != 0) {
                 WARN_STATIC_BUFFER();
             }
@@ -671,7 +671,7 @@ size_t size)
                 if (sbe->level <= maxlevel) {
                     int result = 0;
                     if (!header) {
-                        result = _snprintf(bufp, size, ", %s: ", LOC(f->locale, "nr_spells"));
+                        result = snprintf(bufp, size, ", %s: ", LOC(f->locale, "nr_spells"));
                         header = 1;
                     }
                     else {
@@ -690,7 +690,7 @@ size_t size)
             }
             if (i != MAXCOMBATSPELLS) {
                 int result =
-                    _snprintf(bufp, size, ", %s: ", LOC(f->locale, "nr_combatspells"));
+                    snprintf(bufp, size, ", %s: ", LOC(f->locale, "nr_combatspells"));
                 if (wrptr(&bufp, &size, result) != 0)
                     WARN_STATIC_BUFFER();
 
@@ -708,7 +708,7 @@ size_t size)
                         int sl = get_combatspelllevel(u, i);
                         bufp = STRLCPY(bufp, spell_name(sp, u->faction->locale), size);
                         if (sl > 0) {
-                            result = _snprintf(bufp, size, " (%d)", sl);
+                            result = snprintf(bufp, size, " (%d)", sl);
                             if (wrptr(&bufp, &size, result) != 0)
                                 WARN_STATIC_BUFFER();
                         }
@@ -819,13 +819,13 @@ const struct unit * u, struct skill * sv, int *dh, int days)
     if (sv->id == SK_STEALTH && fval(u, UFL_STEALTH)) {
         i = u_geteffstealth(u);
         if (i >= 0) {
-            if (wrptr(&bufp, &size, _snprintf(bufp, size, "%d/", i)) != 0)
+            if (wrptr(&bufp, &size, snprintf(bufp, size, "%d/", i)) != 0)
                 WARN_STATIC_BUFFER();
         }
     }
 
     effsk = eff_skill(u, sv, 0);
-    if (wrptr(&bufp, &size, _snprintf(bufp, size, "%d", effsk)) != 0)
+    if (wrptr(&bufp, &size, snprintf(bufp, size, "%d", effsk)) != 0)
         WARN_STATIC_BUFFER();
 
     if (u->faction->options & want(O_SHOWSKCHANGE)) {
@@ -836,11 +836,11 @@ const struct unit * u, struct skill * sv, int *dh, int days)
             oldeff = sv->old + get_modifier(u, sv->id, sv->old, u->region, false);
         }
 
-        oldeff = _max(0, oldeff);
+        oldeff = MAX(0, oldeff);
         diff = effsk - oldeff;
 
         if (diff != 0) {
-            if (wrptr(&bufp, &size, _snprintf(bufp, size, " (%s%d)", (diff > 0) ? "+" : "", diff)) != 0)
+            if (wrptr(&bufp, &size, snprintf(bufp, size, " (%s%d)", (diff > 0) ? "+" : "", diff)) != 0)
                 WARN_STATIC_BUFFER();
         }
     }
@@ -877,7 +877,7 @@ void split_paragraph(strlist ** SP, const char *s, unsigned int indent, unsigned
             firstline = false;
         }
         if (!cut) {
-            cut = s + _min(len, REPORTWIDTH);
+            cut = s + MIN(len, REPORTWIDTH);
         }
         memcpy(buf + indent, s, cut - s);
         buf[indent + (cut - s)] = 0;
@@ -1412,7 +1412,7 @@ int write_reports(faction * f, time_t ltime)
             int error = 0;
             do {
                 char filename[32];
-                char path[MAX_PATH];
+                char path[4096];
                 sprintf(filename, "%d-%s.%s", turn, itoa36(f->no),
                     rtype->extension);
                 join_path(reportpath(), filename, path, sizeof(path));
@@ -1482,7 +1482,7 @@ int reports(void)
     FILE *mailit;
     time_t ltime = time(NULL);
     int retval = 0;
-    char path[MAX_PATH];
+    char path[4096];
     const char * rpath = reportpath();
 
     log_info("Writing reports for turn %d:", turn);
@@ -1509,7 +1509,7 @@ int reports(void)
 
 static variant var_copy_string(variant x)
 {
-    x.v = x.v ? _strdup((const char *)x.v) : 0;
+    x.v = x.v ? strdup((const char *)x.v) : 0;
     return x;
 }
 
@@ -1613,7 +1613,7 @@ f_regionid(const region * r, const faction * f, char *buffer, size_t size)
         pnormalize(&nx, &ny, pl);
         adjust_coordinates(f, &nx, &ny, pl);
         len = strlcpy(buffer, rname(r, f ? f->locale : 0), size);
-        _snprintf(buffer + len, size - len, " (%d,%d%s%s)", nx, ny, named ? "," : "", (named) ? name : "");
+        snprintf(buffer + len, size - len, " (%d,%d%s%s)", nx, ny, named ? "," : "", (named) ? name : "");
         buffer[size - 1] = 0;
         len = strlen(buffer);
     }
@@ -1864,7 +1864,7 @@ static void eval_order(struct opstack **stack, const void *userdata)
     size_t len;
     variant var;
 
-    unused_arg(userdata);
+    UNUSED_ARG(userdata);
     write_order(ord, buf, sizeof(buf));
     len = strlen(buf);
     var.v = strcpy(balloc(len + 1), buf);
@@ -1884,7 +1884,7 @@ static void eval_resources(struct opstack **stack, const void *userdata)
     while (res != NULL && size > 4) {
         const char *rname =
             resourcename(res->type, (res->number != 1) ? NMF_PLURAL : 0);
-        int result = _snprintf(bufp, size, "%d %s", res->number, LOC(lang, rname));
+        int result = snprintf(bufp, size, "%d %s", res->number, LOC(lang, rname));
         if (wrptr(&bufp, &size, result) != 0 || size < sizeof(buf) / 2) {
             WARN_STATIC_BUFFER();
             break;
@@ -1948,7 +1948,7 @@ static void eval_trail(struct opstack **stack, const void *userdata)
     variant var;
     char *bufp = buf;
 #ifdef _SECURECRT_ERRCODE_VALUES_DEFINED
-    /* stupid MS broke _snprintf */
+    /* stupid MS broke snprintf */
     int eold = errno;
 #endif
 
@@ -1959,7 +1959,7 @@ static void eval_trail(struct opstack **stack, const void *userdata)
             const char *trail = trailinto(r, lang);
             const char *rn = f_regionid_s(r, report);
 
-            if (wrptr(&bufp, &size, _snprintf(bufp, size, trail, rn)) != 0)
+            if (wrptr(&bufp, &size, snprintf(bufp, size, trail, rn)) != 0)
                 WARN_STATIC_BUFFER();
 
             if (i + 2 < end) {
@@ -2015,7 +2015,7 @@ static void eval_int36(struct opstack **stack, const void *userdata)
 
     var.v = strcpy(balloc(len + 1), c);
     opush(stack, var);
-    unused_arg(userdata);
+    UNUSED_ARG(userdata);
 }
 
 /*** END MESSAGE RENDERING ***/
diff --git a/src/skill.h b/src/skill.h
index 8b0c0c155..24f96a844 100644
--- a/src/skill.h
+++ b/src/skill.h
@@ -3,7 +3,7 @@
 #ifndef H_SKILL_H
 #define H_SKILL_H
 
-#include <platform.h>
+#include <stdbool.h>
 struct locale;
 
 typedef enum {
diff --git a/src/spells.c b/src/spells.c
index 7e7b5669a..6ed38d022 100644
--- a/src/spells.c
+++ b/src/spells.c
@@ -60,6 +60,7 @@
 #include <util/assert.h>
 #include <util/attrib.h>
 #include <util/base36.h>
+#include <util/bsdstring.h>
 #include <util/event.h>
 #include <util/gamedata.h>
 #include <util/language.h>
@@ -149,7 +150,7 @@ static void magicanalyse_region(region * r, unit * mage, double force)
          * mehr als 100% probability und damit immer ein Erfolg. */
         probability = curse_chance(c, force);
         mon = c->duration + (rng_int() % 10) - 5;
-        mon = _max(1, mon);
+        mon = MAX(1, mon);
         found = true;
 
         if (chance(probability)) {  /* Analyse geglueckt */
@@ -190,7 +191,7 @@ static void magicanalyse_unit(unit * u, unit * mage, double force)
          * mehr als 100% probability und damit immer ein Erfolg. */
         probability = curse_chance(c, force);
         mon = c->duration + (rng_int() % 10) - 5;
-        mon = _max(1, mon);
+        mon = MAX(1, mon);
 
         if (chance(probability)) {  /* Analyse geglueckt */
             if (c_flags(c) & CURSE_NOAGE) {
@@ -231,7 +232,7 @@ static void magicanalyse_building(building * b, unit * mage, double force)
          * mehr als 100% probability und damit immer ein Erfolg. */
         probability = curse_chance(c, force);
         mon = c->duration + (rng_int() % 10) - 5;
-        mon = _max(1, mon);
+        mon = MAX(1, mon);
 
         if (chance(probability)) {  /* Analyse geglueckt */
             if (c_flags(c) & CURSE_NOAGE) {
@@ -272,7 +273,7 @@ static void magicanalyse_ship(ship * sh, unit * mage, double force)
          * mehr als 100% probability und damit immer ein Erfolg. */
         probability = curse_chance(c, force);
         mon = c->duration + (rng_int() % 10) - 5;
-        mon = _max(1, mon);
+        mon = MAX(1, mon);
 
         if (chance(probability)) {  /* Analyse geglueckt */
             if (c_flags(c) & CURSE_NOAGE) {
@@ -704,7 +705,7 @@ static int sp_destroy_magic(castorder * co)
             "unit region command", mage, mage->region, co->order));
     }
 
-    return _max(succ, 1);
+    return MAX(succ, 1);
 }
 
 /* ------------------------------------------------------------- */
@@ -773,7 +774,7 @@ static int sp_transferaura(castorder * co)
         return 0;
     }
 
-    gain = _min(aura, scm_src->spellpoints) / multi;
+    gain = MIN(aura, scm_src->spellpoints) / multi;
     scm_src->spellpoints -= gain * multi;
     scm_dst->spellpoints += gain;
 
@@ -912,7 +913,7 @@ static int sp_summonent(castorder * co)
         return 0;
     }
 
-    ents = _min((int)(power * power), rtrees(r, 2));
+    ents = MIN((int)(power * power), rtrees(r, 2));
 
     u = create_unit(r, mage->faction, ents, get_race(RC_TREEMAN), 0, NULL, mage);
 
@@ -1304,7 +1305,7 @@ static int sp_rosthauch(castorder * co)
         for (; iweapon != NULL; iweapon = iweapon->next) {
             item **ip = i_find(&u->items, iweapon->type);
             if (*ip) {
-                float chance = (float)_min((*ip)->number, force);
+                float chance = (float)MIN((*ip)->number, force);
                 if (iweapon->chance < 1.0) {
                     chance *= iweapon->chance;
                 }
@@ -1343,7 +1344,7 @@ static int sp_rosthauch(castorder * co)
      * unguenstigsten Fall kann pro Stufe nur eine Waffe verzaubert werden,
      * darum wird hier nur fuer alle Faelle in denen noch weniger Waffen
      * betroffen wurden ein Kostennachlass gegeben */
-    return _min(success, cast_level);
+    return MIN(success, cast_level);
 }
 
 /* ------------------------------------------------------------- */
@@ -1373,7 +1374,7 @@ static int sp_kaelteschutz(castorder * co)
     unit *mage = co->magician.u;
     int cast_level = co->level;
     double force = co->force;
-    int duration = _max(cast_level, (int)force) + 1;
+    int duration = MAX(cast_level, (int)force) + 1;
     spellparameter *pa = co->par;
     double effect;
 
@@ -2137,8 +2138,8 @@ static int sp_drought(castorder * co)
      */
     c = get_curse(r->attribs, ct_find("drought"));
     if (c) {
-        c->vigour = _max(c->vigour, power);
-        c->duration = _max(c->duration, (int)power);
+        c->vigour = MAX(c->vigour, power);
+        c->duration = MAX(c->duration, (int)power);
     }
     else {
         double effect = 4.0;
@@ -2335,8 +2336,8 @@ static int sp_earthquake(castorder * co)
         if (burg->size != 0 && !is_cursed(burg->attribs, C_MAGICWALLS, 0)) {
             /* Magieresistenz */
             if (!target_resists_magic(mage, burg, TYP_BUILDING, 0)) {
-                kaputt = _min(10 * cast_level, burg->size / 4);
-                kaputt = _max(kaputt, 1);
+                kaputt = MIN(10 * cast_level, burg->size / 4);
+                kaputt = MAX(kaputt, 1);
                 burg->size -= kaputt;
                 if (burg->size == 0) {
                     /* TODO: sollten die Insassen nicht Schaden nehmen? */
@@ -2501,7 +2502,7 @@ static int sp_forest_fire(castorder * co)
  *  das Zaubern. Patzer werden warscheinlicher.
  *  Jeder Zauber muss erst gegen den Wiederstand des Fluchs gezaubert
  *  werden und schwaecht dessen Antimagiewiederstand um 1.
- *  Wirkt _max(Stufe(Magier) - Stufe(Ziel), rand(3)) Wochen
+ *  Wirkt MAX(Stufe(Magier) - Stufe(Ziel), rand(3)) Wochen
  * Patzer:
  *  Magier wird selbst betroffen
  *
@@ -2529,7 +2530,7 @@ static int sp_fumblecurse(castorder * co)
 
     rx = rng_int() % 3;
     sx = cast_level - effskill(target, SK_MAGIC, 0);
-    duration = _max(sx, rx) + 1;
+    duration = MAX(sx, rx) + 1;
 
     effect = force / 2;
     c = create_curse(mage, &target->attribs, ct_find("fumble"),
@@ -2695,8 +2696,8 @@ static int sp_firewall(castorder * co)
     }
     else {
         fd = (wall_data *)b->data.v;
-        fd->force = (int)_max(fd->force, force / 2 + 0.5);
-        fd->countdown = _max(fd->countdown, cast_level + 1);
+        fd->force = (int)MAX(fd->force, force / 2 + 0.5);
+        fd->countdown = MAX(fd->countdown, cast_level + 1);
     }
 
     /* melden, 1x pro Partei */
@@ -2938,7 +2939,7 @@ attrib_type at_deathcloud_compat = {
 *   Ruestung wirkt nicht
 * Patzer:
 *   Magier geraet in den Staub und verliert zufaellige Zahl von HP bis
-*   auf _max(hp,2)
+*   auf MAX(hp,2)
 * Besonderheiten:
 *   Nicht als curse implementiert, was schlecht ist - man kann dadurch
 *   kein dispell machen. Wegen fix unter Zeitdruck erstmal nicht zu
@@ -3361,7 +3362,7 @@ static int sp_summonundead(castorder * co)
         return 0;
     }
 
-    undead = _min(deathcount(r), 2 + lovar(force));
+    undead = MIN(deathcount(r), 2 + lovar(force));
 
     if (cast_level <= 8) {
         race = get_race(RC_SKELETON);
@@ -3409,7 +3410,7 @@ static int sp_auraleak(castorder * co)
     int cast_level = co->level;
     message *msg;
 
-    lost = _min(0.95, cast_level * 0.05);
+    lost = MIN(0.95, cast_level * 0.05);
 
     for (u = r->units; u; u = u->next) {
         if (is_mage(u)) {
@@ -3792,8 +3793,8 @@ static int sp_raisepeasantmob(castorder * co)
     anteil = 6 + (rng_int() % 4);
 
     n = rpeasants(r) * anteil / 10;
-    n = _max(0, n);
-    n = _min(n, rpeasants(r));
+    n = MAX(0, n);
+    n = MIN(n, rpeasants(r));
 
     if (n <= 0) {
         report_failure(mage, co->order);
@@ -4032,13 +4033,13 @@ static int sp_recruit(castorder * co)
     n = (pow(force, 1.6) * 100) / f->race->recruitcost;
     if (rc->recruit_multi > 0) {
         double multp = (double)maxp / rc->recruit_multi;
-        n = _min(multp, n);
-        n = _max(n, 1);
+        n = MIN(multp, n);
+        n = MAX(n, 1);
         rsetpeasants(r, maxp - (int)(n * rc->recruit_multi));
     }
     else {
-        n = _min(maxp, n);
-        n = _max(n, 1);
+        n = MIN(maxp, n);
+        n = MAX(n, 1);
         rsetpeasants(r, maxp - (int)n);
     }
 
@@ -4083,13 +4084,13 @@ static int sp_bigrecruit(castorder * co)
 
     n = (int)force + lovar((force * force * 1000) / (float)f->race->recruitcost);
     if (f->race == get_race(RC_ORC)) {
-        n = _min(2 * maxp, n);
-        n = _max(n, 1);
+        n = MIN(2 * maxp, n);
+        n = MAX(n, 1);
         rsetpeasants(r, maxp - (n + 1) / 2);
     }
     else {
-        n = _min(maxp, n);
-        n = _max(n, 1);
+        n = MIN(maxp, n);
+        n = MAX(n, 1);
         rsetpeasants(r, maxp - n);
     }
 
@@ -4178,7 +4179,7 @@ static int sp_pump(castorder * co)
  *  Betoert eine Einheit, so das sie ihm den groe�ten Teil ihres Bargelds
  *  und 50% ihres Besitzes schenkt. Sie behaelt jedoch immer soviel, wie
  *  sie zum ueberleben braucht. Wirkt gegen Magieresistenz.
- *  _min(Stufe*1000$, u->money - maintenace)
+ *  MIN(Stufe*1000$, u->money - maintenace)
  *  Von jedem Item wird 50% abgerundet ermittelt und uebergeben. Dazu
  *  kommt Itemzahl%2 mit 50% chance
  *
@@ -4215,8 +4216,8 @@ static int sp_seduce(castorder * co)
         int loot;
         if (itm->type->rtype == rsilver) {
             loot =
-                _min(cast_level * 1000, get_money(target) - (maintenance_cost(target)));
-            loot = _max(loot, 0);
+                MIN(cast_level * 1000, get_money(target) - (maintenance_cost(target)));
+            loot = MAX(loot, 0);
         }
         else {
             loot = itm->number / 2;
@@ -4224,7 +4225,7 @@ static int sp_seduce(castorder * co)
                 loot += rng_int() % 2;
             }
             if (loot > 0) {
-                loot = _min(loot, (int)(force * 5));
+                loot = MIN(loot, (int)(force * 5));
             }
         }
         if (loot > 0) {
@@ -4341,7 +4342,7 @@ static int sp_headache(castorder * co)
     }
     if (smax != NULL) {
         /* wirkt auf maximal 10 Personen */
-        unsigned int change = _min(10, target->number) * (rng_uint() % 2 + 1) / target->number;
+        unsigned int change = MIN(10, target->number) * (rng_uint() % 2 + 1) / target->number;
         reduce_skill(target, smax, change);
     }
     set_order(&target->thisorder, NULL);
@@ -4385,7 +4386,7 @@ static int sp_raisepeasants(castorder * co)
             "error_nopeasants", ""));
         return 0;
     }
-    bauern = _min(rpeasants(r), (int)(power * 250));
+    bauern = MIN(rpeasants(r), (int)(power * 250));
     rsetpeasants(r, rpeasants(r) - bauern);
 
     u2 =
@@ -4468,7 +4469,7 @@ int sp_puttorest(castorder * co)
     message *seen = msg_message("puttorest", "mage", mage);
     message *unseen = msg_message("puttorest", "mage", NULL);
 
-    laid_to_rest = _max(laid_to_rest, dead);
+    laid_to_rest = MAX(laid_to_rest, dead);
 
     deathcounts(r, -laid_to_rest);
 
@@ -4713,7 +4714,7 @@ static int sp_gbdreams(castorder * co, const char *curse_name, int effect)
 
     /* wirkt erst in der Folgerunde, soll mindestens eine Runde wirken,
      * also duration+2 */
-    duration = (int)_max(1, power / 2);    /* Stufe 1 macht sonst mist */
+    duration = (int)MAX(1, power / 2);    /* Stufe 1 macht sonst mist */
     duration = 2 + rng_int() % duration;
 
     /* Nichts machen als ein entsprechendes Attribut in die Region legen. */
@@ -4752,7 +4753,7 @@ int sp_clonecopy(castorder * co)
         return 0;
     }
 
-    _snprintf(name, sizeof(name), (const char *)LOC(mage->faction->locale,
+    slprintf(name, sizeof(name), (const char *)LOC(mage->faction->locale,
         "clone_of"), unitname(mage));
     clone =
         create_unit(target_region, mage->faction, 1, get_race(RC_CLONE), 0, name,
@@ -4855,7 +4856,7 @@ int sp_sweetdreams(castorder * co)
             cmistake(mage, co->order, 40, MSG_EVENT);
             continue;
         }
-        men = _min(opfer, u->number);
+        men = MIN(opfer, u->number);
         opfer -= men;
 
         /* Nichts machen als ein entsprechendes Attribut an die Einheit legen. */
@@ -4969,7 +4970,7 @@ int sp_itemcloak(castorder * co)
     spellparameter *pa = co->par;
     int cast_level = co->level;
     double power = co->force;
-    int duration = (int)_max(2.0, power + 1);      /* works in the report, and ageing this round would kill it if it's <=1 */
+    int duration = (int)MAX(2.0, power + 1);      /* works in the report, and ageing this round would kill it if it's <=1 */
 
     /* wenn kein Ziel gefunden, Zauber abbrechen */
     if (pa->param[0]->flag == TARGET_NOTFOUND)
@@ -5027,7 +5028,7 @@ int sp_resist_magic_bonus(castorder * co)
 
         u = pa->param[n]->data.u;
 
-        m = _min(u->number, victims);
+        m = MIN(u->number, victims);
         victims -= m;
 
         create_curse(mage, &u->attribs, ct_find("magicresistance"),
@@ -5043,8 +5044,8 @@ int sp_resist_magic_bonus(castorder * co)
         msg_release(msg);
     }
 
-    cast_level = _min(cast_level, (int)(cast_level * (victims + 4) / maxvictims));
-    return _max(cast_level, 1);
+    cast_level = MIN(cast_level, (int)(cast_level * (victims + 4) / maxvictims));
+    return MAX(cast_level, 1);
 }
 
 /** spell 'Astraler Weg'.
@@ -5656,7 +5657,7 @@ int sp_showastral(castorder * co)
 
     free_regionlist(rl);
     return cast_level;
-    unused_arg(co);
+    UNUSED_ARG(co);
     return 0;
 }
 #endif
@@ -5907,7 +5908,7 @@ int sp_permtransfer(castorder * co)
         return 0;
     }
 
-    aura = _min(get_spellpoints(mage) - spellcost(mage, sp), aura);
+    aura = MIN(get_spellpoints(mage) - spellcost(mage, sp), aura);
 
     change_maxspellpoints(mage, -aura);
     change_spellpoints(mage, -aura);
@@ -6216,7 +6217,7 @@ int sp_speed2(castorder * co)
     spellparameter *pa = co->par;
 
     maxmen = 2 * cast_level * cast_level;
-    dur = _max(1, cast_level / 2);
+    dur = MAX(1, cast_level / 2);
 
     for (n = 0; n < pa->length; n++) {
         double effect;
@@ -6230,7 +6231,7 @@ int sp_speed2(castorder * co)
 
         u = pa->param[n]->data.u;
 
-        men = _min(maxmen, u->number);
+        men = MIN(maxmen, u->number);
         effect = 2;
         create_curse(mage, &u->attribs, ct_find("speed"), force, dur, effect, men);
         maxmen -= men;
@@ -6241,7 +6242,7 @@ int sp_speed2(castorder * co)
         "unit region amount", mage, mage->region, used));
     /* Effektiv benoetigten cast_level (mindestens 1) zurueckgeben */
     used = (int)sqrt(used / 2);
-    return _max(1, used);
+    return MAX(1, used);
 }
 
 /* ------------------------------------------------------------- */
@@ -6324,7 +6325,7 @@ int sp_q_antimagie(castorder * co)
         ADDMSG(&mage->faction->msgs, msg_message("destroy_magic_noeffect",
             "unit region command", mage, mage->region, co->order));
     }
-    return _max(succ, 1);
+    return MAX(succ, 1);
 }
 
 /* ------------------------------------------------------------- */
diff --git a/src/spells/borders.c b/src/spells/borders.c
index 04f7e15f4..00019e92c 100644
--- a/src/spells/borders.c
+++ b/src/spells/borders.c
@@ -206,7 +206,7 @@ struct region *from, struct region *to, bool routing)
     wall_data *fd = (wall_data *)b->data.v;
     if (!routing && fd->active) {
         int hp = dice(3, fd->force) * u->number;
-        hp = _min(u->hp, hp);
+        hp = MIN(u->hp, hp);
         u->hp -= hp;
         if (u->hp) {
             ADDMSG(&u->faction->msgs, msg_message("firewall_damage",
@@ -227,9 +227,9 @@ static const char *b_namefirewall(const connection * b, const region * r,
     const faction * f, int gflags)
 {
     const char *bname;
-    unused_arg(f);
-    unused_arg(r);
-    unused_arg(b);
+    UNUSED_ARG(f);
+    UNUSED_ARG(r);
+    UNUSED_ARG(b);
     if (gflags & GF_ARTICLE)
         bname = "a_firewall";
     else
diff --git a/src/spells/borders.h b/src/spells/borders.h
index 31823df94..b14661b9f 100644
--- a/src/spells/borders.h
+++ b/src/spells/borders.h
@@ -1,5 +1,8 @@
 #ifndef H_KRNL_CURSES
 #define H_KRNL_CURSES
+
+#include <stdbool.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/src/spells/buildingcurse.c b/src/spells/buildingcurse.c
index 01b0435ab..158383fd2 100644
--- a/src/spells/buildingcurse.c
+++ b/src/spells/buildingcurse.c
@@ -36,7 +36,7 @@ message *cinfo_building(const void *obj, objtype_t typ, const curse * c,
     int self)
 {
     const building *b = (const building *)obj;
-    unused_arg(typ);
+    UNUSED_ARG(typ);
     assert(typ == TYP_BUILDING);
     assert(obj);
     assert(c);
diff --git a/src/spells/combatspells.c b/src/spells/combatspells.c
index da7e7085a..0e1a27e75 100644
--- a/src/spells/combatspells.c
+++ b/src/spells/combatspells.c
@@ -337,14 +337,14 @@ int sp_combatrosthauch(struct castorder * co)
         if (force <= 0)
             break;
 
-        /* da n _min(force, x), sollte force maximal auf 0 sinken */
+        /* da n MIN(force, x), sollte force maximal auf 0 sinken */
         assert(force >= 0);
 
         if (df->weapons) {
             int w;
             for (w = 0; df->weapons[w].type != NULL; ++w) {
                 weapon *wp = df->weapons;
-                int n = _min(force, wp->used);
+                int n = MIN(force, wp->used);
                 if (n) {
                     requirement *mat = wp->type->itype->construction->materials;
                     bool iron = false;
@@ -921,7 +921,7 @@ int sp_shadowknights(struct castorder * co)
     region *r = b->region;
     unit *mage = fi->unit;
     attrib *a;
-    int force = _max(1, (int)get_force(power, 3));
+    int force = MAX(1, (int)get_force(power, 3));
     message *msg;
 
     u =
@@ -1015,7 +1015,7 @@ int sp_chaosrow(struct castorder * co)
             continue;
         if (power <= 0.0)
             break;
-        /* force sollte wegen des _max(0,x) nicht unter 0 fallen k�nnen */
+        /* force sollte wegen des MAX(0,x) nicht unter 0 fallen k�nnen */
 
         if (is_magic_resistant(mage, df->unit, 0))
             continue;
@@ -1050,7 +1050,7 @@ int sp_chaosrow(struct castorder * co)
             }
             k += df->alive;
         }
-        power = _max(0, power - n);
+        power = MAX(0, power - n);
     }
     ql_free(fgs);
 
@@ -1154,12 +1154,12 @@ int sp_hero(struct castorder * co)
     switch (sp->id) {
     case SPL_HERO:
         df_bonus = (int)(power / 5);
-        force = _max(1, lovar(get_force(power, 4)));
+        force = MAX(1, lovar(get_force(power, 4)));
         break;
 
     default:
         df_bonus = 1;
-        force = _max(1, (int)power);
+        force = MAX(1, (int)power);
     }
 
     allies =
@@ -1208,7 +1208,7 @@ int sp_berserk(struct castorder * co)
     switch (sp->id) {
     case SPL_BERSERK:
     case SPL_BLOODTHIRST:
-        at_bonus = _max(1, level / 3);
+        at_bonus = MAX(1, level / 3);
         df_malus = 2;
         force = (int)get_force(power, 2);
         break;
@@ -1264,7 +1264,7 @@ int sp_frighten(struct castorder * co)
     int targets = 0;
     message *m;
 
-    at_malus = _max(1, level - 4);
+    at_malus = MAX(1, level - 4);
     df_malus = 2;
     force = (int)get_force(power, 2);
 
@@ -1545,7 +1545,7 @@ int sp_fumbleshield(struct castorder * co)
     case SPL_CERDDOR_FUMBLESHIELD:
     case SPL_TYBIED_FUMBLESHIELD:
         duration = 100;
-        effect = _max(1, 25 - level);
+        effect = MAX(1, 25 - level);
         break;
 
     default:
@@ -1596,7 +1596,7 @@ int sp_reanimate(struct castorder * co)
     }
 
     healable = count_healable(b, fi);
-    healable = (int)_min(k, healable);
+    healable = (int)MIN(k, healable);
     while (healable--) {
         fighter *tf = select_corpse(b, fi);
         if (tf != NULL && tf->side->casualties > 0
@@ -1649,7 +1649,7 @@ int sp_keeploot(struct castorder * co)
     message_all(b, m);
     msg_release(m);
 
-    b->keeploot = (int)_max(25, b->keeploot + 5 * power);
+    b->keeploot = (int)MAX(25, b->keeploot + 5 * power);
 
     return level;
 }
@@ -1680,10 +1680,10 @@ static int heal_fighters(quicklist * fgs, int *power, bool heal_monsters)
                     ++wound;
 
                 if (wound > 0 && wound < hp) {
-                    int heal = _min(healhp, wound);
+                    int heal = MIN(healhp, wound);
                     assert(heal >= 0);
                     df->person[n].hp += heal;
-                    healhp = _max(0, healhp - heal);
+                    healhp = MAX(0, healhp - heal);
                     ++healed;
                     if (healhp <= 0)
                         break;
@@ -1834,7 +1834,7 @@ int sp_undeadhero(struct castorder * co)
     }
     ql_free(fgs);
 
-    level = _min(level, undead);
+    level = MIN(level, undead);
     if (undead == 0) {
         msg =
             msg_message("summonundead_effect_0", "mage region", mage, mage->region);
diff --git a/src/spells/flyingship.h b/src/spells/flyingship.h
index 8b7bf0874..52013ac13 100644
--- a/src/spells/flyingship.h
+++ b/src/spells/flyingship.h
@@ -3,6 +3,8 @@
 #ifndef FLYINGSHIP_H
 #define FLYINGSHIP_H
 
+#include <stdbool.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/src/spells/regioncurse.c b/src/spells/regioncurse.c
index 3d7593484..b10f3046f 100644
--- a/src/spells/regioncurse.c
+++ b/src/spells/regioncurse.c
@@ -45,8 +45,8 @@ static message *cinfo_cursed_by_the_gods(const void *obj, objtype_t typ,
 {
     region *r = (region *)obj;
 
-    unused_arg(typ);
-    unused_arg(self);
+    UNUSED_ARG(typ);
+    UNUSED_ARG(self);
     assert(typ == TYP_REGION);
 
     if (r->terrain->flags & SEA_REGION) {
@@ -68,9 +68,9 @@ static struct curse_type ct_godcursezone = {
 static message *cinfo_dreamcurse(const void *obj, objtype_t typ, const curse * c,
     int self)
 {
-    unused_arg(self);
-    unused_arg(typ);
-    unused_arg(obj);
+    UNUSED_ARG(self);
+    UNUSED_ARG(typ);
+    UNUSED_ARG(obj);
     assert(typ == TYP_REGION);
 
     if (c->effect > 0) {
@@ -94,9 +94,9 @@ static struct curse_type ct_gbdream = {
 static message *cinfo_magicstreet(const void *obj, objtype_t typ, const curse * c,
     int self)
 {
-    unused_arg(typ);
-    unused_arg(self);
-    unused_arg(obj);
+    UNUSED_ARG(typ);
+    UNUSED_ARG(self);
+    UNUSED_ARG(obj);
     assert(typ == TYP_REGION);
 
     /* Warnung vor Aufl�sung */
@@ -117,9 +117,9 @@ static struct curse_type ct_magicstreet = {
 static message *cinfo_antimagiczone(const void *obj, objtype_t typ, const curse * c,
     int self)
 {
-    unused_arg(typ);
-    unused_arg(self);
-    unused_arg(obj);
+    UNUSED_ARG(typ);
+    UNUSED_ARG(self);
+    UNUSED_ARG(obj);
     assert(typ == TYP_REGION);
 
     /* Magier sp�ren eine Antimagiezone */
@@ -139,7 +139,7 @@ const curse * c, int self)
     unit *u = NULL;
     unit *mage = c->magician;
 
-    unused_arg(typ);
+    UNUSED_ARG(typ);
 
     assert(typ == TYP_REGION);
     r = (region *)obj;
@@ -167,8 +167,8 @@ static struct curse_type ct_antimagiczone = {
 static message *cinfo_farvision(const void *obj, objtype_t typ, const curse * c,
     int self)
 {
-    unused_arg(typ);
-    unused_arg(obj);
+    UNUSED_ARG(typ);
+    UNUSED_ARG(obj);
 
     assert(typ == TYP_REGION);
 
diff --git a/src/spells/shipcurse.c b/src/spells/shipcurse.c
index 59cc534d4..b6a722ad3 100644
--- a/src/spells/shipcurse.c
+++ b/src/spells/shipcurse.c
@@ -38,8 +38,8 @@ message *cinfo_ship(const void *obj, objtype_t typ, const curse * c, int self)
 {
     message *msg;
 
-    unused_arg(typ);
-    unused_arg(obj);
+    UNUSED_ARG(typ);
+    UNUSED_ARG(obj);
     assert(typ == TYP_SHIP);
 
     if (self != 0) {              /* owner or inside */
@@ -62,7 +62,7 @@ static message *cinfo_shipnodrift(const void *obj, objtype_t typ, const curse *
 {
     ship *sh = (ship *)obj;
 
-    unused_arg(typ);
+    UNUSED_ARG(typ);
     assert(typ == TYP_SHIP);
 
     if (self != 0) {
diff --git a/src/spells/unitcurse.c b/src/spells/unitcurse.c
index 6e769145e..ded4a1676 100644
--- a/src/spells/unitcurse.c
+++ b/src/spells/unitcurse.c
@@ -46,7 +46,7 @@ static message *cinfo_auraboost(const void *obj, objtype_t typ, const curse * c,
     int self)
 {
     struct unit *u = (struct unit *)obj;
-    unused_arg(typ);
+    UNUSED_ARG(typ);
     assert(typ == TYP_UNIT);
 
     if (self != 0) {
@@ -80,7 +80,7 @@ static message *cinfo_slave(const void *obj, objtype_t typ, const curse * c,
     int self)
 {
     unit *u;
-    unused_arg(typ);
+    UNUSED_ARG(typ);
 
     assert(typ == TYP_UNIT);
     u = (unit *)obj;
@@ -104,7 +104,7 @@ cinfo_slave
 static message *cinfo_calm(const void *obj, objtype_t typ, const curse * c,
     int self)
 {
-    unused_arg(typ);
+    UNUSED_ARG(typ);
     assert(typ == TYP_UNIT);
 
     if (c->magician && c->magician->faction) {
@@ -133,7 +133,7 @@ static struct curse_type ct_calmmonster = {
 static message *cinfo_speed(const void *obj, objtype_t typ, const curse * c,
     int self)
 {
-    unused_arg(typ);
+    UNUSED_ARG(typ);
     assert(typ == TYP_UNIT);
 
     if (self != 0) {
@@ -156,7 +156,7 @@ static struct curse_type ct_speed = {
  */
 message *cinfo_unit(const void *obj, objtype_t typ, const curse * c, int self)
 {
-    unused_arg(typ);
+    UNUSED_ARG(typ);
     assert(typ == TYP_UNIT);
     assert(obj);
 
@@ -181,7 +181,7 @@ static struct curse_type ct_orcish = {
 static message *cinfo_kaelteschutz(const void *obj, objtype_t typ, const curse * c,
     int self)
 {
-    unused_arg(typ);
+    UNUSED_ARG(typ);
     assert(typ == TYP_UNIT);
 
     if (self != 0) {
@@ -233,7 +233,7 @@ static message *cinfo_sparkle(const void *obj, objtype_t typ, const curse * c,
     };
     int m, begin = 0, end = 0;
     unit *u;
-    unused_arg(typ);
+    UNUSED_ARG(typ);
 
     assert(typ == TYP_UNIT);
     u = (unit *)obj;
@@ -324,7 +324,7 @@ write_skill(struct storage *store, const curse * c, const void *target)
 static message *cinfo_skillmod(const void *obj, objtype_t typ, const curse * c,
     int self)
 {
-    unused_arg(typ);
+    UNUSED_ARG(typ);
 
     if (self != 0) {
         unit *u = (unit *)obj;
diff --git a/src/spy.c b/src/spy.c
index 22c548d68..a7d08d42e 100644
--- a/src/spy.c
+++ b/src/spy.c
@@ -148,7 +148,7 @@ int spy_cmd(unit * u, struct order *ord)
      * Fuer jeden Talentpunkt, den das Spionagetalent das Tarnungstalent
      * des Opfers uebersteigt, erhoeht sich dieses um 5%*/
     spy = effskill(u, SK_SPY, 0) - effskill(target, SK_STEALTH, r);
-    spychance = 0.1 + _max(spy * 0.05, 0.0);
+    spychance = 0.1 + MAX(spy * 0.05, 0.0);
 
     if (chance(spychance)) {
         produceexp(u, SK_SPY, u->number);
@@ -164,7 +164,7 @@ int spy_cmd(unit * u, struct order *ord)
         - (effskill(u, SK_STEALTH, 0) + effskill(u, SK_SPY, 0) / 2);
 
     if (invisible(u, target) >= u->number) {
-        observe = _min(observe, 0);
+        observe = MIN(observe, 0);
     }
 
     /* Anschliessend wird - unabhaengig vom Erfolg - gewuerfelt, ob der
@@ -354,7 +354,7 @@ static int top_skill(region * r, faction * f, ship * sh, skill_t sk)
     for (u = r->units; u; u = u->next) {
         if (u->ship == sh && u->faction == f) {
             int s = effskill(u, sk, 0);
-            value = _max(s, value);
+            value = MAX(s, value);
         }
     }
     return value;
diff --git a/src/sqlite.c b/src/sqlite.c
index 42bfdb3b5..aea0f5d20 100644
--- a/src/sqlite.c
+++ b/src/sqlite.c
@@ -94,9 +94,9 @@ read_factions(sqlite3 * db, int game_id) {
         text = (const char *)sqlite3_column_text(stmt, 1);
         if (text) dbf->no = atoi36(text);
         text = (const char *)sqlite3_column_text(stmt, 2);
-        if (text) dbf->name = _strdup(text);
+        if (text) dbf->name = strdup(text);
         text = (const char *)sqlite3_column_text(stmt, 3);
-        if (text) dbf->email = _strdup(text);
+        if (text) dbf->email = strdup(text);
         ql_push(&result, dbf);
         res = sqlite3_step(stmt);
     }
diff --git a/src/study.c b/src/study.c
index 58cd068f2..b69b4359f 100644
--- a/src/study.c
+++ b/src/study.c
@@ -201,7 +201,7 @@ teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk,
      * steigen.
      *
      * n ist die Anzahl zusaetzlich gelernter Tage. n darf max. die Differenz
-     * von schon gelernten Tagen zum _max(30 Tage pro Mann) betragen. */
+     * von schon gelernten Tagen zum MAX(30 Tage pro Mann) betragen. */
 
     if (magic_lowskill(student)) {
         cmistake(teacher, teacher->thisorder, 292, MSG_EVENT);
@@ -215,7 +215,7 @@ teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk,
         n -= teach->value;
     }
 
-    n = _min(n, nteaching);
+    n = MIN(n, nteaching);
 
     if (n != 0) {
         if (teach == NULL) {
@@ -267,7 +267,7 @@ teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk,
          * die Talentaenderung (enno).
          */
 
-        nteaching = _max(0, nteaching - student->number * 30);
+        nteaching = MAX(0, nteaching - student->number * 30);
 
     }
     return n;
@@ -303,7 +303,7 @@ int teach_cmd(unit * u, struct order *ord)
     teaching = u->number * 30 * TEACHNUMBER;
 
     if ((i = get_effect(u, oldpotiontype[P_FOOL])) > 0) { /* Trank "Dumpfbackenbrot" */
-        i = _min(i, u->number * TEACHNUMBER);
+        i = MIN(i, u->number * TEACHNUMBER);
         /* Trank wirkt pro Schueler, nicht pro Lehrer */
         teaching -= i * 30;
         change_effect(u, oldpotiontype[P_FOOL], -i);
@@ -604,7 +604,7 @@ int study_cmd(unit * u, order * ord)
     }
     /* Akademie: */
     if (active_building(u, bt_find("academy"))) {
-        studycost = _max(50, studycost * 2);
+        studycost = MAX(50, studycost * 2);
     }
 
     if (sk == SK_MAGIC) {
@@ -691,11 +691,11 @@ int study_cmd(unit * u, order * ord)
     if (studycost) {
         int cost = studycost * u->number;
         money = get_pooled(u, get_resourcetype(R_SILVER), GET_DEFAULT, cost);
-        money = _min(money, cost);
+        money = MIN(money, cost);
     }
     if (money < studycost * u->number) {
         studycost = p;              /* Ohne Univertreurung */
-        money = _min(money, studycost);
+        money = MIN(money, studycost);
         if (p > 0 && money < studycost * u->number) {
             cmistake(u, ord, 65, MSG_EVENT);
             multi = money / (double)(studycost * u->number);
@@ -715,12 +715,12 @@ int study_cmd(unit * u, order * ord)
     }
 
     if (get_effect(u, oldpotiontype[P_WISE])) {
-        l = _min(u->number, get_effect(u, oldpotiontype[P_WISE]));
+        l = MIN(u->number, get_effect(u, oldpotiontype[P_WISE]));
         teach->value += l * 10;
         change_effect(u, oldpotiontype[P_WISE], -l);
     }
     if (get_effect(u, oldpotiontype[P_FOOL])) {
-        l = _min(u->number, get_effect(u, oldpotiontype[P_FOOL]));
+        l = MIN(u->number, get_effect(u, oldpotiontype[P_FOOL]));
         teach->value -= l * 30;
         change_effect(u, oldpotiontype[P_FOOL], -l);
     }
diff --git a/src/summary.c b/src/summary.c
index 8a3ee3c41..32416a263 100644
--- a/src/summary.c
+++ b/src/summary.c
@@ -97,8 +97,8 @@ int update_nmrs(void)
             if (timeout>0) {
                 if (nmr < 0 || nmr > timeout) {
                     log_error("faction %s has %d NMR", itoa36(f->no), nmr);
-                    nmr = _max(0, nmr);
-                    nmr = _min(nmr, timeout);
+                    nmr = MAX(0, nmr);
+                    nmr = MIN(nmr, timeout);
                 }
                 if (nmr > 0) {
                     log_debug("faction %s has %d NMR", itoa36(f->no), nmr);
@@ -164,7 +164,7 @@ static char *gamedate2(const struct locale *lang)
 
 static void writeturn(void)
 {
-    char zText[MAX_PATH];
+    char zText[4096];
     FILE *f;
 
     join_path(basepath(), "datum", zText, sizeof(zText));
@@ -190,7 +190,7 @@ void report_summary(summary * s, summary * o, bool full)
     FILE *F = NULL;
     int i, newplayers = 0;
     faction *f;
-    char zText[MAX_PATH];
+    char zText[4096];
     int timeout = NMRTimeout();
 
     if (full) {
diff --git a/src/test_eressea.c b/src/test_eressea.c
index 6d2dead3f..02d52c5ed 100644
--- a/src/test_eressea.c
+++ b/src/test_eressea.c
@@ -33,7 +33,7 @@ static void add_suite(CuSuite *(*csuite)(void), const char *name, int argc, char
     }
     if (s) {
         s->next = suites;
-        s->name = _strdup(name);
+        s->name = strdup(name);
         s->csuite = csuite();
         suites = s;
     }
diff --git a/src/travelthru.test.c b/src/travelthru.test.c
index be87743d2..09d807674 100644
--- a/src/travelthru.test.c
+++ b/src/travelthru.test.c
@@ -15,7 +15,7 @@ struct attrib;
 
 static void count_travelers(region *r, unit *u, void *cbdata) {
     int *n = (int *)cbdata;
-    unused_arg(r);
+    UNUSED_ARG(r);
     *n += u->number;
 }
 
diff --git a/src/triggers/changefaction.c b/src/triggers/changefaction.c
index 37d993f4a..3de537c7b 100644
--- a/src/triggers/changefaction.c
+++ b/src/triggers/changefaction.c
@@ -70,7 +70,7 @@ static int changefaction_handle(trigger * t, void *data)
     else {
         log_error("could not perform changefaction::handle()\n");
     }
-    unused_arg(data);
+    UNUSED_ARG(data);
     return 0;
 }
 
diff --git a/src/triggers/changerace.c b/src/triggers/changerace.c
index f38b7f3d5..a9f282698 100644
--- a/src/triggers/changerace.c
+++ b/src/triggers/changerace.c
@@ -74,7 +74,7 @@ static int changerace_handle(trigger * t, void *data)
     else {
         log_error("could not perform changerace::handle()\n");
     }
-    unused_arg(data);
+    UNUSED_ARG(data);
     return 0;
 }
 
diff --git a/src/triggers/clonedied.c b/src/triggers/clonedied.c
index 642b50ab0..f3d1fc00b 100644
--- a/src/triggers/clonedied.c
+++ b/src/triggers/clonedied.c
@@ -58,7 +58,7 @@ static int clonedied_handle(trigger * t, void *data)
     }
     else
         log_error("could not perform clonedied::handle()\n");
-    unused_arg(data);
+    UNUSED_ARG(data);
     return 0;
 }
 
diff --git a/src/triggers/createcurse.c b/src/triggers/createcurse.c
index 040a4e7b7..3eb0891ca 100644
--- a/src/triggers/createcurse.c
+++ b/src/triggers/createcurse.c
@@ -76,7 +76,7 @@ static int createcurse_handle(trigger * t, void *data)
     else {
         log_error("could not perform createcurse::handle()\n");
     }
-    unused_arg(data);
+    UNUSED_ARG(data);
     return 0;
 }
 
diff --git a/src/triggers/createunit.c b/src/triggers/createunit.c
index 5952c88bc..41573d86b 100644
--- a/src/triggers/createunit.c
+++ b/src/triggers/createunit.c
@@ -74,7 +74,7 @@ static int createunit_handle(trigger * t, void *data)
     else {
         log_error("could not perform createunit::handle()\n");
     }
-    unused_arg(data);
+    UNUSED_ARG(data);
     return 0;
 }
 
diff --git a/src/triggers/gate.c b/src/triggers/gate.c
index e681efc04..c70163a14 100644
--- a/src/triggers/gate.c
+++ b/src/triggers/gate.c
@@ -57,7 +57,7 @@ static int gate_handle(trigger * t, void *data)
         log_error("could not perform gate::handle()\n");
         return -1;
     }
-    unused_arg(data);
+    UNUSED_ARG(data);
     return 0;
 }
 
diff --git a/src/triggers/giveitem.c b/src/triggers/giveitem.c
index 6b0e8f8c7..9bc2c56e1 100644
--- a/src/triggers/giveitem.c
+++ b/src/triggers/giveitem.c
@@ -70,7 +70,7 @@ static int giveitem_handle(trigger * t, void *data)
     else {
         log_error("could not perform giveitem::handle()\n");
     }
-    unused_arg(data);
+    UNUSED_ARG(data);
     return 0;
 }
 
diff --git a/src/triggers/killunit.c b/src/triggers/killunit.c
index 22ad27896..3e6c9defe 100644
--- a/src/triggers/killunit.c
+++ b/src/triggers/killunit.c
@@ -48,7 +48,7 @@ static int killunit_handle(trigger * t, void *data)
         /* we can't remove_unit() here, because that's what's calling us. */
         set_number(u, 0);
     }
-    unused_arg(data);
+    UNUSED_ARG(data);
     return 0;
 }
 
diff --git a/src/triggers/shock.c b/src/triggers/shock.c
index 7c54676e0..31424e979 100644
--- a/src/triggers/shock.c
+++ b/src/triggers/shock.c
@@ -60,8 +60,8 @@ static void do_shock(unit * u, const char *reason)
     if (u->number > 0) {
         /* HP - Verlust */
         int hp = (unit_max_hp(u) * u->number) / 10;
-        hp = _min(u->hp, hp);
-        u->hp = _max(1, hp);
+        hp = MIN(u->hp, hp);
+        u->hp = MAX(1, hp);
     }
 
     /* Aura - Verlust */
@@ -102,7 +102,7 @@ static int shock_handle(trigger * t, void *data)
     if (u && u->number) {
         do_shock(u, "trigger");
     }
-    unused_arg(data);
+    UNUSED_ARG(data);
     return 0;
 }
 
diff --git a/src/triggers/timeout.c b/src/triggers/timeout.c
index 10e4d08be..43bb061c8 100644
--- a/src/triggers/timeout.c
+++ b/src/triggers/timeout.c
@@ -61,7 +61,7 @@ static int timeout_handle(trigger * t, void *data)
         handle_triggers(&td->triggers, NULL);
         return -1;
     }
-    unused_arg(data);
+    UNUSED_ARG(data);
     return 0;
 }
 
diff --git a/src/triggers/unitmessage.c b/src/triggers/unitmessage.c
index 0c1e80124..7ba97d9bc 100644
--- a/src/triggers/unitmessage.c
+++ b/src/triggers/unitmessage.c
@@ -71,7 +71,7 @@ static int unitmessage_handle(trigger * t, void *data)
                 td->level);
         }
     }
-    unused_arg(data);
+    UNUSED_ARG(data);
     return 0;
 }
 
@@ -92,7 +92,7 @@ static int unitmessage_read(trigger * t, gamedata *data)
     int result = read_reference(&td->target, data, read_unit_reference,
         resolve_unit);
     READ_TOK(data->store, zText, sizeof(zText));
-    td->string = _strdup(zText);
+    td->string = strdup(zText);
     READ_INT(data->store, &td->type);
     READ_INT(data->store, &td->level);
 
@@ -117,7 +117,7 @@ trigger *trigger_unitmessage(unit * target, const char *string, int type,
     trigger *t = t_new(&tt_unitmessage);
     unitmessage_data *td = (unitmessage_data *)t->data.v;
     td->target = target;
-    td->string = _strdup(string);
+    td->string = strdup(string);
     td->type = type;
     td->level = level;
     return t;
diff --git a/src/upkeep.c b/src/upkeep.c
index 1cf41011f..94cbc341d 100644
--- a/src/upkeep.c
+++ b/src/upkeep.c
@@ -47,7 +47,7 @@ static void help_feed(unit * donor, unit * u, int *need_p)
 {
     int need = *need_p;
     int give = get_money(donor) - lifestyle(donor);
-    give = _min(need, give);
+    give = MIN(need, give);
 
     if (give > 0) {
         change_money(donor, -give);
@@ -161,7 +161,7 @@ void get_food(region * r)
             * food from the peasants - should not be used with WORK */
             if (owner != NULL && (get_alliance(owner, u->faction) & HELP_MONEY)) {
                 int rm = rmoney(r);
-                int use = _min(rm, need);
+                int use = MIN(rm, need);
                 rsetmoney(r, rm - use);
                 need -= use;
             }
@@ -174,7 +174,7 @@ void get_food(region * r)
             for (v = r->units; need && v; v = v->next) {
                 if (v->faction == u->faction && help_money(v)) {
                     int give = get_money(v) - lifestyle(v);
-                    give = _min(need, give);
+                    give = MIN(need, give);
                     if (give > 0) {
                         change_money(v, -give);
                         change_money(u, give);
@@ -191,7 +191,7 @@ void get_food(region * r)
         int need = lifestyle(u);
         faction *f = u->faction;
 
-        need -= _max(0, get_money(u));
+        need -= MAX(0, get_money(u));
 
         if (need > 0) {
             unit *v;
@@ -247,7 +247,7 @@ void get_food(region * r)
                 unit *donor = u;
                 while (donor != NULL && hungry > 0) {
                     int blut = get_effect(donor, pt_blood);
-                    blut = _min(blut, hungry);
+                    blut = MIN(blut, hungry);
                     if (blut) {
                         change_effect(donor, pt_blood, -blut);
                         hungry -= blut;
@@ -295,7 +295,7 @@ void get_food(region * r)
 
     /* 3. Von den �berlebenden das Geld abziehen: */
     for (u = r->units; u; u = u->next) {
-        int need = _min(get_money(u), lifestyle(u));
+        int need = MIN(get_money(u), lifestyle(u));
         change_money(u, -need);
     }
 }
diff --git a/src/util/attrib.c b/src/util/attrib.c
index 4bdf35bfa..a99a70ba3 100644
--- a/src/util/attrib.c
+++ b/src/util/attrib.c
@@ -124,7 +124,7 @@ int a_readstring(attrib * a, void *owner, struct gamedata *data)
             len += DISPLAYSIZE - 1;
         }
         else {
-            result = _strdup(buf);
+            result = strdup(buf);
         }
     } while (e == ENOMEM);
     a->data.v = result;
diff --git a/src/util/attrib.h b/src/util/attrib.h
index d93ce1240..45dc9b942 100644
--- a/src/util/attrib.h
+++ b/src/util/attrib.h
@@ -19,6 +19,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #ifndef ATTRIB_H
 #define ATTRIB_H
 
+#include <stdbool.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/src/util/attrib.test.c b/src/util/attrib.test.c
index 7fa2ef82c..b44afeec2 100644
--- a/src/util/attrib.test.c
+++ b/src/util/attrib.test.c
@@ -119,7 +119,7 @@ static void test_attrib_rwstring(CuTest *tc) {
     attrib a = { 0 };
 
     test_setup();
-    a.data.v = _strdup("Hello World");
+    a.data.v = strdup("Hello World");
     mstream_init(&data.strm);
     gamedata_init(&data, &store, RELEASE_VERSION);
     a_writestring(&a, NULL, &store);
diff --git a/src/util/crmessage.c b/src/util/crmessage.c
index 98afe0f05..47bb6bf7d 100644
--- a/src/util/crmessage.c
+++ b/src/util/crmessage.c
@@ -145,21 +145,21 @@ int cr_render(const message * msg, char *buffer, const void *userdata)
 int cr_string(variant var, char *buffer, const void *userdata)
 {
     sprintf(buffer, "\"%s\"", (const char *)var.v);
-    unused_arg(userdata);
+    UNUSED_ARG(userdata);
     return 0;
 }
 
 int cr_int(variant var, char *buffer, const void *userdata)
 {
     sprintf(buffer, "%d", var.i);
-    unused_arg(userdata);
+    UNUSED_ARG(userdata);
     return 0;
 }
 
 int cr_ignore(variant var, char *buffer, const void *userdata)
 {
-    unused_arg(var);
-    unused_arg(buffer);
-    unused_arg(userdata);
+    UNUSED_ARG(var);
+    UNUSED_ARG(buffer);
+    UNUSED_ARG(userdata);
     return -1;
 }
diff --git a/src/util/event.c b/src/util/event.c
index cdf178aec..78a6d6fbc 100644
--- a/src/util/event.c
+++ b/src/util/event.c
@@ -153,7 +153,7 @@ static int read_handler(attrib * a, void *owner, gamedata *data)
     handler_info *hi = (handler_info *)a->data.v;
 
     READ_TOK(store, zText, sizeof(zText));
-    hi->event = _strdup(zText);
+    hi->event = strdup(zText);
     read_triggers(data, &hi->triggers);
     if (hi->triggers != NULL) {
         return AT_READ_OK;
@@ -200,7 +200,7 @@ void add_trigger(struct attrib **ap, const char *eventname, struct trigger *t)
     if (a == NULL || a->type != &at_eventhandler) {
         a = a_add(ap, a_new(&at_eventhandler));
         td = (handler_info *)a->data.v;
-        td->event = _strdup(eventname);
+        td->event = strdup(eventname);
     }
     tp = &td->triggers;
     while (*tp)
diff --git a/src/util/goodies.c b/src/util/goodies.c
index 2444d0f47..c478bcf83 100644
--- a/src/util/goodies.c
+++ b/src/util/goodies.c
@@ -113,7 +113,7 @@ int set_email(char **pemail, const char *newmail)
         free(*pemail);
     *pemail = 0;
     if (newmail) {
-        *pemail = _strdup(newmail);
+        *pemail = strdup(newmail);
     }
     return 0;
 }
diff --git a/src/util/language.c b/src/util/language.c
index cb91d7419..efd5cd5f7 100644
--- a/src/util/language.c
+++ b/src/util/language.c
@@ -86,7 +86,7 @@ locale *get_or_create_locale(const char *name)
     *lp = l = (locale *)calloc(sizeof(locale), 1);
     assert_alloc(l);
     l->hashkey = hkey;
-    l->name = _strdup(name);
+    l->name = strdup(name);
     l->index = nextlocaleindex++;
     assert(nextlocaleindex <= MAXLOCALES);
     if (default_locale == NULL) default_locale = l;
@@ -209,15 +209,15 @@ void locale_setstring(locale * lang, const char *key, const char *value)
         find->nexthash = lang->strings[id];
         lang->strings[id] = find;
         find->hashkey = hkey;
-        find->key = _strdup(key);
-        find->str = _strdup(value);
+        find->key = strdup(key);
+        find->str = strdup(value);
     }
     else {
         if (strcmp(find->str, value) != 0) {
             log_warning("multiple translations for key %s\n", key);
         }
         free(find->str);
-        find->str = _strdup(value);
+        find->str = strdup(value);
     }
 }
 
diff --git a/src/util/language.h b/src/util/language.h
index a90398cc0..36bc58378 100644
--- a/src/util/language.h
+++ b/src/util/language.h
@@ -19,7 +19,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #ifndef MY_LOCALE_H
 #define MY_LOCALE_H
 
-#include <platform.h>
+#include <stdbool.h>
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/src/util/lists.c b/src/util/lists.c
index d61327fa0..be3deeffd 100644
--- a/src/util/lists.c
+++ b/src/util/lists.c
@@ -127,7 +127,7 @@ void addstrlist(strlist ** SP, const char *s)
 {
     strlist *slist = malloc(sizeof(strlist));
     slist->next = NULL;
-    slist->s = _strdup(s);
+    slist->s = strdup(s);
     addlist(SP, slist);
 }
 
diff --git a/src/util/log.test.c b/src/util/log.test.c
index 55616c026..1558ee3e3 100644
--- a/src/util/log.test.c
+++ b/src/util/log.test.c
@@ -9,9 +9,9 @@
 void log_string(void *data, int level, const char *module, const char *format, va_list args) {
     char *str = (char *)data;
     const char *arg = va_arg(args, const char *);
-    unused_arg(format);
-    unused_arg(module);
-    unused_arg(level);
+    UNUSED_ARG(format);
+    UNUSED_ARG(module);
+    UNUSED_ARG(level);
     strcpy(str, arg);
 }
 
diff --git a/src/util/message.c b/src/util/message.c
index 5b6f12eb8..b5a9592bd 100644
--- a/src/util/message.c
+++ b/src/util/message.c
@@ -73,7 +73,7 @@ message_type *mt_new(const char *name, const char *args[])
         while (args[nparameters]) ++nparameters;
     }
     mtype->key = 0;
-    mtype->name = _strdup(name);
+    mtype->name = strdup(name);
     mtype->nparameters = nparameters;
     if (nparameters > 0) {
         mtype->pnames = (char **)malloc(sizeof(char *) * nparameters);
diff --git a/src/util/nrmessage.c b/src/util/nrmessage.c
index e3b0bcc0b..8156b9784 100644
--- a/src/util/nrmessage.c
+++ b/src/util/nrmessage.c
@@ -91,7 +91,7 @@ const nrsection *section_add(const char *name)
     }
     if (!*mcp) {
         nrsection *mc = calloc(sizeof(nrsection), 1);
-        mc->name = _strdup(name);
+        mc->name = strdup(name);
         *mcp = mc;
     }
     return *mcp;
@@ -130,14 +130,14 @@ const char *string, int level, const char *section)
             nrt->section = NULL;
         nrtypes[hash] = nrt;
         assert(string && *string);
-        nrt->string = _strdup(string);
+        nrt->string = strdup(string);
         *c = '\0';
         for (i = 0; i != mtype->nparameters; ++i) {
             if (i != 0)
                 *c++ = ' ';
             c += strlcpy(c, mtype->pnames[i], sizeof(zNames)-(c-zNames));
         }
-        nrt->vars = _strdup(zNames);
+        nrt->vars = strdup(zNames);
     }
 }
 
diff --git a/src/util/translation.c b/src/util/translation.c
index 829a1fe05..b0933d322 100644
--- a/src/util/translation.c
+++ b/src/util/translation.c
@@ -414,7 +414,7 @@ static void eval_lt(opstack ** stack, const void *userdata)
     int b = opop_i(stack);
     int rval = (b < a) ? 1 : 0;
     opush_i(stack, rval);
-    unused_arg(userdata);
+    UNUSED_ARG(userdata);
 }
 
 static void eval_eq(opstack ** stack, const void *userdata)
@@ -423,7 +423,7 @@ static void eval_eq(opstack ** stack, const void *userdata)
     int b = opop_i(stack);
     int rval = (a == b) ? 1 : 0;
     opush_i(stack, rval);
-    unused_arg(userdata);
+    UNUSED_ARG(userdata);
 }
 
 static void eval_add(opstack ** stack, const void *userdata)
@@ -431,14 +431,14 @@ static void eval_add(opstack ** stack, const void *userdata)
     int a = opop_i(stack);
     int b = opop_i(stack);
     opush_i(stack, a + b);
-    unused_arg(userdata);
+    UNUSED_ARG(userdata);
 }
 
 static void eval_isnull(opstack ** stack, const void *userdata)
 {                               /* (int, int) -> int */
     void *a = opop_v(stack);
     opush_i(stack, (a == NULL) ? 1 : 0);
-    unused_arg(userdata);
+    UNUSED_ARG(userdata);
 }
 
 static void eval_if(opstack ** stack, const void *userdata)
@@ -447,14 +447,14 @@ static void eval_if(opstack ** stack, const void *userdata)
     void *b = opop_v(stack);
     int cond = opop_i(stack);
     opush_v(stack, cond ? b : a);
-    unused_arg(userdata);
+    UNUSED_ARG(userdata);
 }
 
 static void eval_strlen(opstack ** stack, const void *userdata)
 {                               /* string -> int */
     const char *c = (const char *)opop_v(stack);
     opush_i(stack, c ? (int)strlen(c) : 0);
-    unused_arg(userdata);
+    UNUSED_ARG(userdata);
 }
 
 #include "base36.h"
diff --git a/src/vortex.c b/src/vortex.c
index 725460ce2..7b6206d03 100644
--- a/src/vortex.c
+++ b/src/vortex.c
@@ -70,7 +70,7 @@ static void a_freedirection(attrib * a)
 static int a_agedirection(attrib * a, void *owner)
 {
     spec_direction *d = (spec_direction *)(a->data.v);
-    unused_arg(owner);
+    (void)owner;
     --d->duration;
     return (d->duration > 0) ? AT_AGE_KEEP : AT_AGE_REMOVE;
 }
@@ -81,14 +81,14 @@ static int a_readdirection(attrib * a, void *owner, struct gamedata *data)
     spec_direction *d = (spec_direction *)(a->data.v);
     char lbuf[32];
 
-    unused_arg(owner);
+    (void)owner;
     READ_INT(store, &d->x);
     READ_INT(store, &d->y);
     READ_INT(store, &d->duration);
     READ_TOK(store, lbuf, sizeof(lbuf));
-    d->desc = _strdup(lbuf);
+    d->desc = strdup(lbuf);
     READ_TOK(store, lbuf, sizeof(lbuf));
-    d->keyword = _strdup(lbuf);
+    d->keyword = strdup(lbuf);
     d->active = true;
     return AT_READ_OK;
 }
@@ -98,7 +98,7 @@ a_writedirection(const attrib * a, const void *owner, struct storage *store)
 {
     spec_direction *d = (spec_direction *)(a->data.v);
 
-    unused_arg(owner);
+    (void)owner;
     WRITE_INT(store, d->x);
     WRITE_INT(store, d->y);
     WRITE_INT(store, d->duration);
@@ -143,8 +143,8 @@ attrib *create_special_direction(region * r, region * rt, int duration,
     d->x = rt->x;
     d->y = rt->y;
     d->duration = duration;
-    d->desc = _strdup(desc);
-    d->keyword = _strdup(keyword);
+    d->desc = strdup(desc);
+    d->keyword = strdup(keyword);
 
     return a;
 }
diff --git a/src/vortex.h b/src/vortex.h
index af41b6111..993f5cdab 100644
--- a/src/vortex.h
+++ b/src/vortex.h
@@ -1,5 +1,10 @@
+#pragma once
+
 #ifndef H_VORTEX
 #define H_VORTEX
+
+#include <stdbool.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/src/wormhole.c b/src/wormhole.c
index 6a115a9f7..46425a0c1 100644
--- a/src/wormhole.c
+++ b/src/wormhole.c
@@ -63,7 +63,7 @@ static int wormhole_age(struct attrib *a, void *owner)
     region *r = entry->region;
     unit *u = r->units;
 
-    unused_arg(owner);
+    UNUSED_ARG(owner);
     for (; u != NULL && maxtransport != 0; u = u->next) {
         if (u->building == entry) {
             message *m = NULL;