diff --git a/package-lock.json b/package-lock.json
index 5a456fc5dfafdd51c39e4cdb165805f339506804..44326bee7821a3c78488c07fe88c90c52e64bb38 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,5 +1,5 @@
 {
-  "name": "dynareapp",
+  "name": "dynareApp",
   "version": "1.0.0",
   "lockfileVersion": 1,
   "requires": true,
@@ -490,15 +490,6 @@
         "chainsaw": "~0.1.0"
       }
     },
-    "block-stream": {
-      "version": "0.0.9",
-      "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz",
-      "integrity": "sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo=",
-      "dev": true,
-      "requires": {
-        "inherits": "~2.0.0"
-      }
-    },
     "bluebird": {
       "version": "3.5.4",
       "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.4.tgz",
@@ -530,6 +521,12 @@
       "integrity": "sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==",
       "dev": true
     },
+    "buffer-crc32": {
+      "version": "0.2.13",
+      "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz",
+      "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=",
+      "dev": true
+    },
     "buffer-fill": {
       "version": "1.0.0",
       "resolved": "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz",
@@ -638,45 +635,34 @@
       "dev": true
     },
     "cliui": {
-      "version": "4.1.0",
-      "resolved": "https://registry.npmjs.org/cliui/-/cliui-4.1.0.tgz",
-      "integrity": "sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==",
+      "version": "5.0.0",
+      "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz",
+      "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==",
       "dev": true,
+      "optional": true,
       "requires": {
-        "string-width": "^2.1.1",
-        "strip-ansi": "^4.0.0",
-        "wrap-ansi": "^2.0.0"
+        "string-width": "^3.1.0",
+        "strip-ansi": "^5.2.0",
+        "wrap-ansi": "^5.1.0"
       },
       "dependencies": {
-        "ansi-regex": {
-          "version": "3.0.0",
-          "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz",
-          "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=",
-          "dev": true
-        },
         "is-fullwidth-code-point": {
           "version": "2.0.0",
           "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
           "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=",
-          "dev": true
+          "dev": true,
+          "optional": true
         },
         "string-width": {
-          "version": "2.1.1",
-          "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",
-          "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==",
+          "version": "3.1.0",
+          "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz",
+          "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==",
           "dev": true,
+          "optional": true,
           "requires": {
+            "emoji-regex": "^7.0.1",
             "is-fullwidth-code-point": "^2.0.0",
-            "strip-ansi": "^4.0.0"
-          }
-        },
-        "strip-ansi": {
-          "version": "4.0.0",
-          "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",
-          "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=",
-          "dev": true,
-          "requires": {
-            "ansi-regex": "^3.0.0"
+            "strip-ansi": "^5.1.0"
           }
         }
       }
@@ -928,6 +914,15 @@
         }
       }
     },
+    "electron-debug": {
+      "version": "3.1.0",
+      "resolved": "https://registry.npmjs.org/electron-debug/-/electron-debug-3.1.0.tgz",
+      "integrity": "sha512-SWEqLj4MgfV3tGuO5eBLQ5/Nr6M+KPxsnE0bUJZvQebGJus6RAcdmvd7L+l0Ji31h2mmrN23l2tHFtCa2FvurA==",
+      "requires": {
+        "electron-is-dev": "^1.1.0",
+        "electron-localshortcut": "^3.1.0"
+      }
+    },
     "electron-download": {
       "version": "4.1.1",
       "resolved": "https://registry.npmjs.org/electron-download/-/electron-download-4.1.1.tgz",
@@ -966,9 +961,9 @@
           }
         },
         "minimist": {
-          "version": "1.2.0",
-          "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
-          "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
+          "version": "1.2.5",
+          "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
+          "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
           "dev": true
         },
         "ms": {
@@ -1018,23 +1013,34 @@
       }
     },
     "electron-installer-debian": {
-      "version": "1.1.1",
-      "resolved": "https://registry.npmjs.org/electron-installer-debian/-/electron-installer-debian-1.1.1.tgz",
-      "integrity": "sha512-2r27a1AhB6iCy3dmdm6aoS9Mn42UW0Y9KhCWUgf2Xd8zIB58Ew1ALTaB8xevVU0nOW5s+quq6McPS633PPHQIA==",
+      "version": "1.2.0",
+      "resolved": "https://registry.npmjs.org/electron-installer-debian/-/electron-installer-debian-1.2.0.tgz",
+      "integrity": "sha512-gowfDlBY4NPZ6dMLsoSJzEeXlEa650NAjvtnYk6/Ikq9tFtS7xCs+Oyk91gNGDbFczA8QAelmR4KX4hV/eebKQ==",
       "dev": true,
       "optional": true,
       "requires": {
         "debug": "^4.1.1",
-        "electron-installer-common": "^0.6.1",
+        "electron-installer-common": "^0.6.2",
         "fs-extra": "^7.0.1",
         "get-folder-size": "^2.0.1",
         "lodash": "^4.17.4",
         "pify": "^4.0.1",
-        "semver": "^5.6.0",
         "word-wrap": "^1.2.3",
-        "yargs": "^12.0.5"
+        "yargs": "^13.2.2"
       },
       "dependencies": {
+        "cliui": {
+          "version": "5.0.0",
+          "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz",
+          "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==",
+          "dev": true,
+          "optional": true,
+          "requires": {
+            "string-width": "^3.1.0",
+            "strip-ansi": "^5.2.0",
+            "wrap-ansi": "^5.1.0"
+          }
+        },
         "debug": {
           "version": "4.1.1",
           "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
@@ -1045,29 +1051,104 @@
             "ms": "^2.1.1"
           }
         },
+        "get-caller-file": {
+          "version": "2.0.5",
+          "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
+          "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
+          "dev": true,
+          "optional": true
+        },
+        "is-fullwidth-code-point": {
+          "version": "2.0.0",
+          "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
+          "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=",
+          "dev": true,
+          "optional": true
+        },
         "ms": {
-          "version": "2.1.1",
-          "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
-          "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==",
+          "version": "2.1.2",
+          "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
+          "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
           "dev": true,
           "optional": true
+        },
+        "require-main-filename": {
+          "version": "2.0.0",
+          "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz",
+          "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==",
+          "dev": true,
+          "optional": true
+        },
+        "string-width": {
+          "version": "3.1.0",
+          "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz",
+          "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==",
+          "dev": true,
+          "optional": true,
+          "requires": {
+            "emoji-regex": "^7.0.1",
+            "is-fullwidth-code-point": "^2.0.0",
+            "strip-ansi": "^5.1.0"
+          }
+        },
+        "wrap-ansi": {
+          "version": "5.1.0",
+          "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz",
+          "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==",
+          "dev": true,
+          "optional": true,
+          "requires": {
+            "ansi-styles": "^3.2.0",
+            "string-width": "^3.0.0",
+            "strip-ansi": "^5.0.0"
+          }
+        },
+        "yargs": {
+          "version": "13.3.2",
+          "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.2.tgz",
+          "integrity": "sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw==",
+          "dev": true,
+          "optional": true,
+          "requires": {
+            "cliui": "^5.0.0",
+            "find-up": "^3.0.0",
+            "get-caller-file": "^2.0.1",
+            "require-directory": "^2.1.1",
+            "require-main-filename": "^2.0.0",
+            "set-blocking": "^2.0.0",
+            "string-width": "^3.0.0",
+            "which-module": "^2.0.0",
+            "y18n": "^4.0.0",
+            "yargs-parser": "^13.1.2"
+          }
+        },
+        "yargs-parser": {
+          "version": "13.1.2",
+          "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz",
+          "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==",
+          "dev": true,
+          "optional": true,
+          "requires": {
+            "camelcase": "^5.0.0",
+            "decamelize": "^1.2.0"
+          }
         }
       }
     },
     "electron-installer-redhat": {
-      "version": "1.0.1",
-      "resolved": "https://registry.npmjs.org/electron-installer-redhat/-/electron-installer-redhat-1.0.1.tgz",
-      "integrity": "sha512-fwdhvA7HvcObq5/+wLC08MVwCGHw8EvhjolsUDuefXoQIfOVNCfbhSIzfMMYHL9lfSeYCuQzZjVv1/gwbSLuOQ==",
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/electron-installer-redhat/-/electron-installer-redhat-1.1.0.tgz",
+      "integrity": "sha512-wea1fZ1VOEZBJ5Y+/D2So04PnhfwoEPFW4rD9UlP/ODIggkDHY6ZLsXj0SRPGKGJqmTzP16Taoj7YNsmxYEL2g==",
       "dev": true,
       "optional": true,
       "requires": {
         "debug": "^4.1.1",
-        "electron-installer-common": "^0.6.1",
+        "electron-installer-common": "^0.6.2",
         "fs-extra": "^7.0.1",
         "lodash": "^4.17.4",
         "nodeify": "^1.0.1",
         "word-wrap": "^1.2.3",
-        "yargs": "^12.0.5"
+        "yargs": "^13.2.2"
       },
       "dependencies": {
         "debug": {
@@ -1081,14 +1162,50 @@
           }
         },
         "ms": {
-          "version": "2.1.1",
-          "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
-          "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==",
+          "version": "2.1.2",
+          "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
+          "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
           "dev": true,
           "optional": true
         }
       }
     },
+    "electron-is-accelerator": {
+      "version": "0.1.2",
+      "resolved": "https://registry.npmjs.org/electron-is-accelerator/-/electron-is-accelerator-0.1.2.tgz",
+      "integrity": "sha1-UJ5RDCala1Xhf4Y6SwThEYRqsns="
+    },
+    "electron-is-dev": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npmjs.org/electron-is-dev/-/electron-is-dev-1.2.0.tgz",
+      "integrity": "sha512-R1oD5gMBPS7PVU8gJwH6CtT0e6VSoD0+SzSnYpNm+dBkcijgA+K7VAMHDfnRq/lkKPZArpzplTW6jfiMYosdzw=="
+    },
+    "electron-localshortcut": {
+      "version": "3.2.1",
+      "resolved": "https://registry.npmjs.org/electron-localshortcut/-/electron-localshortcut-3.2.1.tgz",
+      "integrity": "sha512-DWvhKv36GsdXKnaFFhEiK8kZZA+24/yFLgtTwJJHc7AFgDjNRIBJZ/jq62Y/dWv9E4ypYwrVWN2bVrCYw1uv7Q==",
+      "requires": {
+        "debug": "^4.0.1",
+        "electron-is-accelerator": "^0.1.0",
+        "keyboardevent-from-electron-accelerator": "^2.0.0",
+        "keyboardevents-areequal": "^0.2.1"
+      },
+      "dependencies": {
+        "debug": {
+          "version": "4.1.1",
+          "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
+          "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
+          "requires": {
+            "ms": "^2.1.1"
+          }
+        },
+        "ms": {
+          "version": "2.1.2",
+          "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
+          "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
+        }
+      }
+    },
     "electron-notarize": {
       "version": "0.0.5",
       "resolved": "https://registry.npmjs.org/electron-notarize/-/electron-notarize-0.0.5.tgz",
@@ -1131,9 +1248,9 @@
       },
       "dependencies": {
         "minimist": {
-          "version": "1.2.0",
-          "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
-          "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
+          "version": "1.2.5",
+          "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
+          "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
           "dev": true
         }
       }
