diff --git a/core/installer.c b/core/installer.c
index 5e4cbe5..eb07f41 100644
--- a/core/installer.c
+++ b/core/installer.c
@@ -200,7 +200,7 @@ static int run_prepost_scripts(struct imglist *list, script_fn type)
 			continue;
 		hnd = find_handler(img);
 		if (hnd) {
-			ret = hnd->installer(img, &type);
+			ret = hnd->installer(img, hnd->data, type);
 			if (ret)
 				return ret;
 		}
@@ -231,7 +231,7 @@ int install_single_image(struct img_type *img, bool dry_run)
 	swupdate_progress_inc_step(img->fname, hnd->desc);
 
 	/* TODO : check callback to push results / progress */
-	ret = hnd->installer(img, hnd->data);
+	ret = hnd->installer(img, hnd->data, NONE);
 	if (ret != 0) {
 		TRACE("Installer for %s not successful !",
 			hnd->desc);
diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c
index 843c0a9..8045d73 100644
--- a/corelib/lua_interface.c
+++ b/corelib/lua_interface.c
@@ -1070,7 +1070,9 @@ static lua_State *gL = NULL;
  * @param data [in] pointer to the index in the Lua registry for the function
  * @return This function returns 0 if successful and -1 if unsuccessful.
  */
-static int l_handler_wrapper(struct img_type *img, void *data) {
+static int l_handler_wrapper(struct img_type *img, void *data,
+			     script_fn __attribute__ ((__unused__)) scriptfn)
+{
 	int res = 0;
 	lua_Number result;
 	int l_func_ref;
@@ -1175,7 +1177,7 @@ static int l_call_handler(lua_State *L)
 		ret = 1;
 		goto call_handler_exit;
 	}
-	if ((hnd->installer(&img, hnd->data)) != 0) {
+	if ((hnd->installer(&img, hnd->data, NONE)) != 0) {
 		if (asprintf(&msg, "Executing handler %s failed!", hnd->desc) == -1) {
 			msg = NULL;
 		}
diff --git a/doc/source/handlers.rst b/doc/source/handlers.rst
index 333c912..6d5be62 100644
--- a/doc/source/handlers.rst
+++ b/doc/source/handlers.rst
@@ -56,7 +56,8 @@ The prototype for the callback is:
 ::
 
 	int my_handler(struct img_type *img,
-		void __attribute__ ((__unused__)) *data)
+		void __attribute__ ((__unused__)) *data,
+		script_fn __attribute__ ((__unused__)) scriptfn)
 
 
 The most important parameter is the pointer to a struct img_type. It describes
diff --git a/handlers/archive_handler.c b/handlers/archive_handler.c
index ef8989f..f794048 100644
--- a/handlers/archive_handler.c
+++ b/handlers/archive_handler.c
@@ -210,7 +210,8 @@ out:
 }
 
 static int install_archive_image(struct img_type *img,
-	void __attribute__ ((__unused__)) *data)
+	void __attribute__ ((__unused__)) *data,
+	script_fn __attribute__ ((__unused__)) scriptfn)
 {
 	char path[255];
 	int fdout = -1;
diff --git a/handlers/boot_handler.c b/handlers/boot_handler.c
index 73c9116..f16650e 100644
--- a/handlers/boot_handler.c
+++ b/handlers/boot_handler.c
@@ -25,7 +25,8 @@ static void uboot_handler(void);
 static void boot_handler(void);
 
 static int install_boot_environment(struct img_type *img,
-	void __attribute__ ((__unused__)) *data)
+	void __attribute__ ((__unused__)) *data,
+	script_fn __attribute__ ((__unused__)) scriptfn)
 {
 	int ret;
 	int fdout;
diff --git a/handlers/delta_handler.c b/handlers/delta_handler.c
index 9a91352..98ec860 100644
--- a/handlers/delta_handler.c
+++ b/handlers/delta_handler.c
@@ -869,7 +869,8 @@ static bool copy_existing_chunks(zckChunk **dstChunk, struct hnd_priv *priv)
  * Handler entry point
  */
 static int install_delta(struct img_type *img,
-	void __attribute__ ((__unused__)) *data)
+	void __attribute__ ((__unused__)) *data,
+	script_fn __attribute__ ((__unused__)) scriptfn)
 {
 	struct hnd_priv *priv;
 	int ret = -1;
diff --git a/handlers/diskformat_handler.c b/handlers/diskformat_handler.c
index bf236b2..96f5a5b 100644
--- a/handlers/diskformat_handler.c
+++ b/handlers/diskformat_handler.c
@@ -15,7 +15,8 @@
 void diskformat_handler(void);
 
 static int diskformat(struct img_type *img,
-		      void __attribute__ ((__unused__)) *data)
+		      void __attribute__ ((__unused__)) *data,
+		      script_fn __attribute__ ((__unused__)) scriptfn)
 {
 	int ret = 0;
 
diff --git a/handlers/diskpart_handler.c b/handlers/diskpart_handler.c
index d96d4e2..6359d8b 100644
--- a/handlers/diskpart_handler.c
+++ b/handlers/diskpart_handler.c
@@ -774,7 +774,8 @@ static void diskpart_unref_context(struct fdisk_context *cxt)
 }
 
 static int diskpart(struct img_type *img,
-	void __attribute__ ((__unused__)) *data)
+	void __attribute__ ((__unused__)) *data,
+	script_fn __attribute__ ((__unused__)) scriptfn)
 {
 	char *lbtype = diskpart_get_lbtype(img);
 	struct dict_list *parts;
diff --git a/handlers/dummy_handler.c b/handlers/dummy_handler.c
index c17b55d..bdbc711 100644
--- a/handlers/dummy_handler.c
+++ b/handlers/dummy_handler.c
@@ -19,7 +19,8 @@
 void dummy_handler(void);
 
 static int install_nothing(struct img_type *img,
-	void __attribute__ ((__unused__)) *data)
+	void __attribute__ ((__unused__)) *data,
+	script_fn __attribute__ ((__unused__)) scriptfn)
 {
 	int ret;
 	int fdout;
diff --git a/handlers/flash_hamming1_handler.c b/handlers/flash_hamming1_handler.c
index 7cdb40a..7f092a5 100644
--- a/handlers/flash_hamming1_handler.c
+++ b/handlers/flash_hamming1_handler.c
@@ -277,7 +277,8 @@ out:
 }
 
 static int install_flash_hamming_image(struct img_type *img,
-	void __attribute__ ((__unused__)) *data)
+	void __attribute__ ((__unused__)) *data,
+	script_fn __attribute__ ((__unused__)) scriptfn)
 {
 	int mtdnum;
 
diff --git a/handlers/flash_handler.c b/handlers/flash_handler.c
index 5c11ff6..69da777 100644
--- a/handlers/flash_handler.c
+++ b/handlers/flash_handler.c
@@ -335,7 +335,8 @@ static int flash_write_image(int mtdnum, struct img_type *img)
 }
 
 static int install_flash_image(struct img_type *img,
-	void __attribute__ ((__unused__)) *data)
+	void __attribute__ ((__unused__)) *data,
+	script_fn __attribute__ ((__unused__)) scriptfn)
 {
 	int mtdnum;
 
diff --git a/handlers/lua_scripthandler.c b/handlers/lua_scripthandler.c
index cc47f53..f096fda 100644
--- a/handlers/lua_scripthandler.c
+++ b/handlers/lua_scripthandler.c
@@ -25,20 +25,16 @@
 
 static void lua_handler(void);
 
-static int start_lua_script(struct img_type *img, void *data)
+static int start_lua_script(struct img_type *img,
+			    void __attribute__ ((__unused__)) *data,
+			    script_fn scriptfn)
 {
 	int ret;
 	const char *fnname;
-	script_fn scriptfn;
 
 	const char* tmp = get_tmpdirscripts();
 	char filename[MAX_IMAGE_FNAME + strlen(tmp) + 2 + strlen(img->type_data)];
 
-	if (!data)
-		return -1;
-
-	scriptfn = *(script_fn *)data;
-
 	switch (scriptfn) {
 	case PREINSTALL:
 		fnname="preinst";
diff --git a/handlers/raw_handler.c b/handlers/raw_handler.c
index 619a2f4..411cdb2 100644
--- a/handlers/raw_handler.c
+++ b/handlers/raw_handler.c
@@ -119,7 +119,8 @@ blkprotect_out:
 }
 
 static int install_raw_image(struct img_type *img,
-	void __attribute__ ((__unused__)) *data)
+	void __attribute__ ((__unused__)) *data,
+	script_fn __attribute__ ((__unused__)) scriptfn)
 {
 	int ret;
 	int fdout;
@@ -150,7 +151,8 @@ static int install_raw_image(struct img_type *img,
 }
 
 static int copy_raw_image(struct img_type *img,
-	void __attribute__ ((__unused__)) *data)
+	void __attribute__ ((__unused__)) *data,
+	script_fn __attribute__ ((__unused__)) scriptfn)
 {
 	int ret;
 	int fdout, fdin;
@@ -203,7 +205,8 @@ static int copy_raw_image(struct img_type *img,
 }
 
 static int install_raw_file(struct img_type *img,
-	void __attribute__ ((__unused__)) *data)
+	void __attribute__ ((__unused__)) *data,
+	script_fn __attribute__ ((__unused__)) scriptfn)
 {
 	char path[255];
 	int fdout;
diff --git a/handlers/rdiff_handler.c b/handlers/rdiff_handler.c
index 0b9e146..130ac88 100644
--- a/handlers/rdiff_handler.c
+++ b/handlers/rdiff_handler.c
@@ -219,7 +219,8 @@ static int apply_rdiff_chunk_cb(void *out, const void *buf, unsigned int len)
 }
 
 static int apply_rdiff_patch(struct img_type *img,
-							 void __attribute__((__unused__)) * data)
+			     void __attribute__((__unused__)) * data,
+			     script_fn __attribute__ ((__unused__)) scriptfn)
 {
 	int ret = 0;
 
diff --git a/handlers/readback_handler.c b/handlers/readback_handler.c
index 98ffd3d..74dea09 100644
--- a/handlers/readback_handler.c
+++ b/handlers/readback_handler.c
@@ -26,12 +26,10 @@
 void readback_handler(void);
 static int readback_postinst(struct img_type *img);
 
-static int readback(struct img_type *img, void *data)
+static int readback(struct img_type *img,
+		    void __attribute__ ((__unused__)) *data,
+		    script_fn scriptfn)
 {
-	if (!data)
-		return -1;
-
-	script_fn scriptfn = *(script_fn *)data;
 	switch (scriptfn) {
 	case POSTINSTALL:
 		return readback_postinst(img);
diff --git a/handlers/remote_handler.c b/handlers/remote_handler.c
index 8558d88..8c04773 100644
--- a/handlers/remote_handler.c
+++ b/handlers/remote_handler.c
@@ -149,7 +149,8 @@ static int forward_data(void *request, const void *buf, unsigned int len)
 }
 
 static int install_remote_image(struct img_type *img,
-	void __attribute__ ((__unused__)) *data)
+	void __attribute__ ((__unused__)) *data,
+	script_fn __attribute__ ((__unused__)) scriptfn)
 {
 	void *context = zmq_ctx_new();
 	void *request = zmq_socket (context, ZMQ_REQ);
diff --git a/handlers/shell_scripthandler.c b/handlers/shell_scripthandler.c
index 9591350..9518216 100644
--- a/handlers/shell_scripthandler.c
+++ b/handlers/shell_scripthandler.c
@@ -47,15 +47,11 @@ static int execute_shell_script(struct img_type *img, const char *fnname)
 	return ret;
 }
 
-static int start_shell_script(struct img_type *img, void *data)
+static int start_shell_script(struct img_type *img,
+			      void __attribute__ ((__unused__)) *data,
+			      script_fn scriptfn)
 {
 	const char *fnname;
-	script_fn scriptfn;
-
-	if (!data)
-		return -EINVAL;
-
-	scriptfn = *(script_fn *)data;
 
 	switch (scriptfn) {
 	case PREINSTALL:
@@ -72,15 +68,10 @@ static int start_shell_script(struct img_type *img, void *data)
 	return execute_shell_script(img, fnname);
 }
 
-static int start_preinstall_script(struct img_type *img, void *data)
+static int start_preinstall_script(struct img_type *img,
+				   void __attribute__ ((__unused__)) *data,
+				   script_fn scriptfn)
 {
-	script_fn scriptfn;
-
-	if (!data)
-		return -EINVAL;
-
-	scriptfn = *(script_fn *)data;
-
 	/*
 	 * Call only in case of preinstall
 	 */
@@ -90,15 +81,10 @@ static int start_preinstall_script(struct img_type *img, void *data)
 	return execute_shell_script(img, "");
 }
 
-static int start_postinstall_script(struct img_type *img, void *data)
+static int start_postinstall_script(struct img_type *img,
+				    void __attribute__ ((__unused__)) *data,
+				    script_fn scriptfn)
 {
-	script_fn scriptfn;
-
-	if (!data)
-		return -EINVAL;
-
-	scriptfn = *(script_fn *)data;
-
 	/*
 	 * Call only in case of postinstall
 	 */
diff --git a/handlers/ssbl_handler.c b/handlers/ssbl_handler.c
index 478319f..22b96d1 100644
--- a/handlers/ssbl_handler.c
+++ b/handlers/ssbl_handler.c
@@ -164,9 +164,10 @@ static int inline get_active_ssbl(struct ssbl_priv *padmins) {
 	return get_inactive_ssbl(padmins) == 1 ? 0 : 1;
 }
 
-static int ssbl_swap(struct img_type *img, void *data)
+static int ssbl_swap(struct img_type *img,
+		     void __attribute__ ((__unused__)) *data,
+		     script_fn scriptfn)
 {
-	script_fn scriptfn;
 	struct ssbl_priv admins[2];
 	struct ssbl_priv *pssbl;
 	struct proplist *entry;
@@ -175,11 +176,6 @@ static int ssbl_swap(struct img_type *img, void *data)
 	struct flash_description *flash = get_flash_info();
 	char mtd_device[80];
 
-	if (!data)
-		return -EINVAL;
-
-	scriptfn = *(script_fn *)data;
-
 	/*
 	 * Call only in case of postinstall
 	 */
diff --git a/handlers/swuforward_handler.c b/handlers/swuforward_handler.c
index 3135afc..fdf765b 100644
--- a/handlers/swuforward_handler.c
+++ b/handlers/swuforward_handler.c
@@ -284,7 +284,8 @@ static int initialize_backchannel(struct hnd_priv *priv)
 }
 
 static int install_remote_swu(struct img_type *img,
-	void __attribute__ ((__unused__)) *data)
+	void __attribute__ ((__unused__)) *data,
+	script_fn __attribute__ ((__unused__)) scriptfn)
 {
 	struct hnd_priv priv;
 	struct curlconn *conn, *tmp;
diff --git a/handlers/ubivol_handler.c b/handlers/ubivol_handler.c
index 8bf4f30..1960022 100644
--- a/handlers/ubivol_handler.c
+++ b/handlers/ubivol_handler.c
@@ -388,7 +388,8 @@ static int wait_volume(struct img_type *img)
 }
 
 static int install_ubivol_image(struct img_type *img,
-	void __attribute__ ((__unused__)) *data)
+	void __attribute__ ((__unused__)) *data,
+	script_fn __attribute__ ((__unused__)) scriptfn)
 {
 	struct flash_description *flash = get_flash_info();
 	struct ubi_part *ubivol;
@@ -429,7 +430,8 @@ static int install_ubivol_image(struct img_type *img,
 }
 
 static int adjust_volume(struct img_type *cfg,
-	void __attribute__ ((__unused__)) *data)
+	void __attribute__ ((__unused__)) *data,
+	script_fn __attribute__ ((__unused__)) scriptfn)
 {
 	return resize_volume(cfg, cfg->partsize);
 }
@@ -450,9 +452,10 @@ static int ubi_volume_get_info(char *name, int *dev_num, int *vol_id)
 	return 0;
 }
 
