--- a/src/event.c
+++ b/src/event.c
@@ -5,96 +5,100 @@
 #include <pthread.h>
 #include <libsmbclient.h>
 #include <fuse/fuse.h>
-#include <glib.h>
 
 #include "common.h"
 #include "smbitem.h"
 #include "auth.h"
 #include "process.h"
 #include "samba.h"
-#include "stat_workaround.h"
 #include "reconfigure.h"
 
-static int		event_query_browser_flag	= 1;
-static int		event_time_step			= 10;
-static int		event_smb_tree_scan_period	= 300;
-static int		event_smb_tree_elements_ttl	= 900;
-static int		event_config_update_period	= 300;
-
-static time_t		event_last_smb_tree_scan	= (time_t) 0;
-static time_t		event_last_config_update	= (time_t) 0;
-
-static pthread_mutex_t	m_evthread			= PTHREAD_MUTEX_INITIALIZER;
-
-static pthread_t	event_ev_thread_id;
-static pthread_t	event_smb_thread_id;
+int		event_query_browser_flag	= 1;
+int		event_time_step			= 10;
+int		event_smb_tree_scan_period	= 300;
+int		event_smb_tree_elements_ttl	= 900;
+int		event_config_update_period	= 300;
+
+time_t		event_last_smb_tree_scan	= (time_t) 0;
+time_t		event_last_config_update	= (time_t) 0;
+
+pthread_mutex_t	m_evthread			= PTHREAD_MUTEX_INITIALIZER;
+
+pthread_t	event_ev_thread_id;
+pthread_t	event_smb_thread_id;
 
 int event_set_query_browser_flag(int flag){
     DPRINTF(7, "flag=%d\n", flag);
-    g_atomic_int_set(&event_query_browser_flag, flag);
+    pthread_mutex_lock(&m_evthread);
+    event_query_browser_flag = flag;
+    pthread_mutex_unlock(&m_evthread);
     return 1;
 }
 
