diff --git a/debian/create-debian-pkg.sh b/debian/create-debian-pkg.sh
index 654df170b9de5f453019e137908583eb9650cc6b..1da14fa3436067f4a90d5deb5eecfa90b07266ec 100755
--- a/debian/create-debian-pkg.sh
+++ b/debian/create-debian-pkg.sh
@@ -70,6 +70,14 @@ then
 	exit 1;
 fi
 
+
+#default connection params (if /etc/minerva/db.properties is not defined)
+DB_HOST=`cat persist/src/main/resources/db.properties |grep "uri" |cut -f3 -d"/" |cut -f1 -d":"`
+DB_PORT=`cat persist/src/main/resources/db.properties |grep "uri" |cut -f3 -d"/" |cut -f2 -d":"`
+DB_DATABASE_NAME=`cat persist/src/main/resources/db.properties |grep "uri" |cut -f4 -d"/"`
+DB_USERNAME=`cat persist/src/main/resources/db.properties |grep "username" |cut -f2 -d"="`
+DB_PASSWORD=`cat persist/src/main/resources/db.properties |grep "password" |cut -f2 -d"="`
+
 #------------------------------------------
 # Now we have all db schema diff files. Let's start preparing 
 # debian package
@@ -107,11 +115,20 @@ sed -i "s/__LOG_FILE__/$LOG_FILE/g" common.sh
 #in the filesystem where package is installed
 sed -i "s/__DB_SCRIPT_DIR__/$DB_SCRIPT_DIR/g" common.sh
 
+sed -i "s/__DB_HOST__/$DB_HOST/g" common.sh
+sed -i "s/__DB_PORT__/$DB_PORT/g" common.sh
+sed -i "s/__DB_DATABASE_NAME__/$DB_DATABASE_NAME/g" common.sh
+sed -i "s/__DB_USERNAME__/$DB_USERNAME/g" common.sh
+sed -i "s/__DB_PASSWORD__/$DB_PASSWORD/g" common.sh
+
 sed -i -e "1r common.sh" debian/postinst
 sed -i -e "1r common.sh" debian/postrm
 sed -i -e "1r common.sh" debian/preinst
 sed -i -e "1r common.sh" debian/prerm
 
+
+
+
 #put scripts into $DB_SCRIPT_DIR (it's a bit different than varaiable because it's not
 #escaped
 echo db_0.sql /usr/share\/minerva/schema >> debian/install
diff --git a/debian/scripts/common.sh b/debian/scripts/common.sh
index 246724cb9444cdf4d2c503fe804ab3d973ffa338..2b5d61837f794dd009b68265814570874af93999 100644
--- a/debian/scripts/common.sh
+++ b/debian/scripts/common.sh
@@ -27,3 +27,74 @@ if [ "$TOMCAT8_OK" != "" ];
 then
   TOMCAT_PACKAGE='tomcat8'
 fi