@@ -1179,9 +1296,9 @@
           "dev": true
         },
         "yargs-parser": {
-          "version": "13.0.0",
-          "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.0.0.tgz",
-          "integrity": "sha512-w2LXjoL8oRdRQN+hOyppuXs+V/fVAYtpcrRxZuF7Kt/Oc+Jr2uAcVntaUTNT6w5ihoWfFDpNY8CPx1QskxZ/pw==",
+          "version": "13.1.2",
+          "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz",
+          "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==",
           "dev": true,
           "requires": {
             "camelcase": "^5.0.0",
@@ -1191,22 +1308,33 @@
       }
     },
     "electron-rebuild": {
-      "version": "1.8.4",
-      "resolved": "https://registry.npmjs.org/electron-rebuild/-/electron-rebuild-1.8.4.tgz",
-      "integrity": "sha512-QBUZg1due+R0bww5rNd4gEcsKczyhxyLrxSFZlKihwHRxaiHrGut532JAUe0fRz+VIU4WNSfNKyZ/ZwSGjaDhA==",
+      "version": "1.11.0",
+      "resolved": "https://registry.npmjs.org/electron-rebuild/-/electron-rebuild-1.11.0.tgz",
+      "integrity": "sha512-cn6AqZBQBVtaEyj5jZW1/LOezZZ22PA1HvhEP7asvYPJ8PDF4i4UFt9be4i9T7xJKiSiomXvY5Fd+dSq3FXZxA==",
       "dev": true,
       "requires": {
         "colors": "^1.3.3",
         "debug": "^4.1.1",
         "detect-libc": "^1.0.3",
-        "fs-extra": "^7.0.1",
-        "node-abi": "^2.7.0",
-        "node-gyp": "^3.8.0",
-        "ora": "^3.0.0",
+        "fs-extra": "^8.1.0",
+        "node-abi": "^2.11.0",
+        "node-gyp": "^6.0.1",
+        "ora": "^3.4.0",
         "spawn-rx": "^3.0.0",
-        "yargs": "^12.0.5"
+        "yargs": "^14.2.0"
       },
       "dependencies": {
+        "cliui": {
+          "version": "5.0.0",
+          "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz",
+          "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==",
+          "dev": true,
+          "requires": {
+            "string-width": "^3.1.0",
+            "strip-ansi": "^5.2.0",
+            "wrap-ansi": "^5.1.0"
+          }
+        },
         "debug": {
           "version": "4.1.1",
           "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
@@ -1216,11 +1344,97 @@
             "ms": "^2.1.1"
           }
         },
+        "fs-extra": {
+          "version": "8.1.0",
+          "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz",
+          "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==",
+          "dev": true,
+          "requires": {
+            "graceful-fs": "^4.2.0",
+            "jsonfile": "^4.0.0",
+            "universalify": "^0.1.0"
+          }
+        },
+        "get-caller-file": {
+          "version": "2.0.5",
+          "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
+          "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
+          "dev": true
+        },
+        "graceful-fs": {
+          "version": "4.2.4",
+          "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz",
+          "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==",
+          "dev": true
+        },
+        "is-fullwidth-code-point": {
+          "version": "2.0.0",
+          "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
+          "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=",
+          "dev": true
+        },
         "ms": {
-          "version": "2.1.1",
-          "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
-          "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==",
+          "version": "2.1.2",
+          "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
+          "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
           "dev": true
+        },
+        "require-main-filename": {
+          "version": "2.0.0",
+          "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz",
+          "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==",
+          "dev": true
+        },
+        "string-width": {
+          "version": "3.1.0",
+          "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz",
+          "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==",
+          "dev": true,
+          "requires": {
+            "emoji-regex": "^7.0.1",
+            "is-fullwidth-code-point": "^2.0.0",
+            "strip-ansi": "^5.1.0"
+          }
+        },
+        "wrap-ansi": {
+          "version": "5.1.0",
+          "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz",
+          "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==",
+          "dev": true,
+          "requires": {
+            "ansi-styles": "^3.2.0",
+            "string-width": "^3.0.0",
+            "strip-ansi": "^5.0.0"
+          }
+        },
+        "yargs": {
+          "version": "14.2.3",
+          "resolved": "https://registry.npmjs.org/yargs/-/yargs-14.2.3.tgz",
+          "integrity": "sha512-ZbotRWhF+lkjijC/VhmOT9wSgyBQ7+zr13+YLkhfsSiTriYsMzkTUFP18pFhWwBeMa5gUc1MzbhrO6/VB7c9Xg==",
+          "dev": true,
+          "requires": {
+            "cliui": "^5.0.0",
+            "decamelize": "^1.2.0",
+            "find-up": "^3.0.0",
+            "get-caller-file": "^2.0.1",
+            "require-directory": "^2.1.1",
+            "require-main-filename": "^2.0.0",
+            "set-blocking": "^2.0.0",
+            "string-width": "^3.0.0",
+            "which-module": "^2.0.0",
+            "y18n": "^4.0.0",
+            "yargs-parser": "^15.0.1"
+          }
+        },
+        "yargs-parser": {
+          "version": "15.0.1",
+          "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-15.0.1.tgz",
+          "integrity": "sha512-0OAMV2mAZQrs3FkNpDQcBk1x5HXb8X4twADss4S0Iuk+2dGnLOE/fRHrsYm542GduMveyA77OF4wrNJuanRCWw==",
+          "dev": true,
+          "requires": {
+            "camelcase": "^5.0.0",
+            "decamelize": "^1.2.0"
+          }
         }
       }
     },
@@ -1307,6 +1521,12 @@
         }
       }
     },
+    "emoji-regex": {
+      "version": "7.0.3",
+      "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz",
+      "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==",
+      "dev": true
+    },
     "end-of-stream": {
       "version": "1.4.1",
       "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz",
@@ -1393,15 +1613,15 @@
       }
     },
     "extract-zip": {
-      "version": "1.6.7",
-      "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.7.tgz",
-      "integrity": "sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k=",
+      "version": "1.7.0",
+      "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.7.0.tgz",
+      "integrity": "sha512-xoh5G1W/PB0/27lXgMQyIhP5DSY/LhoCsOyZgb+6iMmRtCwVBo55uKaMoEYrDCKQhWvqEip5ZPKAc6eFNyf/MA==",
       "dev": true,
       "requires": {
-        "concat-stream": "1.6.2",
-        "debug": "2.6.9",
-        "mkdirp": "0.5.1",
-        "yauzl": "2.4.1"
+        "concat-stream": "^1.6.2",
+        "debug": "^2.6.9",
+        "mkdirp": "^0.5.4",
+        "yauzl": "^2.10.0"
       }
     },
     "extsprintf": {
@@ -1420,9 +1640,9 @@
       "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I="
     },
     "fd-slicer": {
-      "version": "1.0.1",
-      "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz",
-      "integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=",
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz",
+      "integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=",
       "dev": true,
       "requires": {
         "pend": "~1.2.0"
@@ -1523,18 +1743,6 @@
       "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
       "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
     },
-    "fstream": {
-      "version": "1.0.11",
-      "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz",
-      "integrity": "sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE=",
-      "dev": true,
-      "requires": {
-        "graceful-fs": "^4.1.2",
-        "inherits": "~2.0.0",
-        "mkdirp": ">=0.5 0",
-        "rimraf": "2"
-      }
-    },
     "galactus": {
       "version": "0.2.1",
       "resolved": "https://registry.npmjs.org/galactus/-/galactus-0.2.1.tgz",
@@ -1612,10 +1820,11 @@
       }
     },
     "get-caller-file": {
-      "version": "1.0.3",
-      "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz",
-      "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==",
-      "dev": true
+      "version": "2.0.5",
+      "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
+      "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
+      "dev": true,
+      "optional": true
     },
     "get-folder-size": {
       "version": "2.0.1",
@@ -1974,12 +2183,6 @@
         }
       }
     },
-    "invert-kv": {
-      "version": "2.0.0",
-      "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-2.0.0.tgz",
-      "integrity": "sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==",
-      "dev": true
-    },
     "is-arrayish": {
       "version": "0.2.1",
       "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz",
@@ -2103,6 +2306,16 @@
         "verror": "1.10.0"
       }
     },
+    "keyboardevent-from-electron-accelerator": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/keyboardevent-from-electron-accelerator/-/keyboardevent-from-electron-accelerator-2.0.0.tgz",
+      "integrity": "sha512-iQcmNA0M4ETMNi0kG/q0h/43wZk7rMeKYrXP7sqKIJbHkTU8Koowgzv+ieR/vWJbOwxx5nDC3UnudZ0aLSu4VA=="
+    },
+    "keyboardevents-areequal": {
+      "version": "0.2.2",
+      "resolved": "https://registry.npmjs.org/keyboardevents-areequal/-/keyboardevents-areequal-0.2.2.tgz",
+      "integrity": "sha512-Nv+Kr33T0mEjxR500q+I6IWisOQ0lK1GGOncV0kWE6n4KFmpcu7RUX5/2B0EUtX51Cb0HjZ9VJsSY3u4cBa0kw=="
+    },
     "klaw": {
       "version": "1.3.1",
       "resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz",
@@ -2113,15 +2326,6 @@
         "graceful-fs": "^4.1.9"
       }
     },
-    "lcid": {
-      "version": "2.0.0",
-      "resolved": "https://registry.npmjs.org/lcid/-/lcid-2.0.0.tgz",
-      "integrity": "sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA==",
-      "dev": true,
-      "requires": {
-        "invert-kv": "^2.0.0"
-      }
-    },
     "load-json-file": {
       "version": "1.1.0",
       "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz",
@@ -2154,9 +2358,9 @@
       }
     },
     "lodash": {
-      "version": "4.17.11",
-      "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz",
-      "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==",
+      "version": "4.17.15",
+      "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
+      "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==",
       "dev": true
     },
     "lodash._reinterpolate": {
@@ -2178,9 +2382,9 @@
       "dev": true
     },
     "lodash.merge": {
-      "version": "4.6.1",
-      "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.1.tgz",
-      "integrity": "sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ==",
+      "version": "4.6.2",
+      "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
+      "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==",
       "dev": true
     },
     "lodash.template": {
@@ -2284,9 +2488,9 @@
       },
       "dependencies": {
         "minimist": {
-          "version": "1.2.0",
-          "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
-          "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
+          "version": "1.2.5",
+          "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
+          "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
           "dev": true
         }
       }
@@ -2319,9 +2523,9 @@
       }
     },
     "minimist": {
-      "version": "0.0.8",
-      "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
-      "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
+      "version": "1.2.5",
+      "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
+      "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
     },
     "minipass": {
       "version": "2.3.5",
@@ -2348,11 +2552,11 @@
       }
     },
     "mkdirp": {
-      "version": "0.5.1",
-      "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
-      "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
+      "version": "0.5.5",
+      "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
+      "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
       "requires": {
-        "minimist": "0.0.8"
+        "minimist": "^1.2.5"
       }
     },
     "mkpath": {
@@ -2448,9 +2652,9 @@
       "dev": true
     },
     "node-abi": {
-      "version": "2.7.1",
-      "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.7.1.tgz",
-      "integrity": "sha512-OV8Bq1OrPh6z+Y4dqwo05HqrRL9YNF7QVMRfq1/pguwKLG+q9UB/Lk0x5qXjO23JjJg+/jqCHSTaG1P3tfKfuw==",
+      "version": "2.18.0",
+      "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.18.0.tgz",
+      "integrity": "sha512-yi05ZoiuNNEbyT/xXfSySZE+yVnQW6fxPZuFbLyS1s6b5Kw3HzV2PHOM4XR+nsjzkHxByK+2Wg+yCQbe35l8dw==",
       "dev": true,
       "requires": {
         "semver": "^5.4.1"
@@ -2463,29 +2667,64 @@
       "dev": true
     },
     "node-gyp": {
-      "version": "3.8.0",
-      "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-3.8.0.tgz",
-      "integrity": "sha512-3g8lYefrRRzvGeSowdJKAKyks8oUpLEd/DyPV4eMhVlhJ0aNaZqIrNUIPuEWWTAoPqyFkfGrM67MC69baqn6vA==",
+      "version": "6.1.0",
+      "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-6.1.0.tgz",
+      "integrity": "sha512-h4A2zDlOujeeaaTx06r4Vy+8MZ1679lU+wbCKDS4ZtvY2A37DESo37oejIw0mtmR3+rvNwts5B6Kpt1KrNYdNw==",
       "dev": true,
       "requires": {
-        "fstream": "^1.0.0",
-        "glob": "^7.0.3",
-        "graceful-fs": "^4.1.2",
-        "mkdirp": "^0.5.0",
-        "nopt": "2 || 3",
-        "npmlog": "0 || 1 || 2 || 3 || 4",
-        "osenv": "0",
-        "request": "^2.87.0",
-        "rimraf": "2",
-        "semver": "~5.3.0",
-        "tar": "^2.0.0",
-        "which": "1"
+        "env-paths": "^2.2.0",
+        "glob": "^7.1.4",
+        "graceful-fs": "^4.2.2",
+        "mkdirp": "^0.5.1",
+        "nopt": "^4.0.1",
+        "npmlog": "^4.1.2",
+        "request": "^2.88.0",
+        "rimraf": "^2.6.3",
+        "semver": "^5.7.1",
+        "tar": "^4.4.12",
+        "which": "^1.3.1"
       },
       "dependencies": {
+        "env-paths": {
+          "version": "2.2.0",
+          "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.0.tgz",
+          "integrity": "sha512-6u0VYSCo/OW6IoD5WCLLy9JUGARbamfSavcNXry/eu8aHVFei6CD3Sw+VGX5alea1i9pgPHW0mbu6Xj0uBh7gA==",
+          "dev": true
+        },
+        "glob": {
+          "version": "7.1.6",
+          "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
+          "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==",
+          "dev": true,
+          "requires": {
+            "fs.realpath": "^1.0.0",
+            "inflight": "^1.0.4",
+            "inherits": "2",
+            "minimatch": "^3.0.4",
+            "once": "^1.3.0",
+            "path-is-absolute": "^1.0.0"
+          }
+        },
+        "graceful-fs": {
+          "version": "4.2.4",
+          "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz",
+          "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==",
+          "dev": true
+        },
+        "nopt": {
+          "version": "4.0.3",
+          "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.3.tgz",
+          "integrity": "sha512-CvaGwVMztSMJLOeXPrez7fyfObdZqNUK1cPAEzLHrTybIua9pMdmmPR5YwtfNftIOMv3DPUhFaxsZMNTQO20Kg==",
+          "dev": true,
+          "requires": {
+            "abbrev": "1",
+            "osenv": "^0.1.4"
+          }
+        },
         "semver": {
-          "version": "5.3.0",
-          "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz",
-          "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=",
+          "version": "5.7.1",
+          "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
+          "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
           "dev": true
         }
       }
@@ -2517,23 +2756,34 @@
           }
         },
         "tar": {
-          "version": "4.4.8",
-          "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.8.tgz",
-          "integrity": "sha512-LzHF64s5chPQQS0IYBn9IN5h3i98c12bo4NCO7e0sGM2llXQ3p2FGC5sdENN4cTW48O915Sh+x+EXx7XW96xYQ==",
+          "version": "4.4.13",
+          "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.13.tgz",
+          "integrity": "sha512-w2VwSrBoHa5BsSyH+KxEqeQBAllHhccyMFVHtGtdMpF4W7IRWfZjFiQceJPChOeTsSDVUpER2T8FA93pr0L+QA==",
           "requires": {
             "chownr": "^1.1.1",
             "fs-minipass": "^1.2.5",
-            "minipass": "^2.3.4",
-            "minizlib": "^1.1.1",
+            "minipass": "^2.8.6",
+            "minizlib": "^1.2.1",
             "mkdirp": "^0.5.0",
             "safe-buffer": "^5.1.2",
-            "yallist": "^3.0.2"
+            "yallist": "^3.0.3"
+          },
+          "dependencies": {
+            "minipass": {
+              "version": "2.9.0",
+              "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz",
+              "integrity": "sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==",
+              "requires": {
+                "safe-buffer": "^5.1.2",
+                "yallist": "^3.0.0"
+              }
+            }
           }
         },
         "yallist": {
-          "version": "3.0.3",
-          "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz",
-          "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A=="
+          "version": "3.1.1",
+          "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz",
+          "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g=="
         }
       }
     },
