diff --git a/apps/plugins/text_viewer/text_viewer.c b/apps/plugins/text_viewer/text_viewer.c
index fae2f07..4817710 100644
--- a/apps/plugins/text_viewer/text_viewer.c
+++ b/apps/plugins/text_viewer/text_viewer.c
@@ -35,7 +35,6 @@ enum plugin_status plugin_start(const void* file)
     long old_tick;
     bool done = false;
     bool display_update = true;
-    const struct tv_preferences *prefs = tv_get_preferences();
 
     old_tick = *rb->current_tick;
 
@@ -66,7 +65,7 @@ enum plugin_status plugin_start(const void* file)
             case TV_MENU2:
 #endif
                 {
-                    enum tv_menu_result res = tv_menu();
+                    unsigned res = tv_menu();
 
                     if (res != TV_MENU_RESULT_EXIT_MENU)
                     {
@@ -108,13 +107,13 @@ enum plugin_status plugin_start(const void* file)
 
             case TV_SCREEN_LEFT:
             case TV_SCREEN_LEFT | BUTTON_REPEAT:
-                if (prefs->windows > 1)
+                if (preferences->windows > 1)
                 {
                     /* Screen left */
                     tv_scroll_left(TV_HORIZONTAL_SCROLL_PREFS);
                 }
                 else {   /* prefs->windows == 1 */
-                    if (prefs->narrow_mode == NM_PAGE)
+                    if (preferences->narrow_mode == NM_PAGE)
                     {
                         /* scroll to previous page */
                         tv_scroll_up(TV_VERTICAL_SCROLL_PAGE);
@@ -129,13 +128,13 @@ enum plugin_status plugin_start(const void* file)
 
             case TV_SCREEN_RIGHT:
             case TV_SCREEN_RIGHT | BUTTON_REPEAT:
-                if (prefs->windows > 1)
+                if (preferences->windows > 1)
                 {
                     /* Screen right */
                     tv_scroll_right(TV_HORIZONTAL_SCROLL_PREFS);
                 }
                 else {   /* prefs->windows == 1 */
-                    if (prefs->narrow_mode == NM_PAGE)
+                    if (preferences->narrow_mode == NM_PAGE)
                     {
                         /* scroll to next page */
                         tv_scroll_down(TV_VERTICAL_SCROLL_PAGE);
@@ -206,7 +205,7 @@ enum plugin_status plugin_start(const void* file)
         }
         if (autoscroll)
         {
-            if(old_tick <= *rb->current_tick - (110 - prefs->autoscroll_speed * 10))
+            if(old_tick <= *rb->current_tick - (110 - preferences->autoscroll_speed * 10))
             {
                 tv_scroll_down(TV_VERTICAL_SCROLL_PREFS);
                 old_tick = *rb->current_tick;
diff --git a/apps/plugins/text_viewer/tv_action.c b/apps/plugins/text_viewer/tv_action.c
index 53a29ef..4dde240 100644
--- a/apps/plugins/text_viewer/tv_action.c
+++ b/apps/plugins/text_viewer/tv_action.c
@@ -28,8 +28,6 @@
 #include "tv_settings.h"
 #include "tv_window.h"
 
-static const struct tv_preferences *prefs;
-
 bool tv_init(const unsigned char *file)
 {
     size_t req_size = 0;
@@ -43,8 +41,6 @@ bool tv_init(const unsigned char *file)
     if (buffer == NULL || size == 0)
         return false;
 
-    prefs = tv_get_preferences();
-
     tv_init_bookmark();
 
     /* initialize modules */
@@ -83,45 +79,45 @@ void tv_draw(void)
     tv_move_screen(pos.page, pos.line, SEEK_SET);
 }
 
-void tv_scroll_up(enum tv_vertical_scroll_mode mode)
+void tv_scroll_up(unsigned mode)
 {
     int offset_page = 0;
     int offset_line = -1;
 
     if ((mode == TV_VERTICAL_SCROLL_PAGE) ||
-        (mode == TV_VERTICAL_SCROLL_PREFS && prefs->vertical_scroll_mode == PAGE))
+        (mode == TV_VERTICAL_SCROLL_PREFS && preferences->vertical_scroll_mode == PAGE))
     {
         offset_page--;
 #ifdef HAVE_LCD_BITMAP
-        offset_line = (prefs->page_mode == OVERLAP)? 1:0;
+        offset_line = (preferences->page_mode == OVERLAP)? 1:0;
 #endif
     }
     tv_move_screen(offset_page, offset_line, SEEK_CUR);
 }
 
-void tv_scroll_down(enum tv_vertical_scroll_mode mode)
+void tv_scroll_down(unsigned mode)
 {
     int offset_page = 0;
     int offset_line = 1;
 
     if ((mode == TV_VERTICAL_SCROLL_PAGE) ||
-        (mode == TV_VERTICAL_SCROLL_PREFS && prefs->vertical_scroll_mode == PAGE))
+        (mode == TV_VERTICAL_SCROLL_PREFS && preferences->vertical_scroll_mode == PAGE))
     {
         offset_page++;
 #ifdef HAVE_LCD_BITMAP
-        offset_line = (prefs->page_mode == OVERLAP)? -1:0;
+        offset_line = (preferences->page_mode == OVERLAP)? -1:0;
 #endif
     }
     tv_move_screen(offset_page, offset_line, SEEK_CUR);
 }
 
-void tv_scroll_left(enum tv_horizontal_scroll_mode mode)
+void tv_scroll_left(unsigned mode)
 {
     int offset_window = 0;
     int offset_column = 0;
 
     if ((mode == TV_HORIZONTAL_SCROLL_COLUMN) ||
-        (mode == TV_HORIZONTAL_SCROLL_PREFS && prefs->horizontal_scroll_mode == COLUMN))
+        (mode == TV_HORIZONTAL_SCROLL_PREFS && preferences->horizontal_scroll_mode == COLUMN))
     {
         /* Scroll left one column */
         offset_column--;
@@ -134,13 +130,13 @@ void tv_scroll_left(enum tv_horizontal_scroll_mode mode)
     tv_move_window(offset_window, offset_column);
 }
 
-void tv_scroll_right(enum tv_horizontal_scroll_mode mode)
+void tv_scroll_right(unsigned mode)
 {
     int offset_window = 0;
     int offset_column = 0;
 
     if ((mode == TV_HORIZONTAL_SCROLL_COLUMN) ||
-        (mode == TV_HORIZONTAL_SCROLL_PREFS && prefs->horizontal_scroll_mode == COLUMN))
+        (mode == TV_HORIZONTAL_SCROLL_PREFS && preferences->horizontal_scroll_mode == COLUMN))
     {
         /* Scroll right one column */
         offset_column++;
@@ -161,13 +157,13 @@ void tv_top(void)
 void tv_bottom(void)
 {
     tv_move_screen(0, 0, SEEK_END);
-    if (prefs->vertical_scroll_mode == PAGE)
+    if (preferences->vertical_scroll_mode == PAGE)
         tv_move_screen(0, -tv_get_screen_pos()->line, SEEK_CUR);
 }
 
-enum tv_menu_result tv_menu(void)
+unsigned tv_menu(void)
 {
-    enum tv_menu_result res;
+    unsigned res;
     struct tv_screen_pos cur_pos;
     off_t cur_file_pos = tv_get_screen_pos()->file_pos;
 
@@ -176,7 +172,7 @@ enum tv_menu_result tv_menu(void)
     if (res == TV_MENU_RESULT_EXIT_MENU)
     {
         tv_convert_fpos(cur_file_pos, &cur_pos);
-        if (prefs->vertical_scroll_mode == PAGE)
+        if (preferences->vertical_scroll_mode == PAGE)
             cur_pos.line = 0;
 
         tv_move_screen(cur_pos.page, cur_pos.line, SEEK_SET);
diff --git a/apps/plugins/text_viewer/tv_action.h b/apps/plugins/text_viewer/tv_action.h
index b01079c..f774f07 100644
--- a/apps/plugins/text_viewer/tv_action.h
+++ b/apps/plugins/text_viewer/tv_action.h
@@ -26,17 +26,17 @@
 #include "tv_menu.h"
 
 /* horizontal scroll mode */
-enum tv_horizontal_scroll_mode
+enum
 {
-    TV_HORIZONTAL_SCROLL_COLUMN, /* left/right one column */
+    TV_HORIZONTAL_SCROLL_COLUMN = 0, /* left/right one column */
     TV_HORIZONTAL_SCROLL_SCREEN, /* left/right one screen */
     TV_HORIZONTAL_SCROLL_PREFS,  /* left/right follows the settings */
 };
 
 /*vertical scroll mode */
-enum tv_vertical_scroll_mode
+enum
 {
-    TV_VERTICAL_SCROLL_LINE,   /* up/down one line */
+    TV_VERTICAL_SCROLL_LINE = 0,   /* up/down one line */
     TV_VERTICAL_SCROLL_PAGE,   /* up/down one page */
     TV_VERTICAL_SCROLL_PREFS,  /* up/down follows the settings */
 };
@@ -70,7 +70,7 @@ void tv_draw(void);
  * [In] mode
  *          scroll mode
  */
-void tv_scroll_up(enum tv_vertical_scroll_mode mode);
+void tv_scroll_up(unsigned mode);
 
 /*
  * scroll down
@@ -78,7 +78,7 @@ void tv_scroll_up(enum tv_vertical_scroll_mode mode);
  * [In] mode
  *          scroll mode
  */
-void tv_scroll_down(enum tv_vertical_scroll_mode mode);
+void tv_scroll_down(unsigned mode);
 
 /*
  * scroll left
@@ -86,7 +86,7 @@ void tv_scroll_down(enum tv_vertical_scroll_mode mode);
  * [In] mode
  *          scroll mode
  */
-void tv_scroll_left(enum tv_horizontal_scroll_mode mode);
+void tv_scroll_left(unsigned mode);
 
 /*
  * scroll right
@@ -94,7 +94,7 @@ void tv_scroll_left(enum tv_horizontal_scroll_mode mode);
  * [In] mode
  *          scroll mode
  */
-void tv_scroll_right(enum tv_horizontal_scroll_mode mode);
+void tv_scroll_right(unsigned mode);
 
 /* jump to the top */
 void tv_top(void);
@@ -111,7 +111,7 @@ void tv_bottom(void);
  *         TV_MENU_RESULT_EXIT_PLUGIN   request to exit this plugin
  *         TV_MENU_RESULT_ATTACHED_USB  connect USB cable
  */
-enum tv_menu_result tv_menu(void);
+unsigned tv_menu(void);
 
 /* add or remove the bookmark to the current position */
 void tv_add_or_remove_bookmark(void);
diff --git a/apps/plugins/text_viewer/tv_bookmark.c b/apps/plugins/text_viewer/tv_bookmark.c
index 78e4c60..d379c92 100644
--- a/apps/plugins/text_viewer/tv_bookmark.c
+++ b/apps/plugins/text_viewer/tv_bookmark.c
@@ -224,7 +224,7 @@ void tv_select_bookmark(void)
     }
 
     /* move to the select position */
-    if (tv_get_preferences()->vertical_scroll_mode == PAGE)
+    if (preferences->vertical_scroll_mode == PAGE)
         select_pos.line = 0;
 
     tv_move_screen(select_pos.page, select_pos.line, SEEK_SET);
diff --git a/apps/plugins/text_viewer/tv_menu.c b/apps/plugins/text_viewer/tv_menu.c
index ce85dc9..7040fbe 100644
--- a/apps/plugins/text_viewer/tv_menu.c
+++ b/apps/plugins/text_viewer/tv_menu.c
@@ -219,44 +219,30 @@ static bool tv_alignment_setting(void)
 #ifdef HAVE_LCD_BITMAP
 static bool tv_header_setting(void)
 {
-    int len = (rb->global_settings->statusbar == STATUSBAR_TOP)? 4 : 2;
-    struct opt_items names[len];
-
-    names[0].string   = "None";
-    names[0].voice_id = -1;
-    names[1].string   = "File path";
-    names[1].voice_id = -1;
-
-    if (rb->global_settings->statusbar == STATUSBAR_TOP)
+    static const struct opt_items names[4] =
     {
-        names[2].string   = "Status bar";
-        names[2].voice_id = -1;
-        names[3].string   = "Both";
-        names[3].voice_id = -1;
-    }
+        {"None",       -1},
+        {"File path",  -1},
+        {"Status bar", -1},
+        {"Both",       -1},
+    };
 
+    int len = (rb->global_settings->statusbar == STATUSBAR_TOP)? 4 : 2;
     return rb->set_option("Show Header", &new_prefs.header_mode, INT,
                          names, len, NULL);
 }
 
 static bool tv_footer_setting(void)
 {
-    int len = (rb->global_settings->statusbar == STATUSBAR_BOTTOM)? 4 : 2;
-    struct opt_items names[len];
-
-    names[0].string   = "None";
-    names[0].voice_id = -1;
-    names[1].string   = "Page Num";
-    names[1].voice_id = -1;
-
-    if (rb->global_settings->statusbar == STATUSBAR_BOTTOM)
+    static const struct opt_items names[4] =
     {
-        names[2].string   = "Status bar";
-        names[2].voice_id = -1;
-        names[3].string   = "Both";
-        names[3].voice_id = -1;
-    }
+        {"None",       -1},
+        {"Page Num",   -1},
+        {"Status bar", -1},
+        {"Both",       -1},
+    };
 
+    int len = (rb->global_settings->statusbar == STATUSBAR_BOTTOM)? 4 : 2;
     return rb->set_option("Show Footer", &new_prefs.footer_mode, INT,
                            names, len, NULL);
 }
@@ -350,9 +336,9 @@ MAKE_MENU(option_menu, "Viewer Options", NULL, Icon_NOICON,
 #endif
             &scroll_menu, &indent_spaces_item);
 
-static enum tv_menu_result tv_options_menu(void)
+static unsigned tv_options_menu(void)
 {
-    enum tv_menu_result result = TV_MENU_RESULT_EXIT_MENU;
+    unsigned result = TV_MENU_RESULT_EXIT_MENU;
 
     if (rb->do_menu(&option_menu, NULL, NULL, false) == MENU_ATTACHED_USB)
         result = TV_MENU_RESULT_ATTACHED_USB;
@@ -360,9 +346,9 @@ static enum tv_menu_result tv_options_menu(void)
     return result;
 }
 
-enum tv_menu_result tv_display_menu(void)
+unsigned tv_display_menu(void)
 {
-    enum tv_menu_result result = TV_MENU_RESULT_EXIT_MENU;
+    unsigned result = TV_MENU_RESULT_EXIT_MENU;
 
     MENUITEM_STRINGLIST(menu, "Viewer Menu", NULL,
                         "Return", "Viewer Options",
diff --git a/apps/plugins/text_viewer/tv_menu.h b/apps/plugins/text_viewer/tv_menu.h
index 9f28723..0db5051 100644
--- a/apps/plugins/text_viewer/tv_menu.h
+++ b/apps/plugins/text_viewer/tv_menu.h
@@ -23,8 +23,8 @@
 #ifndef PLUGIN_TEXT_VIEWER_MENU_H
 #define PLUGIN_TEXT_VIEWER_MENU_H
 
-enum tv_menu_result {
-    TV_MENU_RESULT_MOVE_PAGE,
+enum {
+    TV_MENU_RESULT_MOVE_PAGE = 0,
     TV_MENU_RESULT_EXIT_MENU,
     TV_MENU_RESULT_EXIT_PLUGIN,
     TV_MENU_RESULT_ATTACHED_USB,
@@ -40,6 +40,6 @@ enum tv_menu_result {
  *         TV_MENU_RESULT_EXIT_PLUGIN   request to exit this plugin
  *         TV_MENU_RESULT_ATTACHED_USB  connect USB cable
  */
-enum tv_menu_result tv_display_menu(void);
+unsigned tv_display_menu(void);
 
 #endif
diff --git a/apps/plugins/text_viewer/tv_preferences.c b/apps/plugins/text_viewer/tv_preferences.c
index d317508..b1045fb 100644
--- a/apps/plugins/text_viewer/tv_preferences.c
+++ b/apps/plugins/text_viewer/tv_preferences.c
@@ -23,15 +23,16 @@
 #include "plugin.h"
 #include "tv_preferences.h"
 
+/* global preferences */
 static struct tv_preferences prefs;
-static bool is_initialized = false;
+struct tv_preferences *preferences = &prefs;
+
 static int listner_count = 0;
 
 #define TV_MAX_LISTNERS 4
 static void (*listners[TV_MAX_LISTNERS])(const struct tv_preferences *oldp);
 
-static void tv_notify_change_preferences(const struct tv_preferences *oldp,
-                                         const struct tv_preferences *newp)
+static void tv_notify_change_preferences(const struct tv_preferences *oldp)
 {
     int i;
 
@@ -45,50 +46,62 @@ static void tv_notify_change_preferences(const struct tv_preferences *oldp,
      *   - autoscroll_speed
      *   - narrow_mode
      */
-    if ((oldp == NULL)                                             ||
-        (oldp->word_mode            != newp->word_mode)            ||
-        (oldp->line_mode            != newp->line_mode)            ||
-        (oldp->windows              != newp->windows)              ||
-        (oldp->horizontal_scrollbar != newp->horizontal_scrollbar) ||
-        (oldp->vertical_scrollbar   != newp->vertical_scrollbar)   ||
-        (oldp->encoding             != newp->encoding)             ||
-        (oldp->indent_spaces        != newp->indent_spaces)        ||
+    if ((oldp == NULL)                                                    ||
+        (oldp->word_mode            != preferences->word_mode)            ||
+        (oldp->line_mode            != preferences->line_mode)            ||
+        (oldp->windows              != preferences->windows)              ||
+        (oldp->horizontal_scrollbar != preferences->horizontal_scrollbar) ||
+        (oldp->vertical_scrollbar   != preferences->vertical_scrollbar)   ||
+        (oldp->encoding             != preferences->encoding)             ||
+        (oldp->indent_spaces        != preferences->indent_spaces)        ||
 #ifdef HAVE_LCD_BITMAP
-        (oldp->header_mode          != newp->header_mode)          ||
-        (oldp->footer_mode          != newp->footer_mode)          ||
-        (rb->strcmp(oldp->font_name, newp->font_name))             ||
+        (oldp->header_mode          != preferences->header_mode)          ||
+        (oldp->footer_mode          != preferences->footer_mode)          ||
+        (rb->strcmp(oldp->font_name, preferences->font_name))             ||
 #endif
-        (rb->strcmp(oldp->file_name, newp->file_name)))
+        (rb->strcmp(oldp->file_name, preferences->file_name)))
     {
-        for (i = listner_count - 1; i >= 0; i--)
+        for (i = 0; i < listner_count; i++)
             listners[i](oldp);
     }
 }
 
-const struct tv_preferences *tv_get_preferences(void)
+static void tv_check_header_and_footer(void)
 {
-    return &prefs;
+    if (rb->global_settings->statusbar != STATUSBAR_TOP)
+    {
+        if (preferences->header_mode == HD_SBAR)
+            preferences->header_mode = HD_NONE;
+        else if (preferences->header_mode == HD_BOTH)
+            preferences->header_mode = HD_PATH;
+    }
+    if (rb->global_settings->statusbar != STATUSBAR_BOTTOM)
+    {
+        if (preferences->footer_mode == FT_SBAR)
+            preferences->footer_mode = FT_NONE;
+        else if (preferences->footer_mode == FT_BOTH)
+            preferences->footer_mode = FT_PAGE;
+    }
 }
 
 void tv_set_preferences(const struct tv_preferences *new_prefs)
 {
+    static struct tv_preferences old_prefs;
     struct tv_preferences *oldp = NULL;
-    struct tv_preferences old_prefs;
+    static bool is_initialized = false;
 
-    if (!is_initialized)
-        is_initialized = true;
-    else
-    {
-        old_prefs = prefs;
-        oldp      = &old_prefs;
-    }
-    rb->memcpy(&prefs, new_prefs, sizeof(struct tv_preferences));
-    tv_notify_change_preferences(oldp, &prefs);
+    if (is_initialized)
+        tv_copy_preferences((oldp = &old_prefs));
+    is_initialized = true;
+
+    rb->memcpy(preferences, new_prefs, sizeof(struct tv_preferences));
+    tv_check_header_and_footer();
+    tv_notify_change_preferences(oldp);
 }
 
 void tv_copy_preferences(struct tv_preferences *copy_prefs)
 {
-    rb->memcpy(copy_prefs, &prefs, sizeof(struct tv_preferences));
+    rb->memcpy(copy_prefs, preferences, sizeof(struct tv_preferences));
 }
 
 void tv_set_default_preferences(struct tv_preferences *p)
@@ -102,7 +115,6 @@ void tv_set_default_preferences(struct tv_preferences *p)
     p->page_mode = NO_OVERLAP;
     p->horizontal_scrollbar = SB_OFF;
     p->vertical_scrollbar = SB_OFF;
-    rb->memset(p->font_name, 0, MAX_PATH);
 #ifdef HAVE_LCD_BITMAP
     p->header_mode = HD_BOTH;
     p->footer_mode = FT_BOTH;
diff --git a/apps/plugins/text_viewer/tv_preferences.h b/apps/plugins/text_viewer/tv_preferences.h
index 1e5c453..906f5c5 100644
--- a/apps/plugins/text_viewer/tv_preferences.h
+++ b/apps/plugins/text_viewer/tv_preferences.h
@@ -23,88 +23,108 @@
 #ifndef PLUGIN_TEXT_VIEWER_PREFERENCES_H
 #define PLUGIN_TEXT_VIEWER_PREFERENCES_H
 
-enum scrollbar_mode {
+/* scrollbar_mode */
+enum {
     SB_OFF = 0,
     SB_ON,
 };
 
+/* word_mode */
+enum {
+    WRAP = 0,
+    CHOP,
+};
+
+/* line_mode */
+enum {
+    NORMAL = 0,
+    JOIN,
+    EXPAND,
+    REFLOW,
+};
+
+/* alignment */
+enum {
+    LEFT = 0,
+    RIGHT,
+};
+
+/* page_mode */
+enum {
+    NO_OVERLAP = 0,
+    OVERLAP,
+};
+
+/* header_mode */
+enum {
+    HD_NONE = 0,
+    HD_PATH,
+    HD_SBAR,
+    HD_BOTH,
+};
+
+/* footer_mode */
+enum {
+
+    FT_NONE = 0,
+    FT_PAGE,
+    FT_SBAR,
+    FT_BOTH,
+};
+
+/* horizontal_scroll_mode */
+enum {
+    SCREEN = 0,
+    COLUMN,
+};
+
+/* vertical_scroll_mode */
+enum {
+    PAGE = 0,
+    LINE,
+};
+
+/* narrow_mode */
+enum {
+    NM_PAGE = 0,
+    NM_TOP_BOTTOM,
+};
+
 struct tv_preferences {
-    enum {
-        WRAP = 0,
-        CHOP,
-    } word_mode;
-
-    enum {
-        NORMAL = 0,
-        JOIN,
-        EXPAND,
-        REFLOW,
-    } line_mode;
-
-    enum {
-        LEFT = 0,
-        RIGHT,
-    } alignment;
-
-    enum codepages encoding;
-
-    enum scrollbar_mode horizontal_scrollbar;
-    enum scrollbar_mode vertical_scrollbar;
-
-    enum {
-        NO_OVERLAP = 0,
-        OVERLAP,
-    } page_mode;
-
-    enum {
-        HD_NONE = 0,
-        HD_PATH,
-        HD_SBAR,
-        HD_BOTH,
-    } header_mode;
-
-    enum {
-        FT_NONE = 0,
-        FT_PAGE,
-        FT_SBAR,
-        FT_BOTH,
-    } footer_mode;
-
-    enum {
-        SCREEN = 0,
-        COLUMN,
-    } horizontal_scroll_mode;
-
-    enum {
-        PAGE = 0,
-        LINE,
-    } vertical_scroll_mode;
+    unsigned word_mode;
+    unsigned line_mode;
+    unsigned alignment;
+
+    unsigned encoding;
+
+    unsigned horizontal_scrollbar;
+    unsigned vertical_scrollbar;
+
+    unsigned page_mode;
+    unsigned header_mode;
+    unsigned footer_mode;
+    unsigned horizontal_scroll_mode;
+    unsigned vertical_scroll_mode;
 
     int autoscroll_speed;
 
     int windows;
 
-    enum {
-        NM_PAGE = 0,
-        NM_TOP_BOTTOM,
-    } narrow_mode;
+    unsigned narrow_mode;
 
-    int indent_spaces;
+    unsigned indent_spaces;
 
-    unsigned char font_name[MAX_PATH];
 #ifdef HAVE_LCD_BITMAP
+    unsigned char font_name[MAX_PATH];
     struct font *font;
 #endif
     unsigned char file_name[MAX_PATH];
 };
 
 /*
- * return the preferences
- *
- * return
- *     the pointer the preferences
+ *     global pointer to the preferences
  */
-const struct tv_preferences *tv_get_preferences(void);
+extern struct tv_preferences *preferences;
 
 /*
  * change the preferences
diff --git a/apps/plugins/text_viewer/tv_reader.c b/apps/plugins/text_viewer/tv_reader.c
index 6dc66ef..e31f761 100644
--- a/apps/plugins/text_viewer/tv_reader.c
+++ b/apps/plugins/text_viewer/tv_reader.c
@@ -135,7 +135,6 @@ void tv_seek(off_t offset, int whence)
 static void tv_change_preferences(const struct tv_preferences *oldp)
 {
     unsigned char bom[BOM_SIZE];
-    const struct tv_preferences *prefs = tv_get_preferences();
     int cur_start_file_pos = start_file_pos;
     off_t cur_file_pos     = file_pos + buf_pos;
 
@@ -145,21 +144,21 @@ static void tv_change_preferences(const struct tv_preferences *oldp)
     start_file_pos = 0;
 
     /* open the new file */
-    if (oldp == NULL || rb->strcmp(oldp->file_name, prefs->file_name))
+    if (oldp == NULL || rb->strcmp(oldp->file_name, preferences->file_name))
     {
         if (fd >= 0)
             rb->close(fd);
 
-        fd = rb->open(prefs->file_name, O_RDONLY);
+        fd = rb->open(preferences->file_name, O_RDONLY);
         if (fd < 0)
             return;
     }
 
     /*
-     * When a file is UTF-8 file with BOM, if prefs.encoding is UTF-8,
+     * When a file is UTF-8 file with BOM, if encoding is UTF-8,
      * then file size decreases only BOM_SIZE.
      */
-    if (prefs->encoding == UTF_8)
+    if (preferences->encoding == UTF_8)
     {
         rb->lseek(fd, 0, SEEK_SET);
         rb->read(fd, bom, BOM_SIZE);
diff --git a/apps/plugins/text_viewer/tv_settings.c b/apps/plugins/text_viewer/tv_settings.c
index 6b16218..c52bbe5 100644
--- a/apps/plugins/text_viewer/tv_settings.c
+++ b/apps/plugins/text_viewer/tv_settings.c
@@ -181,9 +181,9 @@ static bool tv_read_preferences(int pfd, int version, struct tv_preferences *pre
     else
         prefs->indent_spaces = 2;
 
+#ifdef HAVE_LCD_BITMAP
     rb->memcpy(prefs->font_name, buf + read_size - MAX_PATH, MAX_PATH);
 
-#ifdef HAVE_LCD_BITMAP
     prefs->font = rb->font_get(FONT_UI);
 #endif
 
@@ -213,7 +213,9 @@ static bool tv_write_preferences(int pfd, const struct tv_preferences *prefs)
     *p++ = prefs->narrow_mode;
     *p++ = prefs->indent_spaces;
 
+#ifdef HAVE_LCD_BITMAP
     rb->memcpy(buf + 28, prefs->font_name, MAX_PATH);
+#endif
 
     return (rb->write(pfd, buf, TV_PREFERENCES_SIZE) >= 0);
 }
@@ -457,7 +459,6 @@ static bool tv_copy_settings(int sfd, int dfd, int size)
 
 bool tv_save_settings(void)
 {
-    const struct tv_preferences *prefs = tv_get_preferences();
     unsigned char buf[MAX_PATH+2];
     unsigned int fcount = 0;
     unsigned int i;
@@ -502,7 +503,7 @@ bool tv_save_settings(void)
                 }
 
                 size = (buf[MAX_PATH] << 8) | buf[MAX_PATH + 1];
-                if (rb->strcmp(buf, prefs->file_name) == 0)
+                if (rb->strcmp(buf, preferences->file_name) == 0)
                     rb->lseek(ofd, size, SEEK_CUR);
                 else
                 {
@@ -523,11 +524,11 @@ bool tv_save_settings(void)
         /* save to current read file's preferences and bookmarks */
         res = false;
         rb->memset(buf, 0, MAX_PATH);
-        rb->strlcpy(buf, prefs->file_name, MAX_PATH);
+        rb->strlcpy(buf, preferences->file_name, MAX_PATH);
 
         if (rb->write(tfd, buf, MAX_PATH + 2) >= 0)
         {
-            if (tv_write_preferences(tfd, prefs))
+            if (tv_write_preferences(tfd, preferences))
             {
                 size = tv_serialize_bookmarks(tfd);
                 if (size > 0)
diff --git a/apps/plugins/text_viewer/tv_text_processor.c b/apps/plugins/text_viewer/tv_text_processor.c
index 5e30f0b..62ef764 100644
--- a/apps/plugins/text_viewer/tv_text_processor.c
+++ b/apps/plugins/text_viewer/tv_text_processor.c
@@ -25,7 +25,7 @@
 #include "tv_preferences.h"
 #include "tv_text_processor.h"
 
-enum tv_text_type {
+enum{
     TV_TEXT_UNKNOWN,
     TV_TEXT_MAC,
     TV_TEXT_UNIX,
@@ -41,8 +41,7 @@ enum tv_text_type {
 
 #define TV_MAX_BLOCKS 5
 
-static const struct tv_preferences *prefs;
-static enum tv_text_type text_type = TV_TEXT_UNKNOWN;
+static unsigned text_type = TV_TEXT_UNKNOWN;
 
 static const unsigned char *end_ptr;
 
@@ -96,7 +95,7 @@ static int tv_glyph_width(int ch)
     if (rb->is_diacritic(ch, NULL))
         return 0;
 
-    return rb->font_get_width(prefs->font, ch);
+    return rb->font_get_width(preferences->font, ch);
 #else
     return 1;
 #endif
@@ -136,13 +135,13 @@ static unsigned char *tv_get_ucs(const unsigned char *str, unsigned short *ch)
         return (unsigned char *)str + 1;
     }
 
-    if (prefs->encoding == UTF_8)
+    if (preferences->encoding == UTF_8)
         return (unsigned char*)rb->utf8decode(str, ch);
 
 #ifdef HAVE_LCD_BITMAP
     if ((*str >= 0x80) &&
-        ((prefs->encoding > SJIS) ||
-         (prefs->encoding == SJIS && (*str <= 0xa0 || *str >= 0xe0))))
+        ((preferences->encoding > SJIS) ||
+         (preferences->encoding == SJIS && (*str <= 0xa0 || *str >= 0xe0))))
     {
         if (str + 1 >= end_ptr)
         {
@@ -153,7 +152,7 @@ static unsigned char *tv_get_ucs(const unsigned char *str, unsigned short *ch)
         count = 2;
     }
 #endif
-    rb->iso_decode(str, utf8_tmp, prefs->encoding, count);
+    rb->iso_decode(str, utf8_tmp, preferences->encoding, count);
     rb->utf8decode(utf8_tmp, ch);
     return (unsigned char *)str + count;
 }
@@ -173,7 +172,7 @@ static bool tv_is_line_break_char(unsigned short ch)
     size_t i;
 
     /* when the word mode is CHOP, all characters does not break line. */
-    if (prefs->word_mode == CHOP)
+    if (preferences->word_mode == CHOP)
         return false;
 
     for (i = 0; i < sizeof(break_chars); i++)
@@ -222,7 +221,7 @@ static int tv_form_reflow_line(unsigned short *ucs, int chars)
     int spaces = 0;
     int words_spaces;
 
-    if (prefs->alignment == LEFT)
+    if (preferences->alignment == LEFT)
     {
         while (chars > 0 && ucs[chars-1] == ' ')
             chars--;
@@ -368,7 +367,6 @@ static int tv_parse_text(const unsigned char *src, unsigned short *ucs,
     unsigned short prev_ch;
     int chars = 0;
     int gw;
-    int i;
     int line_break_width = 0;
     int line_end_chars   = 0;
     int width = 0;
@@ -388,7 +386,7 @@ static int tv_parse_text(const unsigned char *src, unsigned short *ucs,
         next = tv_get_ucs(cur, &ch);
         if (ch == '\n')
         {
-            if (prefs->line_mode != JOIN || tv_is_break_line_join_mode(next))
+            if (preferences->line_mode != JOIN || tv_is_break_line_join_mode(next))
             {
                 line_end_ptr   = next;
                 line_end_chars = chars;
@@ -396,7 +394,7 @@ static int tv_parse_text(const unsigned char *src, unsigned short *ucs,
                 break;
             }
 
-            if (prefs->word_mode == CHOP || tv_isspace(prev_ch))
+            if (preferences->word_mode == CHOP || tv_isspace(prev_ch))
                 continue;
 
             /*
@@ -413,7 +411,7 @@ static int tv_parse_text(const unsigned char *src, unsigned short *ucs,
              *     (1) spacelike character convert to ' '
              *     (2) plural spaces are collected to one
              */
-            if (prefs->line_mode == REFLOW)
+            if (preferences->line_mode == REFLOW)
             {
                 ch = ' ';
                 if (prev_ch == ch)
@@ -421,14 +419,14 @@ static int tv_parse_text(const unsigned char *src, unsigned short *ucs,
             }
 
             /* when the alignment is RIGHT, ignores indent spaces. */
-            if (prefs->alignment == RIGHT && is_indent)
+            if (preferences->alignment == RIGHT && is_indent)
                 continue;
         }
         else
             is_indent = false;
 
-        if (prefs->line_mode == REFLOW && is_indent)
-            gw = tv_glyph_width(ch) * prefs->indent_spaces;
+        if (preferences->line_mode == REFLOW && is_indent)
+            gw = tv_glyph_width(ch) * preferences->indent_spaces;
         else
             gw = tv_glyph_width(ch);
 
@@ -445,11 +443,12 @@ static int tv_parse_text(const unsigned char *src, unsigned short *ucs,
             break;
         }
 
-        if (prefs->line_mode != REFLOW || !is_indent)
+        if (preferences->line_mode != REFLOW || !is_indent)
             ucs[chars++] = ch;
         else
         {
-            for (i = 0; i < prefs->indent_spaces; i++)
+            unsigned char i;
+            for (i = 0; i < preferences->indent_spaces; i++)
                 ucs[chars++] = ch;
         }
 
@@ -473,7 +472,7 @@ static int tv_parse_text(const unsigned char *src, unsigned short *ucs,
          * when the last line break position is too short (line length < 0.75 * block width),
          * the line is cut off at the position where it is closest to the displayed width.
          */
-        if ((prefs->line_mode == REFLOW && line_break_ptr == NULL) ||
+        if ((preferences->line_mode == REFLOW && line_break_ptr == NULL) ||
             (4 * line_break_width < 3 * block_width))
         {
             line_end_ptr   = cur;
@@ -505,7 +504,7 @@ int tv_create_formed_text(const unsigned char *src, ssize_t bufsize,
     if (dst != NULL)
         *dst = utf8buf;
 
-    if (prefs->line_mode == EXPAND && (expand_extra_line = !expand_extra_line) == true)
+    if (preferences->line_mode == EXPAND && (expand_extra_line = !expand_extra_line) == true)
         return 0;
 
     end_ptr = src + bufsize;
@@ -513,7 +512,7 @@ int tv_create_formed_text(const unsigned char *src, ssize_t bufsize,
     tv_get_ucs(src, &ch);
     is_indent = (tv_isspace(ch) && !is_break_line);
 
-    if (is_indent && prefs->indent_spaces == 0 && (expand_extra_line = !expand_extra_line) == true)
+    if (is_indent && preferences->indent_spaces == 0 && (expand_extra_line = !expand_extra_line) == true)
         return 0;
 
     for (i = 0; i < block_count; i++)
@@ -527,14 +526,14 @@ int tv_create_formed_text(const unsigned char *src, ssize_t bufsize,
 
     if (dst != NULL)
     {
-        if (prefs->alignment == RIGHT)
+        if (preferences->alignment == RIGHT)
             tv_align_right(chars);
 
         for (i = 0; i < block_count; i++)
         {
             if (i == block || (is_multi && i == block + 1))
             {
-                if (is_break_line && prefs->line_mode == REFLOW)
+                if (is_break_line && preferences->line_mode == REFLOW)
                     chars[i] = tv_form_reflow_line(ucsbuf[i], chars[i]);
 
                 tv_decode2utf8(ucsbuf[i], chars[i]);
@@ -553,7 +552,6 @@ bool tv_init_text_processor(unsigned char *buf, size_t bufsize, size_t *used_siz
     if (bufsize < *used_size)
         return false;
 
-    prefs = tv_get_preferences();
     text_type = TV_TEXT_UNKNOWN;
     expand_extra_line = false;
     is_break_line = false;
diff --git a/apps/plugins/text_viewer/tv_window.c b/apps/plugins/text_viewer/tv_window.c
index 1ffc921..23648bb 100644
--- a/apps/plugins/text_viewer/tv_window.c
+++ b/apps/plugins/text_viewer/tv_window.c
@@ -50,8 +50,6 @@ static int col_width;
 static int cur_window;
 static int cur_column;
 
-static const struct tv_preferences *prefs = NULL;
-
 #ifdef HAVE_LCD_BITMAP
 static bool tv_set_font(const unsigned char *font)
 {
@@ -69,46 +67,23 @@ static bool tv_set_font(const unsigned char *font)
     return true;
 }
 
-static void tv_check_header_and_footer(void)
-{
-    struct tv_preferences new_prefs;
-
-    tv_copy_preferences(&new_prefs);
-
-    if (rb->global_settings->statusbar != STATUSBAR_TOP)
-    {
-        if (new_prefs.header_mode == HD_SBAR)
-            new_prefs.header_mode = HD_NONE;
-        else if (new_prefs.header_mode == HD_BOTH)
-            new_prefs.header_mode = HD_PATH;
-    }
-    if (rb->global_settings->statusbar != STATUSBAR_BOTTOM)
-    {
-        if (new_prefs.footer_mode == FT_SBAR)
-            new_prefs.footer_mode = FT_NONE;
-        else if (new_prefs.footer_mode == FT_BOTH)
-            new_prefs.footer_mode = FT_PAGE;
-    }
-    tv_set_preferences(&new_prefs);
-}
-
 static void tv_show_header(void)
 {
-    if (prefs->header_mode == HD_SBAR || prefs->header_mode == HD_BOTH)
+    if (preferences->header_mode == HD_SBAR || preferences->header_mode == HD_BOTH)
         rb->gui_syncstatusbar_draw(rb->statusbars, true);
 
-    if (prefs->header_mode == HD_PATH || prefs->header_mode == HD_BOTH)
-        rb->lcd_putsxy(0, header_height - prefs->font->height, prefs->file_name);
+    if (preferences->header_mode == HD_PATH || preferences->header_mode == HD_BOTH)
+        rb->lcd_putsxy(0, header_height - preferences->font->height, preferences->file_name);
 }
 
 static void tv_show_footer(const struct tv_screen_pos *pos)
 {
     unsigned char buf[12];
 
-    if (prefs->footer_mode == FT_SBAR || prefs->footer_mode == FT_BOTH)
+    if (preferences->footer_mode == FT_SBAR || preferences->footer_mode == FT_BOTH)
         rb->gui_syncstatusbar_draw(rb->statusbars, true);
 
-    if (prefs->footer_mode == FT_PAGE || prefs->footer_mode == FT_BOTH)
+    if (preferences->footer_mode == FT_PAGE || preferences->footer_mode == FT_BOTH)
     {
         if (pos->line == 0)
             rb->snprintf(buf, sizeof(buf), "%d", pos->page + 1);
@@ -128,9 +103,9 @@ static void tv_show_scrollbar(off_t cur_pos, int size)
     int sb_height;
 
     sb_height = LCD_HEIGHT - header_height - footer_height;
-    if (prefs->horizontal_scrollbar)
+    if (preferences->horizontal_scrollbar)
     {
-        items     = prefs->windows * window_columns;
+        items     = preferences->windows * window_columns;
         min_shown = cur_window * window_columns + cur_column;
         max_shown = min_shown + window_columns;
         sb_width  = (need_vertical_scrollbar)? TV_SCROLLBAR_WIDTH : 0;
@@ -157,25 +132,27 @@ static void tv_show_scrollbar(off_t cur_pos, int size)
 
 static int tv_calc_display_lines(void)
 {
-    int scrollbar_height = (prefs->horizontal_scrollbar)? TV_SCROLLBAR_HEIGHT : 0;
+    int scrollbar_height = preferences->horizontal_scrollbar ? TV_SCROLLBAR_HEIGHT : 0;
+    unsigned header_mode = preferences->header_mode;
+    unsigned footer_mode = preferences->footer_mode;
 
-    header_height = (prefs->header_mode == HD_SBAR || prefs->header_mode == HD_BOTH)?
+    header_height = (header_mode == HD_SBAR || header_mode == HD_BOTH)?
                     STATUSBAR_HEIGHT : 0;
 
-    footer_height = (prefs->footer_mode == FT_SBAR || prefs->footer_mode == FT_BOTH)?
+    footer_height = (footer_mode == FT_SBAR || footer_mode == FT_BOTH)?
                     STATUSBAR_HEIGHT : 0;
 
-    if (prefs->header_mode == HD_NONE || prefs->header_mode == HD_PATH ||
-        prefs->footer_mode == FT_NONE || prefs->footer_mode == FT_PAGE)
+    if (header_mode == HD_NONE || header_mode == HD_PATH ||
+        footer_mode == FT_NONE || footer_mode == FT_PAGE)
         rb->gui_syncstatusbar_draw(rb->statusbars, false);
 
-    if (prefs->header_mode == HD_PATH || prefs->header_mode == HD_BOTH)
-        header_height += prefs->font->height;
+    if (header_mode == HD_PATH || header_mode == HD_BOTH)
+        header_height += preferences->font->height;
 
-    if (prefs->footer_mode == FT_PAGE || prefs->footer_mode == FT_BOTH)
-        footer_height += prefs->font->height;
+    if (footer_mode == FT_PAGE || footer_mode == FT_BOTH)
+        footer_height += preferences->font->height;
 
-    return (LCD_HEIGHT - header_height - footer_height - scrollbar_height) / prefs->font->height;
+    return (LCD_HEIGHT - header_height - footer_height - scrollbar_height) / preferences->font->height;
 }
 #endif
 
@@ -195,8 +172,8 @@ static void tv_show_bookmarks(const struct tv_screen_pos *top_pos)
         if (line >= 0 && line < display_lines)
         {
 #ifdef HAVE_LCD_BITMAP
-            rb->lcd_fillrect(start_width, header_height + line * prefs->font->height,
-                             window_width, prefs->font->height);
+            rb->lcd_fillrect(start_width, header_height + line * preferences->font->height,
+                             window_width, preferences->font->height);
 #else
             rb->lcd_putc(start_width - 1, line, TV_BOOKMARK_ICON);
 #endif
@@ -215,30 +192,30 @@ void tv_draw_window(void)
     int offset = cur_column * col_width;
     int size = 0;
     int line_width;
-    int draw_width = (prefs->windows - cur_window) * LCD_WIDTH - offset;
+    int draw_width = (preferences->windows - cur_window) * LCD_WIDTH - offset;
     int dx = start_width - offset;
 
     tv_copy_screen_pos(&pos);
     rb->lcd_clear_display();
 
-    if (prefs->alignment == LEFT)
+    if (preferences->alignment == LEFT)
         tv_read_start(cur_window, (cur_column > 0));
     else
-        tv_read_start(0, prefs->windows > 1);
+        tv_read_start(0, preferences->windows > 1);
 
     for (line = 0; line < display_lines; line++)
     {
         if (!tv_get_next_line(&line_buf))
             break;
 
-        if (prefs->alignment == RIGHT)
+        if (preferences->alignment == RIGHT)
         {
             rb->lcd_getstringsize(line_buf, &line_width, NULL);
             dx = draw_width - line_width;
         }
 
 #ifdef HAVE_LCD_BITMAP
-        rb->lcd_putsxy(dx, header_height + line * prefs->font->height, line_buf);
+        rb->lcd_putsxy(dx, header_height + line * preferences->font->height, line_buf);
 #else
         rb->lcd_puts(dx, line, line_buf);
 #endif
@@ -284,12 +261,13 @@ static void tv_change_preferences(const struct tv_preferences *oldp)
     font_str = (oldp && !font_changing)? oldp->font_name : rb->global_settings->font_file;
 
     /* change font */
-    if (font_changing || rb->strcmp(font_str, prefs->font_name))
+    if (font_changing || rb->strcmp(font_str, preferences->font_name))
     {
         font_changing = true;
-        if (!tv_set_font(prefs->font_name))
+        if (!tv_set_font(preferences->font_name))
         {
-            struct tv_preferences new_prefs = *prefs;
+            struct tv_preferences new_prefs;
+            tv_copy_preferences(&new_prefs);
 
             rb->strlcpy(new_prefs.font_name, font_str, MAX_PATH);
             tv_set_preferences(&new_prefs);
@@ -299,7 +277,6 @@ static void tv_change_preferences(const struct tv_preferences *oldp)
     font_changing = false;
 
     /* calculates display lines */
-    tv_check_header_and_footer();
     display_lines = tv_calc_display_lines();
 #else
     (void)oldp;
@@ -309,12 +286,12 @@ static void tv_change_preferences(const struct tv_preferences *oldp)
 #endif
 
 #ifdef HAVE_LCD_BITMAP
-    col_width = 2 * rb->font_get_width(prefs->font, ' ');
+    col_width = 2 * rb->font_get_width(preferences->font, ' ');
 #else
     col_width = 1;
 #endif
 
-    if (cur_window >= prefs->windows)
+    if (cur_window >= preferences->windows)
         cur_window = 0;
 
     window_width = LCD_WIDTH;
@@ -322,8 +299,8 @@ static void tv_change_preferences(const struct tv_preferences *oldp)
     need_vertical_scrollbar = false;
     start_width = 0;
     tv_seek_top();
-    tv_set_read_conditions(prefs->windows, window_width);
-    if (tv_traverse_lines() && prefs->vertical_scrollbar)
+    tv_set_read_conditions(preferences->windows, window_width);
+    if (tv_traverse_lines() && preferences->vertical_scrollbar)
     {
         need_vertical_scrollbar = true;
         start_width = TV_SCROLLBAR_WIDTH;
@@ -337,7 +314,7 @@ static void tv_change_preferences(const struct tv_preferences *oldp)
 
     cur_column = 0;
 
-    tv_set_read_conditions(prefs->windows, window_width);
+    tv_set_read_conditions(preferences->windows, window_width);
 }
 
 bool tv_init_window(unsigned char *buf, size_t bufsize, size_t *used_size)
@@ -346,7 +323,6 @@ bool tv_init_window(unsigned char *buf, size_t bufsize, size_t *used_size)
     if (!tv_init_text_reader(buf, bufsize, used_size))
         return false;
 
-    prefs = tv_get_preferences();
     return true;
 }
 
@@ -356,7 +332,7 @@ void tv_finalize_window(void)
 
 #ifdef HAVE_LCD_BITMAP
     /* restore font */
-    if (rb->strcmp(rb->global_settings->font_file, prefs->font_name))
+    if (rb->strcmp(rb->global_settings->font_file, preferences->font_name))
     {
         tv_set_font(rb->global_settings->font_file);
     }
@@ -373,9 +349,9 @@ void tv_move_window(int window_delta, int column_delta)
         cur_window = 0;
         cur_column = 0;
     }
-    else if (cur_window >= prefs->windows)
+    else if (cur_window >= preferences->windows)
     {
-        cur_window = prefs->windows - 1;
+        cur_window = preferences->windows - 1;
         cur_column = 0;
     }
 
@@ -391,7 +367,7 @@ void tv_move_window(int window_delta, int column_delta)
     }
     else
     {
-        if (cur_window == prefs->windows - 1)
+        if (cur_window == preferences->windows - 1)
             cur_column = 0;
         else if (cur_column >= window_columns)
         {
