diff --git a/CMakeLists.txt b/CMakeLists.txt
index 77e6c18..9d4b1c5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,6 +10,7 @@ option(WINDOWS "Whether the build target is Windows or not." OFF)
 option(SHARED "Whether we should build a shared library, instead of a static one." OFF)
 option(TESTS "Whether the test executable should be build as well." OFF)
 option(STATICC "Whether gcc and stdc++ should be linked statically to the library." OFF)
+option(PRETTYTRACES "Whether full stacktraces should be included. Note that this adds a dependency to libdw." ON)
 
 # Set whether we want a static or shared library.
 set(LIBTYPE STATIC)
@@ -47,8 +48,9 @@ if (WINDOWS)
 endif (WINDOWS)
 
 set(LINKS)
-if (NOT WINDOWS)
+if (NOT WINDOWS AND PRETTYTRACES)
     set(LINKS ${LINKS} -ldw)
+    ADD_DEFINITIONS(-DPRETTYTRACES=1)
 endif()
 # If we want to link the C and C++ library statically, link those as well.
 if (STATICC)
diff --git a/src/Exception.hpp b/src/Exception.hpp
index 5562f00..d77046e 100644
--- a/src/Exception.hpp
+++ b/src/Exception.hpp
@@ -6,7 +6,9 @@
 #include <string>
 #include <utility>
 #if !WINDOWS
+#if PRETTYTRACES
 #define BACKWARD_HAS_DW 1
+#endif
 #include "../extern/backward.hpp"
 #endif
 
@@ -53,6 +55,9 @@ namespace ArbUt {
                 backward::ResolvedTrace trace = tr.resolve(_stack[i]);
                 if (trace.source.filename.empty()) {
                     AppendNoSourceStack(ss, trace, include_addr);
+                    if (foundExceptionClass) {
+                        framesAppended++;
+                    }
                 } else {
                     AppendSourceStack(ss, trace.source, foundExceptionClass, snippetFactory);
                     if (foundExceptionClass) {