diff --git a/lib/editors/common.dart b/lib/editors/common.dart
index ab822693..8cfc3be4 100644
--- a/lib/editors/common.dart
+++ b/lib/editors/common.dart
@@ -32,6 +32,18 @@ class TextEditorState {
   int cursorPos;
 
   TextEditorState(this.text, this.cursorPos);
+
+  TextEditorState.fromValue(TextEditingValue val) {
+    text = val.text;
+    cursorPos = val.selection.baseOffset;
+  }
+
+  TextEditingValue toValue() {
+    return TextEditingValue(
+      text: text,
+      selection: TextSelection.collapsed(offset: cursorPos),
+    );
+  }
 }
 
 class EditorAppBar extends StatelessWidget implements PreferredSizeWidget {
diff --git a/lib/editors/heuristics.dart b/lib/editors/heuristics.dart
index 76c91bd8..0d0ad454 100644
--- a/lib/editors/heuristics.dart
+++ b/lib/editors/heuristics.dart
@@ -69,3 +69,18 @@ TextEditorState autoAddBulletList(
 
   return TextEditorState(text, newCursorPos);
 }
+
+class EditorHeuristics {
+  EditorHeuristics({String text = ''}) {
+    _lastState = TextEditorState(text, 0);
+  }
+
+  TextEditorState _lastState;
+
+  TextEditorState textChanged(TextEditorState es) {
+    var lastState = _lastState;
+    _lastState = es;
+
+    return autoAddBulletList(lastState.text, es.text, es.cursorPos);
+  }
+}
diff --git a/lib/editors/markdown_editor.dart b/lib/editors/markdown_editor.dart
index 7f78aa3d..f515390a 100644
--- a/lib/editors/markdown_editor.dart
+++ b/lib/editors/markdown_editor.dart
@@ -63,20 +63,20 @@ class MarkdownEditorState extends State<MarkdownEditor>
   TextEditingController _textController = TextEditingController();
   TextEditingController _titleTextController = TextEditingController();
 
-  String _oldText;
+  EditorHeuristics _heuristics;
 
   bool _noteModified;
 
   MarkdownEditorState(this.note) {
     _textController = TextEditingController(text: note.body);
     _titleTextController = TextEditingController(text: note.title);
-    _oldText = note.body;
   }
 
   @override
   void initState() {
     super.initState();
     _noteModified = widget.noteModified;
+    _heuristics = EditorHeuristics(text: note.body);
   }
 
   @override
@@ -192,21 +192,18 @@ class MarkdownEditorState extends State<MarkdownEditor>
 
   void _applyHeuristics() {
     var selection = _textController.selection;
+    var editState = TextEditorState.fromValue(_textController.value);
+
+    // vHanda: Why does this happen?
     if (selection.baseOffset != selection.extentOffset) {
-      _oldText = _textController.text;
+      _heuristics.textChanged(editState);
       return;
     }
 
-    var r =
-        autoAddBulletList(_oldText, _textController.text, selection.baseOffset);
-    _oldText = _textController.text;
-
-    if (r == null) {
-      return;
+    var r = _heuristics.textChanged(editState);
+    if (r != null) {
+      _textController.value = r.toValue();
     }
-
-    _textController.text = r.text;
-    _textController.selection = TextSelection.collapsed(offset: r.cursorPos);
   }
 
   @override
diff --git a/lib/repository.dart b/lib/repository.dart
index 86c0efb3..a69b44a4 100644
--- a/lib/repository.dart
+++ b/lib/repository.dart
@@ -22,6 +22,7 @@ import 'package:gitjournal/error_reporting.dart';
 import 'package:gitjournal/features.dart';
 import 'package:gitjournal/settings.dart';
 import 'package:gitjournal/settings_migrations.dart';
+import 'package:gitjournal/setup/clone.dart';
 import 'package:gitjournal/utils/logger.dart';
 
 enum SyncStatus {
@@ -89,6 +90,23 @@ class Repository with ChangeNotifier {
 
     var repo = await GitRepository.load(repoPath);
     var remoteConfigured = repo.config.remotes.isNotEmpty;
+    if (remoteConfigured) {
+      // Code path for 'branch is null' exception
+      var branches = await repo.branches();
+      if (branches.isEmpty) {
+        var remoteConfig = repo.config.remotes[0];
+        await cloneRemote(
+          repoPath: repoPath,
+          remoteName: remoteConfig.name,
+          cloneUrl: remoteConfig.url,
+          authorName: settings.gitAuthor,
+          authorEmail: settings.gitAuthorEmail,
+          sshPublicKey: settings.sshPublicKey,
+          sshPrivateKey: settings.sshPrivateKey,
+          sshPassword: settings.sshPassword,
+        );
+      }
+    }
 
     return Repository._internal(
       repoPath: repoPath,