--- contrib/bobtoolz/DPatch.cpp.orig	2013-06-30 14:04:35 UTC
+++ contrib/bobtoolz/DPatch.cpp
@@ -302,7 +302,7 @@ DPatch* DPatch::MergePatches( patch_merge_t merge_info
 
 	int newHeight = p1->height + p2->height - 1;
 	if ( newHeight > MAX_PATCH_HEIGHT ) {
-		return false;
+		return NULL;
 	}
 
 	DPatch* newPatch = new DPatch();
--- contrib/bobtoolz/DTreePlanter.h.orig	2013-06-30 14:04:35 UTC
+++ contrib/bobtoolz/DTreePlanter.h
@@ -20,6 +20,8 @@
 #ifndef __DTREE_H__
 #define __DTREE_H__
 
+#include <stdlib.h>
+
 #include "qerplugin.h"
 #include "signal/isignal.h"
 #include "string/string.h"
--- contrib/bobtoolz/dialogs/dialogs-gtk.cpp.orig	2013-06-30 14:04:35 UTC
+++ contrib/bobtoolz/dialogs/dialogs-gtk.cpp
@@ -22,6 +22,7 @@
 
 #include "str.h"
 #include <list>
+#include <stdlib.h>
 #include <gtk/gtk.h>
 #include "gtkutil/pointer.h"
 
--- contrib/bobtoolz/misc.cpp.orig	2013-06-30 14:04:35 UTC
+++ contrib/bobtoolz/misc.cpp
@@ -31,7 +31,7 @@
 
 #include "funchandlers.h"
 
-#ifdef __linux__
+#if defined (__linux__) || defined(__FreeBSD__)
 #include <sys/types.h>
 #include <unistd.h>
 #endif
--- contrib/bobtoolz/shapes.cpp.orig	2013-06-30 14:04:35 UTC
+++ contrib/bobtoolz/shapes.cpp
@@ -40,6 +40,7 @@
 #include <list>
 #include <map>
 #include <algorithm>
+#include <stdlib.h>
 #include <time.h>
 
 #include "scenelib.h"
--- contrib/bobtoolz/visfind.cpp.orig	2013-06-30 14:04:35 UTC
+++ contrib/bobtoolz/visfind.cpp
@@ -8,6 +8,7 @@
 #include "bsploader.h"
 
 #include <list>
+#include <stdlib.h>
 
 typedef struct {
 	int portalclusters;
--- contrib/sunplug/sunplug.cpp.orig	2013-06-30 14:04:35 UTC
+++ contrib/sunplug/sunplug.cpp
@@ -35,6 +35,7 @@
 #include "qerplugin.h"   // declaration to use other interfaces as a plugin
 
 #include <gtk/gtk.h>     // to display something with gtk (windows, buttons etc.), the whole package might not be necessary
+#include <stdlib.h>
 
 void about_plugin_window();
 void MapCoordinator();
--- contrib/ufoaiplug/ufoai_level.cpp.orig	2013-06-30 14:04:35 UTC
+++ contrib/ufoaiplug/ufoai_level.cpp
@@ -25,6 +25,7 @@
 
 #include "string/string.h"
 #include <list>
+#include <stdlib.h>
 
 class Level;
 
--- libs/cmdlib/cmdlib.cpp.orig	2013-06-30 14:04:34 UTC
+++ libs/cmdlib/cmdlib.cpp
@@ -27,6 +27,7 @@
 
 #include <string.h>
 #include <stdio.h>
+#include <stdlib.h>
 
 #include "string/string.h"
 #include "os/path.h"
--- libs/scenelib.h.orig	2013-06-30 14:04:34 UTC
+++ libs/scenelib.h
@@ -32,7 +32,6 @@
 #include "math/aabb.h"
 #include "transformlib.h"
 #include "generic/callback.h"
-#include "generic/reference.h"
 #include "container/stack.h"
 #include "typesystem.h"
 
@@ -286,6 +285,7 @@ inline bool operator!=( scene::Node& node, scene::Node
 	return !::operator==( node, other );
 }
 
+#include "generic/reference.h"
 
 inline scene::Node& NewNullNode(){
 	return ( new scene::NullNode )->node();
--- plugins/mapq3/parse.h.orig	2013-06-30 14:04:35 UTC
+++ plugins/mapq3/parse.h
@@ -40,6 +40,7 @@ namespace scene
 class Node;
 }
 
+#include "scenelib.h"
 #include "generic/referencecounted.h"
 typedef SmartReference<scene::Node, IncRefDecRefCounter<scene::Node> > NodeSmartReference;
 
--- radiant/texwindow.cpp.orig	2013-06-30 14:04:35 UTC
+++ radiant/texwindow.cpp
@@ -1880,7 +1880,7 @@ void TextureBrowser_SetNotex(){
 	name << GlobalRadiant().getAppPath() << "bitmaps/notex.png";
 	g_notex = name.c_str();
 
-	name = NULL;
+	name.clear();
 	name << GlobalRadiant().getAppPath() << "bitmaps/shadernotex.png";
 	g_shadernotex = name.c_str();
 }
