         for path in paths {
             let isDir = !path.hasSuffix(".gpg")
             if let passwordEntity = getPasswordEntity(by: path, isDir: isDir) {
+                passwordEntity.synced = false
                 parentPasswordEntity = passwordEntity
+            } else {
+                let passwordEntity = NSEntityDescription.insertNewObject(forEntityName: "PasswordEntity", into: self.context) as! PasswordEntity
+                let pathURL = URL(string: path.stringByAddingPercentEncodingForRFC3986()!)!
+                if isDir {
+                    passwordEntity.name = pathURL.lastPathComponent
+                } else {
+                    passwordEntity.name = pathURL.deletingPathExtension().lastPathComponent
+                }
+                passwordEntity.path = path
+                passwordEntity.parent = parentPasswordEntity
                 passwordEntity.synced = false
-            } else {
-                if !isDir {
-                    return insertPasswordEntity(name: URL(string: path.stringByAddingPercentEncodingForRFC3986()!)!.deletingPathExtension().lastPathComponent, path: path, parent: parentPasswordEntity, synced: false, isDir: false)
-                } else {
-                    parentPasswordEntity = insertPasswordEntity(name: URL(string: path.stringByAddingPercentEncodingForRFC3986()!)!.lastPathComponent, path: path, parent: parentPasswordEntity, synced: false, isDir: true)
-                }
-            }
-        }
-        return nil
-    }
-    
-    private func insertPasswordEntity(name: String, path: String, parent: PasswordEntity?, synced: Bool = false, isDir: Bool = false) -> PasswordEntity? {
-        var ret: PasswordEntity? = nil
-        if let passwordEntity = NSEntityDescription.insertNewObject(forEntityName: "PasswordEntity", into: self.context) as? PasswordEntity {
-            passwordEntity.name = name
-            passwordEntity.path = path
-            passwordEntity.parent = parent
-            passwordEntity.synced = synced
-            passwordEntity.isDir = isDir
-            do {
-                try self.context.save()
-                ret = passwordEntity
-            } catch {
-                fatalError("FailedToInsertPasswordEntity".localize(error))
-            }
-        }
-        return ret
+                passwordEntity.isDir = isDir
+                parentPasswordEntity = passwordEntity
+            }
+        }
+
+        self.saveUpdatedContext()
+        return parentPasswordEntity
     }
     
     public func add(password: Password) throws -> PasswordEntity? {

            let parent = current!.parent
            self.context.delete(current!)
            current = parent
            do {
                try self.context.save()
            } catch {
                fatalError("FailedToDeletePasswordEntity".localize(error))
            }
        }
    }
    
    public func saveUpdated(passwordEntity: PasswordEntity) {
        do {
            try context.save()
        } catch {
            fatalError("FailedToSavePasswordEntity".localize(error))
        }
    }
    

        } catch {
            print(error)
        }
        self.saveUpdatedContext()
    }
    
    public func getRecentCommits(count: Int) throws -> [GTCommit] {
