diff --git a/debian/scripts/common.sh b/debian/scripts/common.sh
index 951364c4390b4471b53074878ab0a731f1abd9fe..246724cb9444cdf4d2c503fe804ab3d973ffa338 100644
--- a/debian/scripts/common.sh
+++ b/debian/scripts/common.sh
@@ -1,6 +1,6 @@
 #file with common script functions for postrm/prerm/postinst/preinst
 log(){
-	echo "$@" >>__LOG_FILE__
+	echo "[" $CURRENT_VERSION "]" "$@" >>__LOG_FILE__
 }
 LOG_FILE="__LOG_FILE__"
 
diff --git a/debian/template/postinst b/debian/template/postinst
index cc4aef4bd91f2c189a8e6c14a4886400db69af53..44228b77f9db6a5d9d50ee43d4917a886fe73f9e 100644
--- a/debian/template/postinst
+++ b/debian/template/postinst
@@ -14,6 +14,7 @@
 # for details, see http://www.debian.org/doc/debian-policy/ or
 # the debian-policy package
 log "Running postinst" $1 $2;
+invoke-rc.d $TOMCAT_PACKAGE status >> $LOG_FILE
 
 # we execute it here because if some packages are missing then dpkg will return non-zero exit code
 set -e
@@ -61,8 +62,10 @@ case "$1" in
 #we have to restart tomcat, because application was started on the old database and it might crash during deplyment
 #for instance in the new war file there was init script that uses some new database features, but they are not
 #availble when new war is deployed from debian package, so tomcat will catch SQL exception and stop deployment
+    invoke-rc.d $TOMCAT_PACKAGE stop || true
+    rm -rf /var/lib/$TOMCAT_PACKAGE/webapps/minerva
     ln -s /usr/share/minerva/minerva.war /var/lib/$TOMCAT_PACKAGE/webapps/minerva.war 
-    invoke-rc.d $TOMCAT_PACKAGE restart
+    invoke-rc.d $TOMCAT_PACKAGE start
     ;;
     *)
         echo "postinst called with unknown argument \`$1'" >&2