-static int swap_volume(struct img_type *img, void *data)
+static int swap_volume(struct img_type *img,
+		       void __attribute__ ((__unused__)) *data,
+		       script_fn scriptfn)
 {
-	script_fn scriptfn;
 	struct flash_description *flash = get_flash_info();
 	libubi_t libubi = flash->libubi;
 	int num, count = 0;
@@ -465,11 +468,6 @@ static int swap_volume(struct img_type *img, void *data)
 	struct ubi_rnvol_req rnvol;
 	int ret = -1;
 
-	if (!data)
-		return -EINVAL;
-
-	scriptfn = *(script_fn *)data;
-
 	/*
 	 * Call only in case of postinstall
 	 */
diff --git a/handlers/ucfw_handler.c b/handlers/ucfw_handler.c
index c4f3199..864ba8d 100644
--- a/handlers/ucfw_handler.c
+++ b/handlers/ucfw_handler.c
@@ -498,7 +498,8 @@ static int get_gpio_from_property(struct dict_list *prop, struct mode_setup *gpi
 }
 
 static int install_uc_firmware_image(struct img_type *img,
-	void __attribute__ ((__unused__)) *data)
+	void __attribute__ ((__unused__)) *data,
+	script_fn __attribute__ ((__unused__)) scriptfn)
 {
 	struct handler_priv hnd_data;
 	struct dict_list *properties;
diff --git a/handlers/uniqueuuid_handler.c b/handlers/uniqueuuid_handler.c
index 3ffb8f1..a9aa13a 100644
--- a/handlers/uniqueuuid_handler.c
+++ b/handlers/uniqueuuid_handler.c
@@ -28,7 +28,8 @@
 void uniqueuuid_handler(void);
 
 static int uniqueuuid(struct img_type *img,
-	void __attribute__ ((__unused__)) *data)
+	void __attribute__ ((__unused__)) *data,
+	script_fn __attribute__ ((__unused__)) scriptfn)
 {
 	struct dict_list *uuids;
 	struct dict_list_elem *uuid;
diff --git a/include/handler.h b/include/handler.h
index a060623..0807021 100644
--- a/include/handler.h
+++ b/include/handler.h
@@ -33,7 +33,7 @@ typedef enum {
 			BOOTLOADER_HANDLER | PARTITION_HANDLER | \
 			NO_DATA_HANDLER)
 
-typedef int (*handler)(struct img_type *img, void *data);
+typedef int (*handler)(struct img_type *img, void *data, script_fn scriptfn);
 struct installer_handler{
 	char	desc[64];
 	handler installer;