+
+POSTGRES_OK=$(dpkg-query -W --showformat='${Status}\n' postgresql|grep "install ok installed")
+
+DB_HOST="__DB_HOST__"
+DB_PORT="__DB_PORT__"
+DB_DATABASE_NAME="__DB_DATABASE_NAME__"
+DB_USERNAME="__DB_USERNAME__"
+DB_PASSWORD="__DB_PASSWORD__"
+
+
+if [ -f /etc/minerva/db.properties ]; then
+	DB_PROPERTIES_FILE="/etc/minerva/db.properties"
+	log "$DB_PROPERTIES_FILE file found"
+	DB_HOST=`cat $DB_PROPERTIES_FILE |grep "uri" |cut -f3 -d"/" |cut -f1 -d":"`
+	DB_PORT=`cat $DB_PROPERTIES_FILE |grep "uri" |cut -f3 -d"/" |cut -f2 -d":"`
+	DB_DATABASE_NAME=`cat $DB_PROPERTIES_FILE |grep "uri" |cut -f4 -d"/"`
+	DB_USERNAME=`cat $DB_PROPERTIES_FILE |grep "username" |cut -f2 -d"="`
+	DB_PASSWORD=`cat $DB_PROPERTIES_FILE |grep "password" |cut -f2 -d"="`
+fi
+
+
+#if we connect to something that is not in localhost then we need to provide login and password
+#because we won't have access to it as postgres user
+if [ "$DB_HOST" != "localhost" ] && [ "$DB_HOST" != "127.0.0.1" ]
+then
+	log "DB is located on the remote server: $DB_HOST"
+	IS_REMOTE_DB=true
+else
+	log "DB is at localhost: $DB_HOST"
+	IS_REMOTE_DB=false
+fi
+
+exec_sql(){
+	log "Execute SQL : '$1'"
+	echo "$1" |PGPASSWORD=$DB_PASSWORD psql -h $DB_HOST -p $DB_PORT -U $DB_USERNAME $DB_DATABASE_NAME >>$LOG_FILE 2>>$LOG_FILE
+}
+exec_sql_file(){
+	log "Execute SQL file: $1"
+	PGPASSWORD=$DB_PASSWORD psql -h $DB_HOST -p $DB_PORT -U $DB_USERNAME $DB_DATABASE_NAME -f $1 >>$LOG_FILE 2>>$LOG_FILE
+}
+create_db(){
+	if [ $IS_REMOTE_DB  = false ]
+	then
+		su - postgres -c "createuser -d -r -s -p $DB_PORT $DB_USERNAME"  >>$LOG_FILE 2>>$LOG_FILE
+		log "User created"
+		su - postgres -c "echo \"ALTER USER $DB_USERNAME WITH PASSWORD '$DB_PASSWORD';\"| psql -p $DB_PORT "  >>$LOG_FILE 2>>$LOG_FILE
+		log "User credentials updated"
+		su - postgres -c "createdb -p $DB_PORT -O $DB_USERNAME $DB_DATABASE_NAME"  >>$LOG_FILE 2>>$LOG_FILE
+		log "Db created"
+
+		hba_conf=`su - postgres -c "psql -t -P format=unaligned -c 'show hba_file';"`;
+		cp $hba_conf $hba_conf".bac"
+		cat $hba_conf".bac" |grep -v "all[ \t]*peer" >$hba_conf
+		printf "local   all             all                                     md5\n" >>$hba_conf
+		invoke-rc.d postgresql restart
+	else
+		log "HOST is remote, assuming db and user are already there"
+	fi
+}
+stop_postgres() {
+	if [ $IS_REMOTE_DB  = false ]
+	then
+		invoke-rc.d postgresql stop || true
+	fi
+}
+start_postgres() {
+	if [ $IS_REMOTE_DB  = false ]
+	then
+		invoke-rc.d postgresql restart
+	fi
+}
diff --git a/debian/template/postinst b/debian/template/postinst
index 2f2c3863a88d87c25e0f49a67687296261a2a16e..35037021f7e211c44b71872a9db765295f72f101 100644
--- a/debian/template/postinst
+++ b/debian/template/postinst
@@ -21,29 +21,21 @@ set -e
 
 case "$1" in
     configure)
-    invoke-rc.d postgresql start
+		start_postgres
 
 		#if we install
 		if [ "$OLD_VERSION" = "" ]
 		then
-			su - postgres -c "createuser -d -r -s map_viewer"  >>$LOG_FILE 2>>$LOG_FILE
-			su - postgres -c "echo \"ALTER USER map_viewer WITH PASSWORD '123qweasdzxc';\"| psql"  >>$LOG_FILE 2>>$LOG_FILE
-			su - postgres -c "createdb -O map_viewer map_viewer"  >>$LOG_FILE 2>>$LOG_FILE
-
-			hba_conf=`su - postgres -c "psql -t -P format=unaligned -c 'show hba_file';"`;
-			cp $hba_conf $hba_conf".bac"
-			cat $hba_conf".bac" |grep -v "all[ \t]*peer" >$hba_conf
-			printf "local   all             all                                     md5\n" >>$hba_conf
-	    invoke-rc.d postgresql restart
+			create_db
 
 			#install base version of the framework
-			su - postgres -c "psql map_viewer -f $DB_SCRIPT_DIR/db_0.sql" >>$LOG_FILE 2>>$LOG_FILE
+			exec_sql_file "$DB_SCRIPT_DIR/db_0.sql"
 			#install patch to current version
-			su - postgres -c "psql map_viewer -f $DB_SCRIPT_DIR/db_0_to_$CURRENT_VERSION\".sql\"" >>$LOG_FILE 2>>$LOG_FILE
+			exec_sql_file "$DB_SCRIPT_DIR/db_0_to_${CURRENT_VERSION}.sql"
 
 		else
 			#if we update the package
