diff --git a/app/assets/javascripts/dtu_core/client_debug.js b/app/assets/javascripts/dtu_core/client_debug.js
index 6e2fe15aebc52863cc0f0473a16ad8cc0dc5c478..fa509162dca0a767bd49ee587fb326fa5bd2d308 100644
--- a/app/assets/javascripts/dtu_core/client_debug.js
+++ b/app/assets/javascripts/dtu_core/client_debug.js
@@ -12,10 +12,14 @@ var ClientDebug = {
       message: message
     };
 
+    var json = stringifySafe(packet, null, 2)
+
     $.ajax({
         method: "PUT",
         url: ClientDebug.resource_url,
-        data: JSON.stringify(packet, null, 2)
+        contentType: "application/json; charset=utf-8",
+        dataType: 'json',
+        data: json
       })
       .done(function(data, textStatus, jqXHR) {
         console.log("client log: success")
diff --git a/app/assets/javascripts/dtu_core/json-stringify-safe.js b/app/assets/javascripts/dtu_core/json-stringify-safe.js
new file mode 100644
index 0000000000000000000000000000000000000000..a2f2a6a4d349f547e8bd678e277b918535760531
--- /dev/null
+++ b/app/assets/javascripts/dtu_core/json-stringify-safe.js
@@ -0,0 +1,28 @@
+// from https://github.com/isaacs/json-stringify-safe/blob/02cfafd45f06d076ac4bf0dd28be6738a07a72f9/stringify.js#L4
+// per http://stackoverflow.com/questions/11616630/json-stringify-avoid-typeerror-converting-circular-structure-to-json
+// to avoid circular refs error when logging mathjax errors
+
+function stringifySafe(obj, replacer, spaces, cycleReplacer) {
+  return JSON.stringify(obj, serializerSafe(replacer, cycleReplacer), spaces)
+}
+
+function serializerSafe(replacer, cycleReplacer) {
+  var stack = [],
+    keys = []
+
+  if (cycleReplacer == null) cycleReplacer = function(key, value) {
+    if (stack[0] === value) return "[Circular ~]"
+    return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]"
+  }
+
+  return function(key, value) {
+    if (stack.length > 0) {
+      var thisPos = stack.indexOf(this);
+      ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
+      ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
+      if (~stack.indexOf(value)) value = cycleReplacer.call(this, key, value);
+    } else stack.push(value)
+
+    return replacer == null ? value : replacer.call(this, key, value)
+  }
+}
\ No newline at end of file
diff --git a/app/assets/javascripts/dtu_core/report_a_bug.coffee b/app/assets/javascripts/dtu_core/report_a_bug.coffee
index b1f5c1adebaa5a7c099cfd79c7b72652b1c45513..61658640be6e4f7501da5f3fc61b37262e37cece 100644
--- a/app/assets/javascripts/dtu_core/report_a_bug.coffee
+++ b/app/assets/javascripts/dtu_core/report_a_bug.coffee
@@ -19,9 +19,10 @@ window.onerror = (msg, url, lineNo, columnNo, error) ->
 
 do ->
   kinds = ['log', 'warn', 'error', 'info']
+  window._CONSOLE = {}
   for kind in kinds
-    oldLog = console[kind]
-    if typeof oldLog is 'function' 
+    window._CONSOLE[kind] = console[kind]
+    if typeof window._CONSOLE is 'function' 
       console[kind] = (message) ->
         ConsoleBuffer.log({kind: kind, message: message})
-        oldLog.apply(console, arguments)
+        _CONSOLE[kind].apply(console, arguments)
diff --git a/lib/git_services.rb b/lib/git_services.rb
index b48f8c6d09f336bf11ef36e735212a6871be7ac9..398aa6ff05e481c97080cf3bc934fcc9e59ca0f1 100644
--- a/lib/git_services.rb
+++ b/lib/git_services.rb
@@ -153,6 +153,16 @@ module DtuCore
       true
     end
 
+    def exec()
+      begin
+        g = Git.open(self.git_repo_info.local_repo_folder, :log => Rails.logger)
+        set_git_identity(g)
+        yield g
+      rescue => e
+        Rails.logger.warn "Unable to change, will ignore: #{e}"
+      end
+    end
+
     def set_git_identity(g)
       g.config('user.name', (self.git_user.full_name || 'aonymous') + ' [from DTU quiz]')
       g.config('user.email', self.git_user.email)