-static inline int event_get_query_browser_flag(void){
-    return g_atomic_int_get(&event_query_browser_flag);
+int event_get_query_browser_flag(void){
+    int flag;
+
+    pthread_mutex_lock(&m_evthread);
+    flag = event_query_browser_flag;
+    pthread_mutex_unlock(&m_evthread);
+    DPRINTF(7, "flag=%d\n", flag);
+    return flag;
 }
 
 int event_set_time_step(int step){
     if (step < 1) return 0;
     DPRINTF(7, "step=%d\n", step);
-    g_atomic_int_set(&event_time_step, step);
+    pthread_mutex_lock(&m_evthread);
+    event_time_step = step;
+    pthread_mutex_unlock(&m_evthread);
     return 1;
 }
 
-static inline int event_get_time_step(void){
-    return g_atomic_int_get(&event_time_step);
+int event_get_time_step(void){
+    int step;
+
+    pthread_mutex_lock(&m_evthread);
+    step = event_time_step;
+    pthread_mutex_unlock(&m_evthread);
+    DPRINTF(7, "step=%d\n", step);
+    return step;
+}
+
+int event_set_smb_tree_elements_ttl(int ttl){
+    DPRINTF(7, "ttl=%d\n", ttl);
+    pthread_mutex_lock(&m_evthread);
+    if (ttl < event_smb_tree_scan_period) ttl = -1;
+    else event_smb_tree_elements_ttl = ttl;
+    pthread_mutex_unlock(&m_evthread);
+    return (ttl > 0) ? 1 : 0;
+}
+
+int event_get_smb_tree_elements_ttl(void){
+    int ttl;
+
+    pthread_mutex_lock(&m_evthread);
+    ttl = event_smb_tree_elements_ttl;
+    pthread_mutex_unlock(&m_evthread);
+    DPRINTF(7, "ttl=%d\n", ttl);
+    return ttl;
 }
 
 int event_set_smb_tree_scan_period(int period){
-    if (period < event_get_time_step()) return 0;
     DPRINTF(7, "period=%d\n", period);
     pthread_mutex_lock(&m_evthread);
-    event_smb_tree_scan_period = period;
-    pthread_mutex_unlock(&m_evthread);
-    return 1;
-}
-
-static inline int event_get_smb_tree_scan_period(void){
-    int period;
-
-    pthread_mutex_lock(&m_evthread);
-    period = event_smb_tree_scan_period;
-    pthread_mutex_unlock(&m_evthread);
-    return period;
-}
-
-int event_set_smb_tree_elements_ttl(int ttl){
-    if (ttl < event_get_smb_tree_scan_period()) return 0;
-    DPRINTF(7, "ttl=%d\n", ttl);
-    g_atomic_int_set(&event_smb_tree_elements_ttl, ttl);
-    return 1;
-}
-
-static inline int event_get_smb_tree_elements_ttl(void){
-    return g_atomic_int_get(&event_smb_tree_elements_ttl);
-}
-
-int event_set_config_update_period(int period){
-    if ((period != 0) && (period < event_get_time_step())) return 0;
-    DPRINTF(7, "period=%d\n", period);
-    pthread_mutex_lock(&m_evthread);
-    event_config_update_period = period;
-    pthread_mutex_unlock(&m_evthread);
-    return 1;
-}
-
-static void event_set_last_smb_tree_scan(time_t scan_time){
+    if (period < event_time_step) period = -1;
+    else event_smb_tree_scan_period = period;
+    pthread_mutex_unlock(&m_evthread);
+    return (period > 0) ? 1 : 0;
+}
+
+void event_set_last_smb_tree_scan(time_t scan_time){
     pthread_mutex_lock(&m_evthread);
     event_last_smb_tree_scan = scan_time;
     pthread_mutex_unlock(&m_evthread);
 }
 
-static int event_is_time_for_smb_tree_scan(void){
+int event_is_time_for_smb_tree_scan(void){
     int flag;
 
     pthread_mutex_lock(&m_evthread);
@@ -104,24 +108,32 @@
     return flag;
 }
 
-static void event_set_last_config_update(time_t update_time){
+int event_set_config_update_period(int period){
+    DPRINTF(7, "period=%d\n", period);
+    pthread_mutex_lock(&m_evthread);
+    if (period < event_time_step) period = -1;
+    else event_config_update_period = period;
+    pthread_mutex_unlock(&m_evthread);
+    return (period > 0) ? 1 : 0;
+}
+
+void event_set_last_config_update(time_t update_time){
     pthread_mutex_lock(&m_evthread);
     event_last_config_update = update_time;
     pthread_mutex_unlock(&m_evthread);
 }
 
-static int event_is_time_for_config_update(void){
+int event_is_time_for_config_update(void){
     int flag;
 
     pthread_mutex_lock(&m_evthread);
-    flag = ((event_config_update_period > 0) &&
-	    (time(NULL) >= event_last_config_update +
-			  event_config_update_period)) ? 1 : 0;
+    flag = (time(NULL) >= event_last_config_update +
+			  event_config_update_period) ? 1 : 0;
     pthread_mutex_unlock(&m_evthread);
     return flag;
 }
 
-static void event_scan_samba_group(const char *group){
+void event_scan_samba_group(const char *group){
     char		buf[4096], name[256], link[256];
     int			count;
     samba_fd		fd;
@@ -155,7 +167,7 @@
     samba_closedir(fd);
 }
 
-static void event_scan_smb_root(void){
+void event_scan_smb_root(void){
     char		buf[4096];
     int			count;
     samba_fd		fd;
@@ -189,7 +201,7 @@
     int			i;
     struct smbitem	*dir;
 
-    if (event_get_query_browser_flag()) event_scan_smb_root();
+    event_scan_smb_root();
     dir = smbitem_get_samba_groups();
     for(i = 0; i < dir->child_cnt; i++){
 	if (dir->childs[i]->type != SMBITEM_GROUP) continue;
@@ -198,7 +210,7 @@
     smbitem_release_dir(dir);
 }
 
-static void* event_update_smb_tree_thread(void *data){
+void* event_update_smb_tree_thread(void *data){
     time_t		scan_time;
     time_t		die_threshold;
     int			time_step;
@@ -231,25 +243,23 @@
     return NULL;
 }
 
-static void event_reread_config(void){
+void event_reread_config(void){
     time_t		reread_time;
 
     reread_time = time(NULL);
     DPRINTF(5, "start at timestamp=%u\n", (unsigned) reread_time);
 
-    reconfigure_read_config(0);
+    reconfigure_read_config_file(config_file, 0);
     smbitem_delete_obsolete(reread_time, SMBITEM_USER_TREE);
     auth_delete_obsolete(reread_time);
-    stat_workaround_delete_obsolete(reread_time);
     event_set_last_config_update(reread_time);
 }
 
-static void* event_thread(void *data){
+void* event_thread(void *data){
     siginfo_t		siginfo;
     sigset_t		signal_set;
     time_t		start_time;
     struct timespec	timeout;
-    int 		sigret;
 
     (void)data;
 
@@ -267,13 +277,12 @@
 	timeout.tv_sec  = event_get_time_step();
 	timeout.tv_nsec = 0;
 	pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
-	sigret = sigtimedwait(&signal_set, &siginfo, &timeout);
+	sigtimedwait(&signal_set, &siginfo, &timeout);
 	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
 
-	process_cleanup_from_zombies();
-	if ((sigret != -1 && siginfo.si_signo == SIGHUP)
-	    || event_is_time_for_config_update())
-		event_reread_config();
+	if (siginfo.si_signo == SIGCHLD) process_cleanup_from_zombies();
+	if ((siginfo.si_signo == SIGHUP) ||
+	    event_is_time_for_config_update()) event_reread_config();
     }
     return NULL;
 }