-			su - postgres -c "psql map_viewer -f $DB_SCRIPT_DIR/db_$OLD_VERSION\"_to_\"$CURRENT_VERSION\".sql\""  >>$LOG_FILE 2>>$LOG_FILE
+			exec_sql_file "$DB_SCRIPT_DIR/db_${OLD_VERSION}_to_${CURRENT_VERSION}.sql"
 		fi
 
 		#print a disclaimer
diff --git a/debian/template/postrm b/debian/template/postrm
index 89144fb629ef34fd3761bc2c749f6cebfcfd4840..6c517b351c62b103aaf36e2479c2f6cec49f9db0 100644
--- a/debian/template/postrm
+++ b/debian/template/postrm
@@ -10,15 +10,6 @@
 
 log "Running postrm" $1 $2;
 
-log "Checking postgresql...";
-POSTGRES_OK=$(dpkg-query -W --showformat='${Status}\n' postgresql|grep "install ok installed")
-if [ "" = "$POSTGRES_OK" ]
-then
-	log "postgresql not found";
-else
-	log "postgresql found";
-fi
-
 # we execute it here because if some packages are missing then dpkg will return non-zero exit code
 set -e
 
@@ -26,34 +17,41 @@ case "$1" in
     upgrade)
 			rm -rf /var/lib/$TOMCAT_PACKAGE/webapps/minerva
 			rm -rf /var/lib/$TOMCAT_PACKAGE/webapps/minerva.war
-#			invoke-rc.d $TOMCAT_PACKAGE start || true
-#			invoke-rc.d postgresql start || true
     ;;
     remove)
 			rm -rf /var/lib/$TOMCAT_PACKAGE/webapps/minerva
 			rm -rf /var/lib/$TOMCAT_PACKAGE/webapps/minerva.war
 			invoke-rc.d $TOMCAT_PACKAGE start || true
-			if [ "" = "$POSTGRES_OK" ]
+			if [ $IS_REMOTE_DB = true ]
 			then
-				log "No postgresql package found.";
+				exec_sql "drop owned by $DB_USERNAME;"
 			else
-				invoke-rc.d postgresql start
-				su - postgres -c "dropdb map_viewer"
-				su - postgres -c "dropuser map_viewer"
+				if [ "" = "$POSTGRES_OK" ]
+				then
+					log "No postgresql package found.";
+				else
+					start_postgres
+					su - postgres -c "dropdb -p $DB_PORT $DB_DATABASE_NAME"
+					su - postgres -c "dropuser -p $DB_PORT $DB_USERNAME"
+				fi
 			fi
-    ;;
-		abort-install)
+    ;;	
+    abort-install)
 			invoke-rc.d $TOMCAT_PACKAGE start || true
-
-			if [ "" = "$POSTGRES_OK" ]; 
+			if [ $IS_REMOTE_DB = true ]
 			then
-				log "No postgresql package found.";
+				exec_sql "drop owned by $DB_USER"
 			else
-				invoke-rc.d postgresql restart
-				su - postgres -c "dropdb map_viewer"
-				su - postgres -c "dropuser map_viewer"
+				if [ "" = "$POSTGRES_OK" ]; 
+				then
+					log "No postgresql package found.";
+				else
+					start_postgres
+					su - postgres -c "dropdb -p $DB_PORT $DB_DATABASE_NAME"
+					su - postgres -c "dropuser -p $DB_PORT $DB_USERNAME"
+				fi
 			fi
-		;;
+    ;;
     *)
         echo "postrm called with unknown argument \`$1'" >&2
         exit 1
diff --git a/debian/template/preinst b/debian/template/preinst
index c6ad957eb6803a810a043143bf5845e16a3017ef..84d76df53b7b63fb52764416c0e076a72484ccf9 100644
--- a/debian/template/preinst
+++ b/debian/template/preinst
@@ -24,12 +24,12 @@ ln -s $path $DEFAULT_JAVA_SYMLINK
 
 case "$1" in
     install|upgrade)
-			invoke-rc.d $TOMCAT_PACKAGE stop || true
-			invoke-rc.d postgresql stop || true
+	invoke-rc.d $TOMCAT_PACKAGE stop || true
+	stop_postgres
     ;;
     abort-upgrade)
-			invoke-rc.d $TOMCAT_PACKAGE stop || true
-			invoke-rc.d postgresql stop || true
+	invoke-rc.d $TOMCAT_PACKAGE stop || true
+	stop_postgres
     ;;
     *)
         echo "preinst called with unknown argument \`$1'" >&2