@@ -2562,6 +2812,7 @@
       "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz",
       "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=",
       "dev": true,
+      "optional": true,
       "requires": {
         "abbrev": "1"
       }
@@ -2628,9 +2879,9 @@
       },
       "dependencies": {
         "minimist": {
-          "version": "1.2.0",
-          "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
-          "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
+          "version": "1.2.5",
+          "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
+          "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
           "dev": true
         }
       }
@@ -2701,17 +2952,6 @@
       "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
       "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M="
     },
-    "os-locale": {
-      "version": "3.1.0",
-      "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-3.1.0.tgz",
-      "integrity": "sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q==",
-      "dev": true,
-      "requires": {
-        "execa": "^1.0.0",
-        "lcid": "^2.0.0",
-        "mem": "^4.0.0"
-      }
-    },
     "os-tmpdir": {
       "version": "1.0.2",
       "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
@@ -2986,9 +3226,9 @@
       },
       "dependencies": {
         "minimist": {
-          "version": "1.2.0",
-          "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
-          "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
+          "version": "1.2.5",
+          "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
+          "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
         }
       }
     },
@@ -3107,10 +3347,11 @@
       "dev": true
     },
     "require-main-filename": {
-      "version": "1.0.1",
-      "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz",
-      "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=",
-      "dev": true
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz",
+      "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==",
+      "dev": true,
+      "optional": true
     },
     "resolve": {
       "version": "1.10.0",
@@ -3226,12 +3467,12 @@
       "dev": true
     },
     "short-uuid": {
-      "version": "3.1.0",
-      "resolved": "https://registry.npmjs.org/short-uuid/-/short-uuid-3.1.0.tgz",
-      "integrity": "sha512-rE1ha17HP7otN1vywYfo7zeHD0jrvSh2KbrCWK3aVVNREAdPaEGFHPtC6hg4NkFpqK815n7ffsWgroqhWWq/Jw==",
+      "version": "3.1.1",
+      "resolved": "https://registry.npmjs.org/short-uuid/-/short-uuid-3.1.1.tgz",
+      "integrity": "sha512-7dI69xtJYpTIbg44R6JSgrbDtZFuZ9vAwwmnF/L0PinykbFrhQ7V8omKsQcVw1TP0nYJ7uQp1PN6/aVMkzQFGQ==",
       "requires": {
         "any-base": "^1.1.0",
-        "uuid": "^3.2.1"
+        "uuid": "^3.3.2"
       }
     },
     "signal-exit": {
@@ -3435,14 +3676,36 @@
       }
     },
     "tar": {
-      "version": "2.2.1",
-      "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz",
-      "integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=",
+      "version": "4.4.13",
+      "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.13.tgz",
+      "integrity": "sha512-w2VwSrBoHa5BsSyH+KxEqeQBAllHhccyMFVHtGtdMpF4W7IRWfZjFiQceJPChOeTsSDVUpER2T8FA93pr0L+QA==",
       "dev": true,
       "requires": {
-        "block-stream": "*",
-        "fstream": "^1.0.2",
-        "inherits": "2"
+        "chownr": "^1.1.1",
+        "fs-minipass": "^1.2.5",
+        "minipass": "^2.8.6",
+        "minizlib": "^1.2.1",
+        "mkdirp": "^0.5.0",
+        "safe-buffer": "^5.1.2",
+        "yallist": "^3.0.3"
+      },
+      "dependencies": {
+        "minipass": {
+          "version": "2.9.0",
+          "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz",
+          "integrity": "sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==",
+          "dev": true,
+          "requires": {
+            "safe-buffer": "^5.1.2",
+            "yallist": "^3.0.0"
+          }
+        },
+        "yallist": {
+          "version": "3.1.1",
+          "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz",
+          "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==",
+          "dev": true
+        }
       }
     },
     "temp": {
@@ -3724,28 +3987,34 @@
       "optional": true
     },
     "wrap-ansi": {
-      "version": "2.1.0",
-      "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz",
-      "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=",
+      "version": "5.1.0",
+      "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz",
+      "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==",
       "dev": true,
+      "optional": true,
       "requires": {
-        "string-width": "^1.0.1",
-        "strip-ansi": "^3.0.1"
+        "ansi-styles": "^3.2.0",
+        "string-width": "^3.0.0",
+        "strip-ansi": "^5.0.0"
       },
       "dependencies": {
-        "ansi-regex": {
-          "version": "2.1.1",
-          "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
-          "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
-          "dev": true
+        "is-fullwidth-code-point": {
+          "version": "2.0.0",
+          "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
+          "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=",
+          "dev": true,
+          "optional": true
         },
-        "strip-ansi": {
-          "version": "3.0.1",
-          "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
-          "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
+        "string-width": {
+          "version": "3.1.0",
+          "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz",
+          "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==",
           "dev": true,
+          "optional": true,
           "requires": {
-            "ansi-regex": "^2.0.0"
+            "emoji-regex": "^7.0.1",
+            "is-fullwidth-code-point": "^2.0.0",
+            "strip-ansi": "^5.1.0"
           }
         }
       }
@@ -3789,63 +4058,51 @@
       "dev": true
     },
     "yargs": {
-      "version": "12.0.5",
-      "resolved": "https://registry.npmjs.org/yargs/-/yargs-12.0.5.tgz",
-      "integrity": "sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw==",
+      "version": "13.3.2",
+      "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.2.tgz",
+      "integrity": "sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw==",
       "dev": true,
+      "optional": true,
       "requires": {
-        "cliui": "^4.0.0",
-        "decamelize": "^1.2.0",
+        "cliui": "^5.0.0",
         "find-up": "^3.0.0",
-        "get-caller-file": "^1.0.1",
-        "os-locale": "^3.0.0",
+        "get-caller-file": "^2.0.1",
         "require-directory": "^2.1.1",
-        "require-main-filename": "^1.0.1",
+        "require-main-filename": "^2.0.0",
         "set-blocking": "^2.0.0",
-        "string-width": "^2.0.0",
+        "string-width": "^3.0.0",
         "which-module": "^2.0.0",
-        "y18n": "^3.2.1 || ^4.0.0",
-        "yargs-parser": "^11.1.1"
+        "y18n": "^4.0.0",
+        "yargs-parser": "^13.1.2"
       },
       "dependencies": {
-        "ansi-regex": {
-          "version": "3.0.0",
-          "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz",
-          "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=",
-          "dev": true
-        },
         "is-fullwidth-code-point": {
           "version": "2.0.0",
           "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
           "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=",
-          "dev": true
+          "dev": true,
+          "optional": true
         },
         "string-width": {
-          "version": "2.1.1",
-          "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",
-          "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==",
+          "version": "3.1.0",
+          "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz",
+          "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==",
           "dev": true,
+          "optional": true,
           "requires": {
+            "emoji-regex": "^7.0.1",
             "is-fullwidth-code-point": "^2.0.0",
-            "strip-ansi": "^4.0.0"
-          }
-        },
-        "strip-ansi": {
-          "version": "4.0.0",
-          "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",
-          "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=",
-          "dev": true,
-          "requires": {
-            "ansi-regex": "^3.0.0"
+            "strip-ansi": "^5.1.0"
           }
         }
       }
     },
     "yargs-parser": {
-      "version": "11.1.1",
-      "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-11.1.1.tgz",
-      "integrity": "sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ==",
+      "version": "13.1.2",
+      "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz",
+      "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==",
       "dev": true,
+      "optional": true,
       "requires": {
         "camelcase": "^5.0.0",
         "decamelize": "^1.2.0"
@@ -3861,12 +4118,13 @@
       }
     },
     "yauzl": {
-      "version": "2.4.1",
-      "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz",
-      "integrity": "sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=",
+      "version": "2.10.0",
+      "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz",
+      "integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=",
       "dev": true,
       "requires": {
-        "fd-slicer": "~1.0.1"
+        "buffer-crc32": "~0.2.3",
+        "fd-slicer": "~1.1.0"
       }
     }
   }
diff --git a/package.json b/package.json
index 224b96acd425067f73f71c1bccb7ffba4b2a02f2..739584601201b01030fa19364836ed18871f965c 100644
--- a/package.json
+++ b/package.json
@@ -44,8 +44,9 @@
     }
   },
   "dependencies": {
+    "electron-debug": "^3.1.0",
     "electron-squirrel-startup": "^1.0.0",
-    "short-uuid": "^3.1.0",
+    "short-uuid": "^3.1.1",
     "sqlite3": "^4.0.6"
   },
   "devDependencies": {
diff --git a/src/appModules.js b/src/appModules.js
index 3177bddb5ce2165b5e5ae1e2361b0709b0798f2a..e98401ce0e8cc2d7a3d0e4f98e77f4102659cff0 100644
--- a/src/appModules.js
+++ b/src/appModules.js
@@ -4,6 +4,7 @@ const path = require('path');
 const sqlite3 = require('sqlite3').verbose();
 const spawn = require('child_process').spawn;
 var fs = require('fs');
+var short = require('short-uuid');
 
 
 
@@ -116,7 +117,7 @@ module.exports = {
 
       // returning promise
       if (('modelhash' in dynaremodel)) {
-        console.log('Model updated and retrived successfully in database.');
+        console.log('Model updated and retrieved successfully in database.');
         return resolve(dynaremodel)
       } else {
         return reject(new Error('modelhash was not found in dynaremodel in savetodb: ' + error));
@@ -185,6 +186,93 @@ module.exports = {
     });
   },
 
+  newmodelindb: (modelname) => {
+    //check https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function
+
+    return new Promise(async function (resolve, reject) {
+
+      let dbpath = path.resolve(__dirname, './assets/data/dynare.db');
+      let db = new sqlite3.Database(dbpath, sqlite3.OPEN_READWRITE, (err) => {
+        if (err) {
+          return console.error(err.message);
+        }
+      });
+
+      // db access promise functions definitions ---
+      db.runAsync = function (sql, sqloptions) {
+        var that = this;
+        return new Promise(function (resolve, reject) {
+          that.run(sql, sqloptions, function (err) {
+            if (err)
+              reject(err);
+            else
+              resolve('db updated');
+          });
+        });
+      };
+
+      db.getAsync = function (sql, sqloptions) {
+        var that = this;
+        return new Promise(function (resolve, reject) {
+          that.get(sql, sqloptions, function (err, data) {
+            if (err)
+              reject(err);
+            else
+              resolve(data);
+          });
+        });
+      };
+
+      db.closeAsync = function () {
+        var that = this;
+        return new Promise(function (resolve, reject) {
+          that.close(function (err) {
+            if (err)
+              reject(err);
+            else
+              resolve('db closed');
+          });
+        });
+      };
+      // ---
+
+      modelhash = short.generate();
+
+      // updating database async
+      let sql1 = `INSERT INTO dynaremodel(modelhash,modelname,modelcode,modelcreatedon,modelupdatedon) VALUES(?,?,?,?,?);`;
+      timestamp = new Date().toISOString().slice(0, 19).replace('T', ' ');
+      try {
+        await db.runAsync(sql1, [modelhash, modelname, '%Enter model here', timestamp, timestamp]);
+      } catch (error) {
+        return reject(new Error('Unable to insert new model in newmodelindb: ' + error));
+      }
+
+      // getting updated dynare model in database async
+      let sql2 = `SELECT * FROM dynaremodel WHERE modelhash = ?;`;
+      try {
+        var dynaremodel = await db.getAsync(sql2, [modelhash]);
+      } catch (error) {
+        return reject(new Error('Unable to get new dynare model from database in newmodelindb: ' + error));
+      }
+
+      // closing database async
+      try {
+        await db.closeAsync();
+      } catch (error) {
+        return reject(new Error('Unable to close database in newmodelindb: ' + error));
+      }
+
+      // returning promise
+      if (('modelhash' in dynaremodel)) {
+        console.log('New model created and retrieved successfully in database.');
+        return resolve(dynaremodel)
+      } else {
+        return reject(new Error('modelhash was not found in dynaremodel in newmodelindb: ' + error));
+      }
+
+    });
+  },
+
   basedir: function (myfilename) {
     //retrives path to the console
     return (path.resolve(__dirname, './assets/modfiles/' + myfilename));
@@ -304,8 +392,9 @@ module.exports = {
           cwd: workPath
         });
       }
-
-
+      if (pptype == 3) {
+        child = spawn(exePath, [filePath, 'json=parse']);
+      }
 
       var dynarestdout = '';
       var dynareerror = '';