diff --git a/debian/template/prerm b/debian/template/prerm
index c43b60f8fa2c3f996db03de69cc8b7e261d9220e..b131100dbb7790d8628054bd04fae91e19575a03 100644
--- a/debian/template/prerm
+++ b/debian/template/prerm
@@ -17,20 +17,20 @@ set -e
 log Running prerm $1 $2;
 
 invoke-rc.d postgresql start || true
-TIMESTAMP=$(date +"%F")
+TIMESTAMP=$(date +"%F_%H%M%S")
 DUMP_FILE=$DB_SCRIPT_DIR/dump_$TIMESTAMP
-log "dump map_viewer database to file $DUMP_FILE"
-su - postgres -c "pg_dump map_viewer"  | gzip > "$DUMP_FILE".gz
+log "dump $DB_DATABASE_NAME database to file $DUMP_FILE"
+PGPASSWORD=$DB_PASSWORD pg_dump -h $DB_HOST -p $DB_PORT -U $DB_USERNAME $DB_DATABASE_NAME | gzip > "$DUMP_FILE".gz
 
 case "$1" in
 
     upgrade)
-			invoke-rc.d $TOMCAT_PACKAGE stop || true
-			invoke-rc.d postgresql stop || true
+	invoke-rc.d $TOMCAT_PACKAGE stop || true
+	stop_postgres
     ;;
     remove)
-			invoke-rc.d $TOMCAT_PACKAGE stop || true
-			invoke-rc.d postgresql stop || true
+	invoke-rc.d $TOMCAT_PACKAGE stop || true
+	stop_postgres
     ;;
     *)
         echo "prerm called with unknown argument \`$1'" >&2
diff --git a/frontend-js/package-lock.json b/frontend-js/package-lock.json
index a97b88ebea0165231b24e0f79ae9e7d6a983e105..d84bc1074518cb44283e90e34d2b94f587814a5d 100644
--- a/frontend-js/package-lock.json
+++ b/frontend-js/package-lock.json
@@ -35,6 +35,24 @@
         "through": "2.3.8"
       }
     },
+    "MolStar": {
+      "version": "git://github.com/davidhoksza/MolStar.git#702c7417cd3dffdb45554b54ce49e27bc881b109",
+      "dev": true,
+      "requires": {
+        "ProtVista": "git://github.com/davidhoksza/protvista.git#4e4bb737ba1e183291505bd25f8bae2e651ce21e",
+        "downloadjs": "1.4.7",
+        "jquery": "3.3.1",
+        "litemol": "github:dsehnal/LiteMol#67556b0de0d2428f9494136758cbf8a662f66412"
+      },
+      "dependencies": {
+        "jquery": {
+          "version": "3.3.1",
+          "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.3.1.tgz",
+          "integrity": "sha512-Ubldcmxp5np52/ENotGxlLe6aGMvmF4R8S6tZjsP6Knsaxd/xp3Zrh50cG93lR6nPXyUFwzN3ZSOQI0wRJNdGg==",
+          "dev": true
+        }
+      }
+    },
     "ProtVista": {
       "version": "git://github.com/davidhoksza/protvista.git#4e4bb737ba1e183291505bd25f8bae2e651ce21e",
       "dev": true,
@@ -2365,26 +2383,6 @@
         }
       }
     },
-    "molstar": {
-      "version": "1.0.0",
-      "resolved": "https://registry.npmjs.org/molstar/-/molstar-1.0.0.tgz",
-      "integrity": "sha1-2e0KopdXq1iOLnbtYUOHiZVi8rA=",
-      "dev": true,
-      "requires": {
-        "ProtVista": "git://github.com/davidhoksza/protvista.git#4e4bb737ba1e183291505bd25f8bae2e651ce21e",
-        "downloadjs": "1.4.7",
-        "jquery": "3.3.1",
-        "litemol": "github:dsehnal/LiteMol#67556b0de0d2428f9494136758cbf8a662f66412"
-      },
-      "dependencies": {
-        "jquery": {
-          "version": "3.3.1",
-          "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.3.1.tgz",
-          "integrity": "sha512-Ubldcmxp5np52/ENotGxlLe6aGMvmF4R8S6tZjsP6Knsaxd/xp3Zrh50cG93lR6nPXyUFwzN3ZSOQI0wRJNdGg==",
-          "dev": true
-        }
-      }
-    },
     "ms": {
       "version": "2.0.0",
       "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",