@@ -336,9 +425,12 @@ module.exports = {
     // writing a JSON file with the perfor table content to be sent to Matlab/Julia
     return new Promise(async function (resolve, reject) {
 
+      console.log('inside preparejsonfiles')
+      console.log(modelhash + '_ini.json')
+
       // loading model JSON file
       try {
-        var modeljson = await loadjsonfile(modelhash + '_ini.json');
+        var modeljson = await module.exports.loadjsonfile(modelhash + '_ini.json');
       } catch (error) {
         return reject({
           'status': 100,
@@ -350,7 +442,7 @@ module.exports = {
 
       // removing old files
       try {
-        await removeoldfile('temp.m');
+        await module.exports.removeoldfile('temp.m');
       } catch (error) {
         return reject({
           'status': 100,
@@ -359,7 +451,7 @@ module.exports = {
       }
 
       try {
-        await removeoldfile('temp_static.m');
+        await module.exports.removeoldfile('temp_static.m');
       } catch (error) {
         return reject({
           'status': 100,
@@ -368,7 +460,7 @@ module.exports = {
       }
 
       try {
-        await removeoldfile('temp_dynamic.m');
+        await module.exports.removeoldfile('temp_dynamic.m');
       } catch (error) {
         return reject({
           'status': 100,
@@ -377,7 +469,7 @@ module.exports = {
       }
 
       try {
-        await removeoldfile('temp.mod');
+        await module.exports.removeoldfile('temp.mod');
       } catch (error) {
         return reject({
           'status': 100,
@@ -385,6 +477,8 @@ module.exports = {
         });
       }
 
+
+
       // preparing temp.mod file content
 
       var modfilecontent = '';
@@ -437,7 +531,7 @@ module.exports = {
       if (ssstatus == 0) {
         // this is the case where the user provided a steady_state block
         try {
-          var ssjson = await loadjsonfile(modelhash + '_ini_steady_state_model.json');
+          var ssjson = await module.exports.loadjsonfile(modelhash + '_ini_steady_state_model.json');
         } catch (error) {
           return reject({
             'status': 100,
@@ -483,7 +577,7 @@ module.exports = {
           modfilecontent += 'end;\n';
           // saving extra ss info to DB
           try {
-            await updatedbSS(modelhash, ssdescription['sstext'], 1);
+            await module.exports.updatedbSS(modelhash, ssdescription['sstext'], 1);
           } catch (error) {
             return reject({
               'status': 100,
@@ -497,7 +591,7 @@ module.exports = {
           modfilecontent += 'end;\n';
           // saving extra ss info to DB
           try {
-            await updatedbSS(modelhash, ssdescription['sstext'], 2);
+            await module.exports.updatedbSS(modelhash, ssdescription['sstext'], 2);
           } catch (error) {
             return reject({
               'status': 100,
@@ -514,7 +608,7 @@ module.exports = {
 
       // writing the temp.mod file
       try {
-        await createnewfile('temp.mod', modfilecontent);
+        await module.exports.createnewfile('temp.mod', modfilecontent);
       } catch (error) {
         return reject({
           'status': 100,
@@ -525,7 +619,7 @@ module.exports = {
       // normal preprocessing that mod file
       var dynarestdout = '';
       try {
-        dynarestdout += await preprocess('temp.mod', 2);
+        dynarestdout += await module.exports.preprocess('temp.mod', 2);
       } catch (error) {
         return reject({
           'status': 100,
@@ -535,8 +629,9 @@ module.exports = {
 
       // removing old JSON files and writing the correct file
       if (runtype == 1) {
+        //writes JSON file for perfect foresight
         try {
-          await removeoldfile('perforout.JSON');
+          await module.exports.removeoldfile('perforout.JSON');
         } catch (error) {
           return reject({
             'status': 100,
@@ -544,7 +639,7 @@ module.exports = {
           });
         }
         try {
-          await removeoldfile('perforin.JSON');
+          await module.exports.removeoldfile('perforin.JSON');
         } catch (error) {
           return reject({
             'status': 100,
@@ -552,7 +647,7 @@ module.exports = {
           });
         }
         try {
-          await createnewfile('perforin.JSON', JSON.stringify(jsonindata));
+          await module.exports.createnewfile('perforin.JSON', JSON.stringify(jsonindata));
         } catch (error) {
           return reject({
             'status': 100,
@@ -562,8 +657,9 @@ module.exports = {
       }
 
       if (runtype == 2) {
+        //writes JSON file for stochastic simulations
         try {
-          await removeoldfile('stochsimout.JSON');
+          await module.exports.removeoldfile('stochsimout.JSON');
         } catch (error) {
           return reject({
             'status': 100,
@@ -571,7 +667,7 @@ module.exports = {
           });
         }
         try {
-          await removeoldfile('stochsimin.JSON');
+          await module.exports.removeoldfile('stochsimin.JSON');
         } catch (error) {
           return reject({
             'status': 100,
@@ -579,7 +675,7 @@ module.exports = {
           });
         }
         try {
-          await createnewfile('stochsimin.JSON', JSON.stringify(jsonindata));
+          await module.exports.createnewfile('stochsimin.JSON', JSON.stringify(jsonindata));
         } catch (error) {
           return reject({
             'status': 100,
diff --git a/src/background.html b/src/background.html
deleted file mode 100755
index 16c184f27f6115b2364fbd5f1a94af9075ebe0ed..0000000000000000000000000000000000000000
--- a/src/background.html
+++ /dev/null
@@ -1,72 +0,0 @@
-<h1>Background</h1>
-
-<script type="text/javascript">
-	const {
-		ipcRenderer
-	} = require('electron');
-	const path = require('path');
-	const spawn = require('child_process').spawn;
-	const loadjsonfileatpath = require('./appModules').loadjsonfileatpath;
-	var origincalltype = 0;
-
-	// let the main thread know this thread is ready to process something
-	function ready() {
-		console.log('ready to do stuff')
-		ipcRenderer.send('ready')
-	}
-
-	async function main() {
-
-		// loading the paths
-		try {
-			var pathholder = await loadjsonfileatpath('dynareapp.JSON', './assets/');
-		} catch (error) {
-			console.log("Can't load dynareapp.JSON" + error);
-			return false;
-		}
-
-		//loading matlab
-		var exePath = path.resolve(__dirname, pathholder.matlabpath + '/bin/matlab');
-		const child = spawn(exePath, ['-nosplash'], {
-			shell: true
-		});
-
-		child.on('exit', function (code, signal) {
-			console.log('child process exited with ' +
-				`code ${code} and signal ${signal}`);
-		});
-
-		child.stdout.on('data', (data) => {
-			// console.log(`child stdout:\n${data}`);
-			//this captures the process stdout ">>" as a sign of readyness
-			if ((data[0] == 62) && (data[1] == 62) && (data[2] = 32)) {
-				if (origincalltype > 0) {
-					ipcRenderer.send('matlabready', origincalltype);
-				}
-				if (origincalltype == 0) {
-					origincalltype += 1;
-				}
-			} else {
-				ipcRenderer.send('stdoutmessage', data)
-			}
-		});
-
-		child.stderr.on('data', (data) => {
-			console.error(`child stderr:\n${data}`);
-		});
-		var filePathcd = path.resolve(__dirname, './assets/modfiles/');
-		child.stdin.setEncoding('utf-8');
-		child.stdin.write("addpath('" + pathholder.dynarepath + "/matlab');dynare_config;cd " + filePathcd + ";\n");
-
-		ipcRenderer.on('rundynarematlab', (event, arg) => {
-			origincalltype = arg[1];
-			child.stdin.write('run temp.m;run di_stochastic_simulations.m;\n');
-			child.stdin.on('drain', () => {});
-			ready()
-		});
-
-		ready()
-	}
-
-	main();
-</script>
\ No newline at end of file
diff --git a/src/background.js b/src/background.js
new file mode 100644
index 0000000000000000000000000000000000000000..7c9265a3925140445efe07c45624e1db9201cd0f
--- /dev/null
+++ b/src/background.js
@@ -0,0 +1,114 @@
+const path = require('path');
+const spawn = require('child_process').spawn;
+var origincalltype = 0;
+
+
+async function main() {
+  //this function loads matlab and then relays all commands to matlab
+
+  // loading the paths from fork process arguments
+  var matlabpath = process.argv[2];
+  var dynarepath = process.argv[3];
+
+
+  //loading matlab
+  var exePath = path.resolve(__dirname, matlabpath + '/bin/matlab');
+  const child = spawn(exePath, ['-nosplash'], {
+    shell: true
+  });
+
+  child.on('exit', function (code, signal) {
+    console.log('child process exited with ' +
+      `code ${code} and signal ${signal}`);
+  });
+
+  child.stdout.on('data', (data) => {
+    // console.log(`child stdout:\n${data}`);
+
+    // process.send("Receiving messages");
+
+    //this captures the process stdout ">>" as a sign of readyness
+    if ((data[0] == 62) && (data[1] == 62) && (data[2] = 32)) {
+      if (origincalltype == 0) {
+        mymessage = {
+          'messageid': 'matlabready',
+          'message': 0
+        };
+      }
+      if (origincalltype == 1) {
+        //this is the return from a stochastic simulation
+        mymessage = {
+          'messageid': 'matlabready',
+          'message': 1
+        };
+      }
+      if (origincalltype == 2) {
+        //this is the return from a perfect foresight computation
+        mymessage = {
+          'messageid': 'matlabready',
+          'message': 2
+        };
+      }
+
+      // process.send('matlabready', origincalltype);
+      process.send(mymessage);
+      // }
+      // if (origincalltype == 0) {
+      //   origincalltype += 1;
+      // }
+    } else {
+      // process.send('stdoutmessage', data)
+      mymessage = {
+        'messageid': 'stdoutmessage',
+        'message': `${data}`
+      };
+      process.send(mymessage);
+    }
+  });
+
+  child.stderr.on('data', (data) => {
+    console.error(`child stderr:\n${data}`);
+  });
+
+  var filePathcd = path.resolve(__dirname, './assets/modfiles/');
+  child.stdin.setEncoding('utf-8');
+  child.stdin.write("addpath('" + dynarepath + "/matlab');dynare_config;cd " + filePathcd + ";\n");
+
+  //process messages from parent
+  process.on('message', (pmessage) => {
+    // var messageprocess=0;
+
+
+
+    if (pmessage.messageid == 'rundynarematlab') {
+
+
+      if (pmessage.messagetype == 'stochastic') {
+        origincalltype = 1;
+        child.stdin.write('run temp.m;run di_stochastic_simulations.m;\n');
+        child.stdin.on('drain', () => {});
+      }
+
+      if (pmessage.messagetype == 'perfect') {
+        origincalltype = 2;
+        child.stdin.write('run temp.m;run di_perfect_foresight.m;\n');
+        child.stdin.on('drain', () => {});
+      }
+
+
+
+    }
+
+  });
+
+}
+
+// var currentPath = process.cwd();
+// mymessage = {
+//   'messageid': 'checkok',
+//   'message': currentPath
+// };
+
+// process.send(mymessage);
+
+main();
\ No newline at end of file
diff --git a/src/index.js b/src/index.js
index b21ab839ba83b36ad1651014e8e737d6ed69c6b9..6719a53356091fb1dea3747bb639b39091de8b52 100644
--- a/src/index.js
+++ b/src/index.js
@@ -8,6 +8,7 @@ const {
 const path = require('path');
 const url = require('url');
 const checkfileexistatpath = require('./appModules').checkfileexistatpath;
+const loadjsonfileatpath = require('./appModules').loadjsonfileatpath;
 
 
 // Handle creating/removing shortcuts on Windows when installing/uninstalling.
@@ -31,24 +32,24 @@ var initialsetupflag = 0;
 
 // Application menu
 
-let template = [
-  {
+let template = [{
     label: 'File',
-    submenu: [
-      {
-      label: 'New project',
-      accelerator: 'Command+N',
-      click: function () {
-        // write function to create a new project 
-                          }
+    submenu: [{
+        label: 'New project',
+        accelerator: 'Command+N',
+        click: function () {
+          // write function to create a new project
+          mainWindow.webContents.send('createnewproject', 'please!')
+        }
       },
       {
         label: 'Open project',
         //accelerator: 'Command+Q',
         click: function () {
           // write function to open a project 
-                            }
-        },]
+        }
+      },
+    ]
   },
   {
     label: 'Edit',
@@ -84,7 +85,8 @@ let template = [
         label: 'Select All',
         accelerator: 'CmdOrCtrl+A',
         selector: 'selectAll:'
-      }]
+      }
+    ]
   }
 ];
 
@@ -97,51 +99,13 @@ if (process.platform === 'darwin') {
       label: 'Quit',
       accelerator: 'Command+Q',
       click: function () {
-app.quit() }
-}] })
-}
-
-
-
-
-
-
-// // hand the tasks out to waiting threads
-function doIt() {
-  if (matlabreadyflag == 1) {
-    callMatlabtask()
-  } else {
-    console.log("Matlab is not ready !");
-  }
+        app.quit()
+      }
+    }]
+  })
 }
 
-function callMatlabtask() {
-  console.log('matlab task inside callMatlabtask yes')
-  console.log(available.length)
-  console.log(tasks.length)
-  while (available.length > 0 && tasks.length > 0) {
-    var task = tasks.shift();
-    available.shift().send('rundynarematlab', task);
-  }
-  mainWindow.webContents.send('status', available.length, tasks.length)
-}
 
-// Create a hidden background window
-function createBgWindow() {
-  result = new BrowserWindow({
-    "show": false,
-    webPreferences: {
-      nodeIntegration: true,
-      webSecurity: true
-    }
-  })
-  result.loadURL('file://' + __dirname + '/background.html')
-  result.webContents.openDevTools();
-  result.on('closed', () => {
-    console.log('background window closed')
-  });
-  return result
-}
 
 
 // main application window creation function
@@ -158,7 +122,7 @@ function createWindow() {
   });
   mainWindow.maximize();
   mainWindow.webContents.loadURL(`file://${__dirname}/index.html`); // #A
-  // mainWindow.webContents.openDevTools();
+  mainWindow.webContents.openDevTools();
 
   // Wait for 'ready-to-show' to display our window
   mainWindow.once('ready-to-show', () => {
@@ -238,47 +202,104 @@ app.on('ready', async function () {
 
   // Once setup is finished and the paths have been saved, we continue normal program
   initialsetupflag = 1;
-  
-  //menu creation 
-  // const menu = Menu.buildFromTemplate(template);
-  // Menu.setApplicationMenu(menu);
 
+  //menu creation 
   const appMenu = Menu.buildFromTemplate(template);
   Menu.setApplicationMenu(appMenu);
 
   // running main windows
   createWindow();
-  createBgWindow();
+  //createBgWindow();
 
-  // this message captures readiness to perform tasks
-  ipcMain.on('ready', (event, arg) => {
-    available.push(event.sender)
-    doIt()
-  })
 
-  // this messages captures the fact that matlab is ready
-  ipcMain.on('matlabready', (event, arg) => {
-    matlabreadyflag = 1;
-    console.log("Matlab is now ready ! " + arg);
-    if (arg == 111) {
-      mainWindow.webContents.send('stochasticsimfinish', arg);
+  //loading matlab et dynare paths
+  try {
+    var pathholder = await loadjsonfileatpath('dynareapp.JSON', './assets/');
+  } catch (error) {
+    console.log("Can't load dynareapp.JSON" + error);
+    return false;
+  }
+  var matlabpath = pathholder.matlabpath;
+  var dynarepath = pathholder.dynarepath;
+
+  //running matlab in a subprocess--------------------
+  const {
+    fork
+  } = require('child_process');
+  const program = path.join(__dirname, 'background.js');
+  const parameters = [matlabpath, dynarepath];
+  const options = {
+    stdio: ['pipe', 'pipe', 'pipe', 'ipc']
+  };
+  const child = fork(program, parameters, options);
+
+
+  // this message comes from either stochastic or perfect foresight and is a call to perform simulations
+  ipcMain.on('rundynarematlab', function (event, data) {
+
+    console.log('received ipc message from runprocesses');
+    console.log(data)
+
+
+    if (matlabreadyflag == 1) {
+      console.log("Matlab is ready !");
+      mymessage = {
+        'messageid': 'rundynarematlab',
+        'messagetype': data
+      };
+      matlabreadyflag = 0;
+      child.send(mymessage);
+    } else {
+      console.log("Matlab is not ready !");
     }
+    event.returnValue = 'I heard you!';
   });
 
-  // this message sends a message to the renderer and ultimately writes to the console output
-  ipcMain.on('stdoutmessage', (event, arg) => {
-    mainWindow.webContents.send('matlabmessagetoconsole', arg);
+  child.on('message', message => {
+
+    var messageprocess = 0;
+
+    if (message.messageid == 'checkok') {
+
+      console.log("backgrounok");
+
+    }
+
+
+    if (message.messageid == 'matlabready') {
+      matlabreadyflag = 1;
+      console.log("matlabready");
+      console.log(message.message);
+      messageprocess = 1;
+
+      if (message.message == 1) {
+        console.log('-=stochastic simulation completed=-');
+        mainWindow.webContents.send('stochasticsimfinish', message.message);
+      }
+
+      if (message.message == 2) {
+        console.log('-=perfect foresight computation completed=-');
+        mainWindow.webContents.send('perfectsimfinish', message.message);
+      }
+
+    }
+
+    if (message.messageid == 'stdoutmessage') {
+      console.log("stdoutmessage");
+      console.log(`${message.message}`);
+      mainWindow.webContents.send('matlabmessagetoconsole', message.message);
+      messageprocess = 1;
+    }
+
+    if (messageprocess == 0) {
+      console.log('Message from child:', message.message, 'with id:', message.messageid);
+    }
   });
 
 
 });
 
-// this message comes from either stochastic or perfect foresight and is a call to perform simulations
-ipcMain.on('performMatlab', function (event, arg) {
-  tasks.push(['task', arg]);
-  doIt();
-  event.returnValue = 'I heard you!';
-});
+
 
 // Quit when all windows are closed.
 app.on('window-all-closed', function () {
diff --git a/src/renderer.js b/src/renderer.js
index f8ec07c220b9d88d004561bc58fd8e10cece45a7..fa7995adb8593ae99b100f8c603fe21cf97e5718 100755
--- a/src/renderer.js
+++ b/src/renderer.js
@@ -1,9 +1,9 @@
-const {shell} = require('electron');
+// const {shell} = require('electron');
 const ipc = require('electron').ipcRenderer;
 const path = require('path');
 const sqlite3 = require('sqlite3').verbose();
 var short = require('short-uuid');
-const savetodb = require('./appModules').savetodb;
+// const savetodb = require('./appModules').savetodb;
 const showconsolealert= require('./appModules').showconsolealert;
 
 
@@ -15,140 +15,9 @@ function setfilename(val) {
   document.getElementById("uploadFile").value = fileName;
 }
 
-// function IsNumeric(input) { //is this a number ?
-//   input = input.replace(/\./g, '');
-//   return (input - 0) == input && ('' + input).trim().length > 0;
-// }
-
-// function popthis(title, content) { //pops an alert
-//   $.alert({
-//     title: title,
-//     content: content,
-//   });
-// }
-
-function sortbyfirst(a, b) {
-  if (a[0] === b[0]) {
-    return 0;
-  } else {
-    return (a[0] < b[0]) ? -1 : 1;
-  }
-}
-
-// const savetodb = (savemodel) => {
-
-//   var dbpath = path.resolve(__dirname, './assets/data/dynare.db');
-//   let db = new sqlite3.Database(dbpath, sqlite3.OPEN_READWRITE, (err) => {
-//     if (err) {
-//       console.error(err.message);
-//     } else {
-
-//       console.log('Connected to the dynare database.');
-
-//       let sql = `UPDATE dynaremodel SET modelname = ?, modelcode = ?, modelupdatedon = ? WHERE modelhash = ?;`;
-
-//       timestamp = new Date().toISOString().slice(0, 19).replace('T', ' ');
-
-//       //there is a table in the database, we get the latest model
-//       db.serialize(() => {
-//         // Queries scheduled here will be serialized.
-
-//         db.run(sql, [savemodel.modelname, savemodel.modelcode, timestamp, savemodel.modelhash], function(err) {
-//           if (err) {
-//             return console.error(err.message);
-//           }
-//           console.log(`Row(s) updated: ${this.changes}`);
-
-//         });
-
-//         db.close((err) => {
-//           if (err) {
-//             return console.error(err.message);
-//           }
-//         });
-
-
-//       });
-
-
-//     }
-
-//   });
 
-// }
 
 
-//autosave
-
-function autosavecall() {
-
-  var autosavemodel = {
-    'modelcode': window.editor_dynare.getValue(),
-    'modelhash': $('#codehash').val(),
-    'modelname': $('#codename').val()
-  };
-  savetodb(autosavemodel);
-
-  return;
-}
-
-$('#savecode').click(function() {
-
-  autosavecall()
-  return false;
-});
-
-
-// //button run code
-// $('#runcode').click(function(){
-//
-//   cl('Runcode');
-//
-//   const reply = ipc.sendSync('synchronous-message', 'Mr. Watson, come here.');
-//   cl(reply);
-//
-//   // var modelname = $('#codename').val();
-//   // if (modelname==null || modelname==""){
-//   //   $.alert({
-//   //     title: 'Project name is empty.',
-//   //     content: 'Please choose a name for this project...',
-//   // });
-//   // return false;
-//   // }
-//   //
-//   //
-//   // var modelcode = {
-//   //   'codetext':window.editor_dynare.getValue(),
-//   //   'codehash':$('#codehash').val(),
-//   //   'codename':modelname,
-//   //   'accesstype': 'savepreprocess'
-//   // };
-//   // $.ajax({
-//   //     url: $(editorform).attr('action'),
-//   //     headers: {'X-CSRFToken': $('#csrf_token').val()},
-//   //     type: "POST",
-//   //     data: modelcode,
-//   //     success: function(resp) {
-//   //
-//   //       if (resp.data.status == 999)
-//   //       {
-//   //         popthis('Error', resp.data.message);
-//   //       }
-//   //       else {
-//   //         $("textarea#preprocessorout").val(resp.data.message);
-//   //         $('.nav-tabs a[href="#console"]').tab('show');
-//   //         var currentdate = new Date();
-//   //         $('#classlist-form-messages').text('Last saved at: '+ currentdate);
-//   //       }
-//   //
-//   //     },
-//   //     error: function() {
-//   //       console.log('there was a problem checking the fields');
-//   //     }
-//   // });
-//   return false;
-// });
-
 
 const createNewModel = (dynaremodel) => {
   document.title = dynaremodel.modelname + ' Project';
@@ -266,14 +135,13 @@ const initapp = () => {
 
 initapp();
 
-var int;
-var autosaveinterval = 30000;
-//$(document).ready(function(){
-int = window.setInterval(autosavecall, autosaveinterval);
-//});
 
-ipc.on('matlabmessagetoconsole', (event, arg) => {
 
+ipc.on('matlabmessagetoconsole', (event, arg) => {
   showconsolealert(`${arg}`,0);
-
 });
+
+ipc.on('createnewproject', (event, arg) => {
+  console.log('got it!')
+  createnewproject();
+})
diff --git a/src/runprocesses.js b/src/runprocesses.js
new file mode 100644
index 0000000000000000000000000000000000000000..3a128c840a52dc23dfbf835df8d1c51984093fd2
--- /dev/null
+++ b/src/runprocesses.js
@@ -0,0 +1,316 @@
+const ipc = require('electron').ipcRenderer;
+const savetodb = require('./appModules').savetodb;
+const removeoldfile = require('./appModules').removeoldfile;
+const createnewfile = require('./appModules').createnewfile;
+const preprocess = require('./appModules').preprocess;
+const basedir = require('./appModules').basedir;
+const loadjsonfile = require('./appModules').loadjsonfile;
+const checkfileexist = require('./appModules').checkfileexist
+const preparejsonfiles = require('./appModules').preparejsonfiles;
+const cl = require('./appModules').cl;
+
+
+
+
+module.exports = {
+
+
+    setpreprocess: (modelcode) => {
+        // will save and preprocess the model
+
+        return new Promise(async function (resolve, reject) {
+
+            console.log('inside setpreprocess')
+            console.log(modelcode)
+
+            var dynaremodel = '';
+            // saving to database and retrieving the model from database
+            try {
+                dynaremodel = await savetodb(modelcode);
+            } catch (error) {
+                return reject({
+                    'status': 200,
+                    'message': error.toString()
+                });
+            }
+
+            // removing old files
+            try {
+                await removeoldfile(dynaremodel['modelhash'] + '_ini_steady_state_model.json');
+            } catch (error) {
+                return reject({
+                    'status': 200,
+                    'message': error.toString()
+                });
+            }
+            try {
+                await removeoldfile(dynaremodel['modelhash'] + '_ini.json');
+            } catch (error) {
+                return reject({
+                    'status': 200,
+                    'message': error.toString()
+                });
+            }
+            try {
+                await removeoldfile(dynaremodel['modelhash'] + '_ini.mod');
+            } catch (error) {
+                return reject({
+                    'status': 200,
+                    'message': error.toString()
+                });
+            }
+
+            // creating a modfile from editor input. Flag 'w' truncates if file already exits
+            try {
+                await createnewfile(dynaremodel['modelhash'] + '_ini.mod', dynaremodel['modelcode']);
+            } catch (error) {
+                return reject({
+                    'status': 200,
+                    'message': error.toString()
+                });
+            }
+
+            console.log('ok before preprocess')
+            console.log(dynaremodel)
+
+            // calling dynare preprocessor on modfile
+            var dynarestdout = '';
+            var preprocok = 1;
+            try {
+                dynarestdout += await preprocess(dynaremodel['modelhash'] + '_ini.mod', 3);
+            } catch (error) {
+                dynarestdout += error.toString();
+                preprocok = 0;
+            }
+
+            console.log('ok after preprocess')
+            console.log(dynarestdout)
+
+            if (preprocok == 0) {
+                return reject({
+                    'status': 100,
+                    'message': dynarestdout
+                });
+            } else {
+                return resolve({
+                    'status': 1,
+                    'message': dynarestdout
+                });
+            }
+
+        }); //end of main promise
+    },
+
+
+    setpreprocessmore: (modelcode) => {
+        // 'node side' of setstochastic
+
+        return new Promise(async function (resolve, reject) {
+
+            var dynaremodel = '';
+            // saving to database and retrieving the model from database
+            try {
+                dynaremodel = await savetodb(modelcode);
+            } catch (error) {
+                return reject({
+                    'status': 200,
+                    'message': error.toString()
+                });
+            }
+
+            // checking if SS info is available
+            var extrassinfo = (dynaremodel['modelextrassinfo'] != null && dynaremodel['modelextrassinfo'].length < 1) ? (dynaremodel['modelextrassinfo']) : null
+            var extrasstype = (dynaremodel['modelextrasstype'] != null && dynaremodel['modelextrasstype'] > 0) ? (dynaremodel['modelextrasstype']) : null
+
+            // removing old files
+            try {
+                await removeoldfile(dynaremodel['modelhash'] + '_ini_steady_state_model.json');
+            } catch (error) {
+                return reject({
+                    'status': 200,
+                    'message': error.toString()
+                });
+            }
+            try {
+                await removeoldfile(dynaremodel['modelhash'] + '_ini.json');
+            } catch (error) {
+                return reject({
+                    'status': 200,
+                    'message': error.toString()
+                });
+            }
+            try {
+                await removeoldfile(dynaremodel['modelhash'] + '_ini.mod');
+            } catch (error) {
+                return reject({
+                    'status': 200,
+                    'message': error.toString()
+                });
+            }
+
+            // creating a modfile from editor input. Flag 'w' truncates if file already exits
+            try {
+                await createnewfile(dynaremodel['modelhash'] + '_ini.mod', dynaremodel['modelcode']);
+            } catch (error) {
+                return reject({
+                    'status': 200,
+                    'message': error.toString()
+                });
+            }
+
+            // calling dynare preprocessor on modfile
+            var dynarestdout = '';
+            var preprocok = 1;
+            try {
+                dynarestdout += await preprocess(dynaremodel['modelhash'] + '_ini.mod', 1);
+            } catch (error) {
+                dynarestdout += error.toString();
+                preprocok = 0;
+            }
+            console.log(dynarestdout)
+
+
+            if (preprocok == 0) {
+                return reject({
+                    'status': 100,
+                    'message': dynarestdout
+                });
+            }
+
+            // loading JSON created by dynare preprocessor
+            try {
+                var dynaremodeljson = await loadjsonfile(dynaremodel['modelhash'] + '_ini.json');
+            } catch (error) {
+                // return popthis('Error', 'Unable to open file ' + basedir(dynaremodel['modelhash'] + '_ini.json'));
+                return reject({
+                    'status': 200,
+                    'message': 'Unable to open file ' + basedir(dynaremodel['modelhash'] + '_ini.json')
+                });
+            }
+            console.log(dynaremodeljson);
+            // showconsolealert(dynarestdout);
+
+            if (dynaremodeljson['exogenous'] == null || dynaremodeljson['exogenous'].length < 1) {
+                return reject({
+                    'status': 200,
+                    'message': 'You did not define any varexo for this model. Please define shocks before using any simulation.'
+                });
+            } else {
+                //we verify if a way to compute the steady state has been provided: either steady_state_block or initval
+                let checkexistflag = await checkfileexist(dynaremodel['modelhash'] + '_ini_steady_state_model.json');
+                if (checkexistflag == true) {
+                    return resolve({
+                        'status': 1,
+                        'message': dynarestdout,
+                        'modeljson': dynaremodeljson
+                    });
+                } else {
+                    // there is no steady_state_block, we check for initval block (for now we ignore steadystate file)
+                    let matchflag = 0;
+                    Object.keys(dynaremodeljson['statements']).forEach((key, index) => {
+                        if (dynaremodeljson['statements'][key]['statementName'] == 'init_val') {
+                            matchflag = 1;
+                        }
+                    });
+
+                    if (matchflag == 1) {
+                        // initval block found
+                        return resolve({
+                            'status': 2,
+                            'message': dynarestdout,
+                            'modeljson': dynaremodeljson
+                        });
+                    } else {
+                        // initval block not found: we provide the last known steadystate available in the database
+                        return resolve({
+                            'status': 201,
+                            'message': dynarestdout,
+                            'modeljson': dynaremodeljson,
+                            'extrassinfo': extrassinfo,
+                            'extrasstype': extrasstype
+                        });
+                    }
+                }
+            }
+        }); //end of main promise
+    },
+
+
+
+    runstochasticnode: (stosimval) => {
+
+        return new Promise(async function (resolve, reject) {
+
+            var modelhash = stosimval['modelhash'];
+            // preparing only the standardized JSON in data
+            var stochsimindata = {
+                'taylororder': stosimval['taylororder'],
+                'irfperiods': stosimval['irfperiods'],
+                'stochasticshocksdescription': stosimval['stochasticshocksdescription']
+            };
+
+            try {
+                await preparejsonfiles(modelhash, 2, stosimval, stochsimindata);
+            } catch (error) {
+                return reject(error);
+            }
+
+            const reply = ipc.sendSync('rundynarematlab', "stochastic");
+            cl(reply);
+
+            return resolve('Done runstochasticnode');
+
+
+        }); //end of main promise
+
+
+    },
+
+
+
+    runperfectnode: (perfectval) => {
+
+        return new Promise(async function (resolve, reject) {
+
+
+            console.log('inside runperfectnode');
+
+            var modelhash = perfectval['modelhash'];
+            // preparing only the standardized JSON in data
+            var perfectindata = {
+                'exonum': perfectval['exonum'],
+                'simperiods': perfectval['simperiods'],
+                'permanentshockexist': perfectval['permanentshockexist'],
+                'transitoryshockexist': perfectval['transitoryshockexist'],
+                'nonanticipatedshockexist': perfectval['nonanticipatedshockexist'],
+                'delayexist': perfectval['delayexist'],
+                'permanentshocksdescription': perfectval['permanentshocksdescription'],
+                'shocksdescription': perfectval['shocksdescription'],
+                'nonanticipmatrix': perfectval['nonanticipmatrix']
+            };
+
+
+            try {
+                await preparejsonfiles(modelhash, 1, perfectval, perfectindata);
+            } catch (error) {
+                return reject(error);
+            }
+
+            const reply = ipc.sendSync('rundynarematlab', "perfect");
+            cl(reply);
+
+
+
+
+            // console.log('runstochasticnode last');
+            return resolve('Done runperfectnode !');
+
+
+        }); //end of main promise
+
+
+    }
+
+
+
+} //module end
\ No newline at end of file
diff --git a/src/static/js/dynareinterface.js b/src/static/js/dynareinterface.js
index 051c985ba52f7f082e18f97aabe70fde097e5639..b64f58f8a70597cbadd532f086a87f5ab2c03b74 100644
--- a/src/static/js/dynareinterface.js
+++ b/src/static/js/dynareinterface.js
@@ -1,5 +1,7 @@
+const setpreprocess = require('./runprocesses').setpreprocess;
+const newmodelindb = require('./appModules').newmodelindb;
 
-
+// const showconsolealert = require('./appModules').showconsolealert;
 
 
 // create a file download link
@@ -16,7 +18,7 @@ function download(filename, text) {
 
 
 //new project on click function
-function createnewproject(){
+async function createnewproject(){
 
   editorformurl=$(editorform).attr('action');
 
@@ -31,39 +33,41 @@ function createnewproject(){
       '</form>',
       buttons: {
           formSubmit: {
-              text: 'Create',
-              btnClass: 'btn-blue',
-              action: function () {
-                  var newname = this.$content.find('.newprojectname').val();
-                  if(!newname){
-                      $.alert('Please provide a valid name');
-                      return false;
+            text: 'Create',
+            btnClass: 'btn-blue',
+            action: async function () {
+                var newname = this.$content.find('.newprojectname').val();
+                if (!newname) {
+                  $.alert('Please provide a valid name');
+                  return false;
+                }
+                // var modelcode = {
+                //   'codetext': 'nothing',
+                //   'codehash': 'nothing',
+                //   'codename': newname,
+                //   'accesstype': 'newproject'
+                // };
+                // calling the 'node side'
+                try {
+                  var resp = await newmodelindb(newname);
+                } catch (error) {
+                  if (error.status == 200) {
+                    console.log("200")
+                    return popthis('Error', error.message);
+                  } else if (error.status == 100) {
+                    console.log("100")
+                    showconsolealert(error.message, 1);
+                    console.log('console error');
+                    return false;
+                  } else if (error.status == 999) {
+                    popthis('Error', resp.message);
                   }
-                  var modelcode = {
-                    'codetext':'nothing',
-                    'codehash':'nothing',
-                    'codename':newname,
-                    'accesstype': 'newproject'
-                  };
-                  return $.ajax({
-                      url: editorformurl,
-                      headers: {'X-CSRFToken': $('#csrf_token').val()},
-                      type: "POST",
-                      data: modelcode,
-                      success: function(resp) {
-                        // var currentdate = new Date();
-                        // $('#classlist-form-messages').text('Last saved at: '+ currentdate);
-                        if (resp.data.status==1){
-                          //we reload the page
-                          var loc = window.location;
-                          //this will reload with get forcing python to request the latest model from db
-                          window.location = loc.protocol + '//' + loc.host + loc.pathname + loc.search;
-                        }
-                      },
-                      error: function() {
-                        console.log('there was a problem checking the fields');
-                      }
-                  });
+                }
+
+                var loc = window.location;
+                //this will reload with get forcing python to request the latest model from db
+                window.location = loc.protocol + '//' + loc.host + loc.pathname + loc.search;
+
               }
           },
           cancel: function () {
@@ -83,48 +87,146 @@ function createnewproject(){
 
 }
 
+var int;
+var autosaveinterval = 30000;
+//$(document).ready(function(){
+int = window.setInterval(autosavecall, autosaveinterval);
+//});
+
+async function autosavecall() {
+
+  var modelcode = {
+    'modelcode': window.editor_dynare.getValue(),
+    'modelhash': $('#codehash').val(),
+    'modelname': $('#codename').val()
+  };
+
+      // calling the 'node side'
+      try {
+        var resp = await savetodb(modelcode);
+      } catch (error) {
+        if (error.status == 200) {
+          console.log("200")
+          return popthis('Error', error.message);
+        } else if (error.status == 100) {
+          console.log("100")
+          showconsolealert(error.message, 1);
+          console.log('console error');
+          return false;
+        } else if (error.status == 999) {
+          popthis('Error', resp.message);
+        }
+      }
+  
+      
+      // console.log(resp)
+  
+        var currentdate = new Date();
+        $('#classlist-form-messages').text('Last saved at: ' + currentdate);
+
+        return false;
+  }
+
+
+
+$('#savecode').click(async function () {
 //button save code
-// $('#savecode').click(function(){
-//
-//   var modelname = $('#codename').val();
-//   if (modelname==null || modelname==""){
-//     $.alert({
-//       title: 'Project name is empty.',
-//       content: 'Please choose a name for this project...',
-//   });
-//   return false;
-//   }
-//
-//   var modelcode = {
-//     'codetext':window.editor_dynare.getValue(),
-//     'codehash':$('#codehash').val(),
-//     'codename':modelname,
-//     'accesstype': 'save'
-//   };
-//
-//   savecodeButton(modelcode);
-//
-//
-//   // console.log(modelcode)
-//   // $.ajax({
-//   //     url: $(editorform).attr('action'),
-//   //     headers: {'X-CSRFToken': $('#csrf_token').val()},
-//   //     type: "POST",
-//   //     data: modelcode,
-//   //     success: function(resp) {
-//   //
-//   //       if (resp.data.status == 999)
-//   //       {
-//   //         popthis('Error', resp.data.message);
-//   //       }
-//   //       else {
-//   //         var currentdate = new Date();
-//   //         $('#classlist-form-messages').text('Last saved at: '+ currentdate);
-//   //       }
-//   //     },
-//   //     error: function() {
-//   //       console.log('there was a problem checking the fields');
-//   //     }
-//   // });
-//   return false;
-// });
+
+  var modelname = $('#codename').val();
+  if (modelname==null || modelname==""){
+    $.alert({
+      title: 'Project name is empty.',
+      content: 'Please choose a name for this project...',
+  });
+  return false;
+  }
+
+  var modelcode = {
+    'modelcode':window.editor_dynare.getValue(),
+    'modelhash':$('#codehash').val(),
+    'modelname':modelname
+    //'accesstype': 'save'
+  };
+
+    // calling the 'node side'
+    try {
+      var resp = await savetodb(modelcode);
+    } catch (error) {
+      if (error.status == 200) {
+        console.log("200")
+        return popthis('Error', error.message);
+      } else if (error.status == 100) {
+        console.log("100")
+        showconsolealert(error.message, 1);
+        console.log('console error');
+        return false;
+      } else if (error.status == 999) {
+        popthis('Error', resp.message);
+      }
+    }
+
+    console.log(resp)
+
+
+      var currentdate = new Date();
+      $('#classlist-form-messages').text('Last saved at: ' + currentdate);
+
+  return false;
+});
+
+
+
+
+
+
+
+//button run code
+
+$('#runcode').click(async function () {
+
+  console.log('Runcode');
+
+  // const reply = ipc.sendSync('synchronous-message', 'Mr. Watson, come here.');
+  // console.log(reply);
+
+  var modelname = $('#codename').val();
+  if (modelname==null || modelname==""){
+    $.alert({
+      title: 'Project name is empty.',
+      content: 'Please choose a name for this project...',
+  });
+  return false;
+  }
+  
+  
+  var modelcode = {
+    'modelcode':window.editor_dynare.getValue(),
+    'modelhash':$('#codehash').val(),
+    'modelname':$('#codename').val()
+    // 'accesstype': 'savepreprocess'
+  };
+
+//calling the node side
+try {
+  var resp = await setpreprocess(modelcode);
+} catch (error) {
+  if (error.status == 200) {
+    console.log("200")
+    return popthis('Error', error.message);
+  } else if (error.status == 100) {
+    console.log("100")
+    showconsolealert(error.message, 1);
+    console.log('console error');
+    return false;
+  }
+}
+
+showconsolealert(resp.message, 1);
+
+//displays the new save time
+var currentdate = new Date();
+$('#classlist-form-messages').text('Last saved at: ' + currentdate);
+
+
+  return false;
+});
diff --git a/src/static/js/perfectforesight.js b/src/static/js/perfectforesight.js
index 2b4a743548cb26183a2de85d9d697baa28fa552a..d6a83c3e2008025d22fe1a08467f12c12e58ac29 100644
--- a/src/static/js/perfectforesight.js
+++ b/src/static/js/perfectforesight.js
@@ -1,11 +1,25 @@
+const ipcperf = require('electron').ipcRenderer;
+const setpreprocessmore = require('./runprocesses').setpreprocessmore;
+const runperfectnode = require('./runprocesses').runperfectnode;
+
+
+
 var matlabdata;
 var numshocks = [];
 for (i = 0; i < 1000; i++) {
   numshocks[i] = 0;
 }
 
+function sortbyfirst(a, b) {
+  if (a[0] === b[0]) {
+    return 0;
+  } else {
+    return (a[0] < b[0]) ? -1 : 1;
+  }
+}
+
 //------------------------------------------------------------@@@button set perfect
-$('#setperfect').click(function() {
+$('#setperfect').click(async function () {
 
   var modelname = $('#codename').val();
   if (modelname == null || modelname == "") {
@@ -18,95 +32,86 @@ $('#setperfect').click(function() {
 
 
   var modelcode = {
-    'codetext': window.editor_dynare.getValue(),
-    'codehash': $('#codehash').val(),
-    'codename': modelname,
-    'accesstype': 'setperfect'
+    'modelcode': window.editor_dynare.getValue(),
+    'modelhash': $('#codehash').val(),
+    'modelname': modelname
   };
-  $.ajax({
-    url: $(editorform).attr('action'),
-    headers: {
-      'X-CSRFToken': $('#csrf_token').val()
-    },
-    type: "POST",
-    data: modelcode,
-    success: function(resp) {
-      $("textarea#preprocessorout").val(resp.data.message);
-      $('.nav-tabs a[href="#console"]').tab('show');
-      var currentdate = new Date();
-      $('#classlist-form-messages').text('Last saved at: ' + currentdate);
-
-      // sucess handling
-
-      if (((resp.data.status == 1) || (resp.data.status == 2)) || (resp.data.status == 201)) {
-        //the model has exo shocks: we make a table
-        // if a steady state has not been provided if ask extra info on that
-        dynaremodel = resp.modeljson;
-
-        // steady-state compute table
-        document.getElementById("perforssinittable").innerHTML = "";
-        if (resp.data.status == 201) {
-          var extrassinfo = "";
-          var extrasshelp = "";
-          if (resp.extrassinfo !== null) {
-            extrassinfo = resp.extrassinfo;
-            extrasshelp = " (the last known steady-state info have been loaded below)"
-          }
-          var extrasstype = "";
-          if (resp.extrasstype == 1) {
-            extrasstype = 'checked';
-          }
 
-          sscomputeeendo = `
+  // calling the 'node side'
+  try {
+    var resp = await setpreprocessmore(modelcode);
+  } catch (error) {
+    if (error.status == 200) {
+      console.log("200")
+      return popthis('Error', error.message);
+    } else if (error.status == 100) {
+      console.log("100")
+      showconsolealert(error.message, 1);
+      console.log('console error');
+      return false;
+    } else if (error.status == 999) {
+      popthis('Error', resp.message);
+    }
+  }
+
+  showconsolealert(resp.message, 1);
+
+
+  // $("textarea#preprocessorout").val(resp.data.message);
+  // $('.nav-tabs a[href="#console"]').tab('show');
+
+  var currentdate = new Date();
+  $('#classlist-form-messages').text('Last saved at: ' + currentdate);
+
+  // sucess handling
+
+
+  //the model has exo shocks: we make a table
+  // if a steady state has not been provided if ask extra info on that
+  dynaremodel = resp.modeljson;
+
+  // steady-state compute table
+  document.getElementById("perforssinittable").innerHTML = "";
+  if (resp.status == 201) {
+    var extrassinfo = "";
+    var extrasshelp = "";
+    if (resp.extrassinfo !== null) {
+      extrassinfo = resp.extrassinfo;
+      extrasshelp = " (the last known steady-state info have been loaded below)"
+    }
+    var extrasstype = "";
+    if (resp.extrasstype == 1) {
+      extrasstype = 'checked';
+    }
+
+    sscomputeeendo = `
             <h4>Steady state</h4>
             <p style="color:#3399CC">You did not provide any way to compute the steady-state. Please specify a way to compute the steady-state` + extrasshelp + `.</p>
             <div class="form-group no-margin"> <textarea class="form-control" id="perforSSblock" name="perforSSblock" placeholder="Steady-state equations;" rows="7">` + extrassinfo + `</textarea> </div>
             <div class="form-group no-margin"><label><input type="checkbox" name="issteadystatelock" id="issteadystateblock"` + extrasstype + `/> Check if the above will compute the exact steady-state (will be interpreted as a <span style="font-style: italic;">steady_state_model</span> block). Leave unchecked if the above should be used as a starting point to compute the steady-state (will be interpreted as an <span style="font-style: italic;">initval</span> block).</label></div>
             <input id="modelsteadystatestatus" name="modelsteadystatestatus" value="99" type="hidden">
             `;
-        } else if (resp.data.status == 2) {
-          sscomputeeendo = `
+  } else if (resp.status == 2) {
+    sscomputeeendo = `
             <input id="modelsteadystatestatus" name="modelsteadystatestatus" value="55" type="hidden">
             `;
-        } else {
-          sscomputeeendo = `
+  } else {
+    sscomputeeendo = `
             <input id="modelsteadystatestatus" name="modelsteadystatestatus" value="0" type="hidden">
             `;
-        }
-        document.getElementById("perforssinittable").innerHTML = sscomputeeendo;
-
-        document.getElementById("model_endonum").value = (dynaremodel.endogenous).length;
-        document.getElementById("model_exonum").value = (dynaremodel.exogenous).length;
-        $('#perforModal').modal('show');
-      }
-
-
-      // errors handling
-      if (resp.data.status == 200) {
-        //the model has no exo/shocks
-        $.alert({
-          title: 'No exogenous warning.',
-          content: 'You did not define any varexo for this model. Please define shocks before using perfect foresight simulation.',
-        });
-      }
-
-      if (resp.data.status == 999)
-      {
-        popthis('Error', resp.data.message);
-      }
+  }
+  document.getElementById("perforssinittable").innerHTML = sscomputeeendo;
+  document.getElementById("model_endonum").value = (dynaremodel.endogenous).length;
+  document.getElementById("model_exonum").value = (dynaremodel.exogenous).length;
+  $('#perforModal').modal('show');
 
-    },
-    error: function() {
-      console.log('there was a problem checking the fields');
-    }
-  });
   return false;
 });
 
 
 
 //--------------------------------------------@@@button add sequence of shocks code
-$('#addshock').click(function() {
+$('#addshock').click(function () {
   var rowindex;
   var xcond = 0;
   var iter = 0;
@@ -164,7 +169,7 @@ function SomeDeleteRowFunction(o, rowindex) {
 
 
 //----------------------------------------------------@@@button run perfect: verifies input then runs perfect foresight simulation
-$('#runperfect').click(function() {
+$('#runperfect').click(async function () {
   //getting all the necessary info from the forms
   var endonum = $('#model_endonum').val();
   var exonum = $('#model_exonum').val();
@@ -734,7 +739,8 @@ $('#runperfect').click(function() {
         'jsontest': ["12"]
       };
 
-      var perforvaldata = JSON.stringify(perforval);
+      // var perforvaldata = JSON.stringify(perforval);
+
       $("#outputtable").empty();
       $("#plotbtn").empty();
       $("#plotbox").empty();
@@ -745,110 +751,156 @@ $('#runperfect').click(function() {
       document.getElementById('inner').appendChild(div);
       $('.nav-tabs a[href="#output"]').tab('show');
 
-      // ajaxing content
 
-      $.ajax({
-        url: $(editorform).attr('action'),
-        headers: {
-          'X-CSRFToken': $('#csrf_token').val()
-        },
-        type: "PUT",
-        contentType: "application/json",
-        dataType: 'json',
-        data: perforvaldata,
-        success: function(resp) {
-          var currentout = $("textarea#preprocessorout").val();
+
+      // calling the 'node side'
+      try {
+        var resp = await runperfectnode(perforval);
+      } catch (error) {
+        console.log(error)
+        if (error.status == 2) {
+          $('.nav-tabs a[href="#console"]').tab('show');
+          $("#inner").empty();
+          document.getElementById("inner").innerHTML = '<p style="color:red;">Matlab errors found. See console.</p>';
+          return false;
+
+        } else if (error.status == 3) {
           currentout = currentout + resp.data.message;
-          $("textarea#preprocessorout").val(currentout);
-
-          if (resp.data.status == 1) { //everything went ok
-            matlabdata = resp.data.matlabdata
-            var endovarname;
-
-            // creating output content
-            var sstbl1 = `
-                <section>
-                <h2>Steady state results</h2>
-                <table class="table table-striped table-hover">
-                <thead>
-                <tr>
-                <th>#</th>
-                <th>Endogenous variable</th>
-                <th>Initial Steady state</th>
-                <th>Final Steady state</th>
-                </tr>
-                </thead>
-                <tbody>
-                `;
-
-            var plotdropdown = `
-                <section>
-                <h2>Plots</h2>
-                <div class="btn-group" role="group" aria-label="...">
-                <div class="btn-group" role="group">
-                  <button id="plotbtn" class="btn btn-primary btn-lg dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
-                    Select graph <span class="caret"></span><span class="sr-only">Toggle Dropdown</span>
-                  </button>
-                  <ul class="dropdown-menu" aria-labelledby="plotbtn">
-                  <li class="dropdown-header">Endogenous variables:</li>
-                  `;
-            y = 0;
-            for (x in matlabdata.endo_names) {
-              endovarname = matlabdata.endo_names[x].trim();
-              plotdropdown += '<li onclick="plotmethis(&quot;' + endovarname + '&quot;)"><a href="#stophere">' + endovarname + '</a></li>';
-              y = y + 1;
-              sstbl1 += '<tr><th scope="row">' + y + '</th>';
-              sstbl1 += "<td>" + endovarname + "</td>";
-              sstbl1 += "<td>" + matlabdata.steady_state1[x] + "</td>";
-              sstbl1 += "<td>" + matlabdata.steady_state2[x] + "</td>";
-            }
-            plotdropdown +='</ul></div>';
-            plotdropdown +=`
-            <div class="btn-group" role="group">
-            <button id="exportbtn" class="btn btn-primary btn-lg dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
-              Export data <span class="caret"></span><span class="sr-only">Toggle Dropdown</span>
-            </button>
-            <ul class="dropdown-menu" aria-labelledby="exportbtn">
-            <li class="dropdown-header">Select file type:</li>
-            <li onclick="exportfile(&quot;json&quot;)"><a href="#stophere">Export to JSON</a></li>
-            <li onclick="exportfile(&quot;csv&quot;)"><a href="#stophere">Export to CSV</a></li>
-            </ul>
-            </div>`;
-
-            plotdropdown += `
-            </div>
-                </section>
-                `;
-            sstbl1 += "</tbody></table></section>";
-            $("#inner").empty();
-            document.getElementById("outputtable").innerHTML = sstbl1;
-            document.getElementById("plotbtn").innerHTML = plotdropdown;
-
-
-            plotmethis(matlabdata.endo_names[0].trim());
-
-          } else if (resp.data.status == 2) { //there were matlab errors
-            $('.nav-tabs a[href="#console"]').tab('show');
-            $("#inner").empty();
-            document.getElementById("inner").innerHTML = '<p style="color:red;">Matlab errors found. See console.</p>';
-          } else if (resp.data.status == 3) {
-            currentout = currentout + resp.data.message;
-            $("textarea#preprocessorout").val(currentout + '\n \n The preprocessor could nor process your input. Please check the extra steady-state information you provided.');
-            $('.nav-tabs a[href="#console"]').tab('show');
-            $("#inner").empty();
-            document.getElementById("inner").innerHTML = '<p style="color:red;">Preprocessor errors found. See console.</p>';
-          }
-        },
-        error: function() {
-          console.log('there was a problem checking the fields');
+          $("textarea#preprocessorout").val(currentout + '\n \n The preprocessor could nor process your input. Please check the extra steady-state information you provided.');
+          $('.nav-tabs a[href="#console"]').tab('show');
+          $("#inner").empty();
+          document.getElementById("inner").innerHTML = '<p style="color:red;">Preprocessor errors found. See console.</p>';
+          return false;
         }
-      });
+      }
+
+
+
+
+
+      // ajaxing content
+
+      // $.ajax({
+      // url: $(editorform).attr('action'),
+      // headers: {
+      //   'X-CSRFToken': $('#csrf_token').val()
+      // },
+      // type: "PUT",
+      // contentType: "application/json",
+      // dataType: 'json',
+      // data: perforvaldata,
+      // success: function (resp) {
+
+
+      // var currentout = $("textarea#preprocessorout").val();
+      // currentout = currentout + resp.data.message;
+      // $("textarea#preprocessorout").val(currentout);
+
+
+
+      // if (resp.data.status == 2) { //there were matlab errors
+
+      // } else if (resp.data.status == 3) {
+
+      // }
+
+
       return false;
     }
   }
 
 });
 
+
+
+ipcperf.on('perfectsimfinish', (event, arg) => {
+
+  async function finishperfect() {
+
+    try {
+      matlabdata = await loadjsonfile('perforout.JSON');
+    } catch (error) {
+      return popthis('Error', 'Unable to open perforout.JSON to process:' + error);
+    }
+
+
+    // if (resp.data.status == 1) { //everything went ok
+      var endovarname;
+
+      // creating output content
+      var sstbl1 = `
+          <section>
+          <h2>Steady state results</h2>
+          <table class="table table-striped table-hover">
+          <thead>
+          <tr>
+          <th>#</th>
+          <th>Endogenous variable</th>
+          <th>Initial Steady state</th>
+          <th>Final Steady state</th>
+          </tr>
+          </thead>
+          <tbody>
+          `;
+
+      var plotdropdown = `
+          <section>
+          <h2>Plots</h2>
+          <div class="btn-group" role="group" aria-label="...">
+          <div class="btn-group" role="group">
+            <button id="plotbtn" class="btn btn-primary btn-lg dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+              Select graph <span class="caret"></span><span class="sr-only">Toggle Dropdown</span>
+            </button>
+            <ul class="dropdown-menu" aria-labelledby="plotbtn">
+            <li class="dropdown-header">Endogenous variables:</li>
+            `;
+      y = 0;
+      for (x in matlabdata.endo_names) {
+        endovarname = matlabdata.endo_names[x].trim();
+        plotdropdown += '<li onclick="plotmethis(&quot;' + endovarname + '&quot;)"><a href="#stophere">' + endovarname + '</a></li>';
+        y = y + 1;
+        sstbl1 += '<tr><th scope="row">' + y + '</th>';
+        sstbl1 += "<td>" + endovarname + "</td>";
+        sstbl1 += "<td>" + matlabdata.steady_state1[x] + "</td>";
+        sstbl1 += "<td>" + matlabdata.steady_state2[x] + "</td>";
+      }
+      plotdropdown += '</ul></div>';
+      plotdropdown += `
+      <div class="btn-group" role="group">
+      <button id="exportbtn" class="btn btn-primary btn-lg dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+        Export data <span class="caret"></span><span class="sr-only">Toggle Dropdown</span>
+      </button>
+      <ul class="dropdown-menu" aria-labelledby="exportbtn">
+      <li class="dropdown-header">Select file type:</li>
+      <li onclick="exportfile(&quot;json&quot;)"><a href="#stophere">Export to JSON</a></li>
+      <li onclick="exportfile(&quot;csv&quot;)"><a href="#stophere">Export to CSV</a></li>
+      </ul>
+      </div>`;
+
+      plotdropdown += `
+      </div>
+          </section>
+          `;
+      sstbl1 += "</tbody></table></section>";
+      $("#inner").empty();
+      document.getElementById("outputtable").innerHTML = sstbl1;
+      document.getElementById("plotbtn").innerHTML = plotdropdown;
+
+
+      plotmethis(matlabdata.endo_names[0].trim());
+
+    
+
+  }
+
+
+
+  finishperfect();
+
+
+
+});
+
 // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ output
 
 // graph plotter
@@ -900,7 +952,7 @@ function exportfile(exporttype) {
     var csvarray = [];
     for (var mykey in matlabdata.endo_names) {
       csvarray.push(matlabdata.endo_simul[matlabdata.endo_names[mykey]]);
-      cl(mykey);
+      console.log(mykey);
     }
     var transpose = csvarray[0].map((col, i) => csvarray.map(row => row[i]));
     for (itr = 0; itr < transpose.length; itr++) {
diff --git a/src/static/js/stochastic.js b/src/static/js/stochastic.js
index 7d9bc49acd47c6f8adeb1b32a35c5aadc4db7046..c90a9f87d32d547670845c56cac54a2fc3df07a8 100644
--- a/src/static/js/stochastic.js
+++ b/src/static/js/stochastic.js
@@ -1,21 +1,19 @@
 const ipc = require('electron').ipcRenderer;
-// const path = require('path');
-var fs = require('fs');
-const savetodb = require('./appModules').savetodb;
-const updatedbSS = require('./appModules').updatedbSS;
-const basedir = require('./appModules').basedir;
-const cl = require('./appModules').cl;
-const popthis = require('./appModules').popthis;
-const createnewfile = require('./appModules').createnewfile;
-const removeoldfile = require('./appModules').removeoldfile;
-const loadjsonfile = require('./appModules').loadjsonfile;
-const checkfileexist = require('./appModules').checkfileexist
-const preprocess = require('./appModules').preprocess;
 const showconsolealert = require('./appModules').showconsolealert;
 const IsNumeric = require('./appModules').IsNumeric;
-const preparejsonfiles = require('./appModules').preparejsonfiles;
-const remote = require('electron').remote;
-const app = remote.app;
+const loadjsonfile = require('./appModules').loadjsonfile;
+const popthis = require('./appModules').popthis;
+// const setpreprocessmore = require('./runprocesses').setpreprocessmore;
+const runstochasticnode = require('./runprocesses').runstochasticnode;
+
+// const path = require('path');
+// var fs = require('fs');
+// const updatedbSS = require('./appModules').updatedbSS;
+// 
+// const remote = require('electron').remote;
+// const app = remote.app;
+
+
 
 var stomatlabdata;
 var stonumshocks = [];
@@ -25,191 +23,6 @@ for (i = 0; i < 1000; i++) {
 
 // cl('hello stochastic ')
 
-
-//button run code
-$('#runcode').click(function () {
-
-  console.log('Runcode');
-
-  const reply = ipc.sendSync('synchronous-message', 'Mr. Watson, come here.');
-  console.log(reply);
-
-  // var modelname = $('#codename').val();
-  // if (modelname==null || modelname==""){
-  //   $.alert({
-  //     title: 'Project name is empty.',
-  //     content: 'Please choose a name for this project...',
-  // });
-  // return false;
-  // }
-  //
-  //
-  // var modelcode = {
-  //   'codetext':window.editor_dynare.getValue(),
-  //   'codehash':$('#codehash').val(),
-  //   'codename':modelname,
-  //   'accesstype': 'savepreprocess'
-  // };
-  // $.ajax({
-  //     url: $(editorform).attr('action'),
-  //     headers: {'X-CSRFToken': $('#csrf_token').val()},
-  //     type: "POST",
-  //     data: modelcode,
-  //     success: function(resp) {
-  //
-  //       if (resp.data.status == 999)
-  //       {
-  //         popthis('Error', resp.data.message);
-  //       }
-  //       else {
-  //         $("textarea#preprocessorout").val(resp.data.message);
-  //         $('.nav-tabs a[href="#console"]').tab('show');
-  //         var currentdate = new Date();
-  //         $('#classlist-form-messages').text('Last saved at: '+ currentdate);
-  //       }
-  //
-  //     },
-  //     error: function() {
-  //       console.log('there was a problem checking the fields');
-  //     }
-  // });
-  return false;
-});
-
-async function setstochasticnode(modelcode) {
-  // 'node side' of setstochastic
-
-  return new Promise(async function (resolve, reject) {
-
-    var dynaremodel = '';
-    // saving to database and retrieving the model from database
-    try {
-      dynaremodel = await savetodb(modelcode);
-    } catch (error) {
-      return reject({
-        'status': 200,
-        'message': error.toString()
-      });
-    }
-
-    // checking if SS info is available
-    var extrassinfo = (dynaremodel['modelextrassinfo'] != null && dynaremodel['modelextrassinfo'].length < 1) ? (dynaremodel['modelextrassinfo']) : null
-    var extrasstype = (dynaremodel['modelextrasstype'] != null && dynaremodel['modelextrasstype'] > 0) ? (dynaremodel['modelextrasstype']) : null
-
-    // removing old files
-    try {
-      await removeoldfile(dynaremodel['modelhash'] + '_ini_steady_state_model.json');
-    } catch (error) {
-      return reject({
-        'status': 200,
-        'message': error.toString()
-      });
-    }
-    try {
-      await removeoldfile(dynaremodel['modelhash'] + '_ini.json');
-    } catch (error) {
-      return reject({
-        'status': 200,
-        'message': error.toString()
-      });
-    }
-    try {
-      await removeoldfile(dynaremodel['modelhash'] + '_ini.mod');
-    } catch (error) {
-      return reject({
-        'status': 200,
-        'message': error.toString()
-      });
-    }
-
-    // creating a modfile from editor input. Flag 'w' truncates if file already exits
-    try {
-      await createnewfile(dynaremodel['modelhash'] + '_ini.mod', dynaremodel['modelcode']);
-    } catch (error) {
-      return reject({
-        'status': 200,
-        'message': error.toString()
-      });
-    }
-
-    // calling dynare preprocessor on modfile
-    var dynarestdout = '';
-    var preprocok = 1;
-    try {
-      dynarestdout += await preprocess(dynaremodel['modelhash'] + '_ini.mod', 1);
-    } catch (error) {
-      dynarestdout += error.toString();
-      preprocok = 0;
-    }
-    console.log(dynarestdout)
-
-
-    if (preprocok == 0) {
-      return reject({
-        'status': 100,
-        'message': dynarestdout
-      });
-    }
-
-    // loading JSON created by dynare preprocessor
-    try {
-      var dynaremodeljson = await loadjsonfile(dynaremodel['modelhash'] + '_ini.json');
-    } catch (error) {
-      // return popthis('Error', 'Unable to open file ' + basedir(dynaremodel['modelhash'] + '_ini.json'));
-      return reject({
-        'status': 200,
-        'message': 'Unable to open file ' + basedir(dynaremodel['modelhash'] + '_ini.json')
-      });
-    }
-    console.log(dynaremodeljson);
-    // showconsolealert(dynarestdout);
-
-    if (dynaremodeljson['exogenous'] == null || dynaremodeljson['exogenous'].length < 1) {
-      return reject({
-        'status': 200,
-        'message': 'You did not define any varexo for this model. Please define shocks before using any simulation.'
-      });
-    } else {
-      //we verify if a way to compute the steady state has been provided: either steady_state_block or initval
-      let checkexistflag = await checkfileexist(dynaremodel['modelhash'] + '_ini_steady_state_model.json');
-      if (checkexistflag == true) {
-        return resolve({
-          'status': 1,
-          'message': dynarestdout,
-          'modeljson': dynaremodeljson
-        });
-      } else {
-        // there is no steady_state_block, we check for initval block (for now we ignore steadystate file)
-        let matchflag = 0;
-        Object.keys(dynaremodeljson['statements']).forEach((key, index) => {
-          if (dynaremodeljson['statements'][key]['statementName'] == 'init_val') {
-            matchflag = 1;
-          }
-        });
-
-        if (matchflag == 1) {
-          // initval block found
-          return resolve({
-            'status': 2,
-            'message': dynarestdout,
-            'modeljson': dynaremodeljson
-          });
-        } else {
-          // initval block not found: we provide the last known steadystate available in the database
-          return resolve({
-            'status': 201,
-            'message': dynarestdout,
-            'modeljson': dynaremodeljson,
-            'extrassinfo': extrassinfo,
-            'extrasstype': extrasstype
-          });
-        }
-      }
-    }
-  }); //end of main promise
-}
-
-
 //------------------------------------------------------------@@@button set perfect
 $('#setstochastic').click(async function () {
 
@@ -232,7 +45,7 @@ $('#setstochastic').click(async function () {
 
   // calling the 'node side'
   try {
-    var resp = await setstochasticnode(modelcode);
+    var resp = await setpreprocessmore(modelcode);
   } catch (error) {
     if (error.status == 200) {
       console.log("200")
@@ -340,42 +153,8 @@ function disableassociated(shockindex) {
 
 
 
-async function runstochasticnode(stosimval) {
-
-  return new Promise(async function (resolve, reject) {
-
-    var modelhash = stosimval['modelhash'];
-    // preparing only the standardized JSON in data
-    var stochsimindata = {
-      'taylororder': stosimval['taylororder'],
-      'irfperiods': stosimval['irfperiods'],
-      'stochasticshocksdescription': stosimval['stochasticshocksdescription']
-    };
-
-    try {
-      await preparejsonfiles(modelhash, 2, stosimval, stochsimindata);
-    } catch (error) {
-      return reject(error);
-    }
-
-    const reply = ipc.sendSync('performMatlab', 111);
-    cl(reply);
-
-    // this code will get the local user directory (do not erase until used)
-    // console.log(app.getPath('userData'));
-
-
-
-
-    // console.log('runstochasticnode last');
-    return resolve('hello');
 
 
-  }); //end of main promise
-
-
-}
-
 
 $('#runstochastic').click(async function () {