diff --git a/doc/How_to_build_Slic3r.txt b/doc/How_to_build_Slic3r.txt
index a1d112981..22e6f953e 100644
--- a/doc/How_to_build_Slic3r.txt
+++ b/doc/How_to_build_Slic3r.txt
@@ -311,5 +311,6 @@ One may save compilation time by compiling just what Slic3r needs.
 ./bootstrap.sh --with-libraries=system,filesystem,thread,log,locale,regex
 The -fPIC flag is required on Linux to make the static libraries rellocatable,
 so they could be embedded into a shared library.
-./bjam -a link=static variant=release threading=multi cxxflags=-fPIC cflags=-fPIC
+It is important to disable boost.locale.icu=off when compiling the static boost library.
+./bjam -a link=static variant=release threading=multi boost.locale.icu=off --with-locale cxxflags=-fPIC cflags=-fPIC
 To install on Linux to /usr/local/..., run the line above with the additional install keyword and with sudo.
diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm
index 66039ddf0..e55e24a7a 100644
--- a/lib/Slic3r.pm
+++ b/lib/Slic3r.pm
@@ -43,6 +43,7 @@ use FindBin;
 # Let the XS module know where the GUI resources reside.
 set_resources_dir(decode_path($FindBin::Bin) . (($^O eq 'darwin') ? '/../Resources' : '/resources'));
 set_var_dir(resources_dir() . "/icons");
+set_local_dir(resources_dir() . "/localization/");
 
 use Moo 1.003001;
 
@@ -136,6 +137,7 @@ sub thread_cleanup {
     *Slic3r::Flow::DESTROY                  = sub {};
     *Slic3r::GCode::DESTROY                 = sub {};
     *Slic3r::GCode::PlaceholderParser::DESTROY = sub {};
+    *Slic3r::GCode::PreviewData::DESTROY    = sub {};
     *Slic3r::GCode::Sender::DESTROY         = sub {};
     *Slic3r::Geometry::BoundingBox::DESTROY = sub {};
     *Slic3r::Geometry::BoundingBoxf::DESTROY = sub {};
diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm
index 5d6d8e4a6..54a27dc99 100644
--- a/lib/Slic3r/GUI.pm
+++ b/lib/Slic3r/GUI.pm
@@ -31,7 +31,6 @@ use Slic3r::GUI::ProgressStatusBar;
 use Slic3r::GUI::OptionsGroup;
 use Slic3r::GUI::OptionsGroup::Field;
 use Slic3r::GUI::SystemInfo;
-use Slic3r::GUI::Tab;
 
 our $have_OpenGL = eval "use Slic3r::GUI::3DScene; 1";
 our $have_LWP    = eval "use LWP::UserAgent; 1";
@@ -41,16 +40,17 @@ use Wx::Event qw(EVT_IDLE EVT_COMMAND EVT_MENU);
 use base 'Wx::App';
 
 use constant FILE_WILDCARDS => {
-    known   => 'Known files (*.stl, *.obj, *.amf, *.xml, *.prusa)|*.stl;*.STL;*.obj;*.OBJ;*.amf;*.AMF;*.xml;*.XML;*.prusa;*.PRUSA',
+    known   => 'Known files (*.stl, *.obj, *.amf, *.xml, *.3mf, *.prusa)|*.stl;*.STL;*.obj;*.OBJ;*.amf;*.AMF;*.xml;*.XML;*.3mf;*.3MF;*.prusa;*.PRUSA',
     stl     => 'STL files (*.stl)|*.stl;*.STL',
     obj     => 'OBJ files (*.obj)|*.obj;*.OBJ',
     amf     => 'AMF files (*.amf)|*.amf;*.AMF;*.xml;*.XML',
+    threemf => '3MF files (*.3mf)|*.3mf;*.3MF',
     prusa   => 'Prusa Control files (*.prusa)|*.prusa;*.PRUSA',
     ini     => 'INI files *.ini|*.ini;*.INI',
     gcode   => 'G-code files (*.gcode, *.gco, *.g, *.ngc)|*.gcode;*.GCODE;*.gco;*.GCO;*.g;*.G;*.ngc;*.NGC',
     svg     => 'SVG files *.svg|*.svg;*.SVG',
 };
-use constant MODEL_WILDCARD => join '|', @{&FILE_WILDCARDS}{qw(known stl obj amf prusa)};
+use constant MODEL_WILDCARD => join '|', @{&FILE_WILDCARDS}{qw(known stl obj amf threemf prusa)};
 
 # Datadir provided on the command line.
 our $datadir;
@@ -67,6 +67,10 @@ our $medium_font = Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
 $medium_font->SetPointSize(12);
 our $grey = Wx::Colour->new(200,200,200);
 
+# Events to be sent from a C++ menu implementation:
+# 1) To inform about a change of the application language.
+our $LANGUAGE_CHANGE_EVENT    = Wx::NewEventType;
+
 sub OnInit {
     my ($self) = @_;
     
@@ -80,6 +84,7 @@ sub OnInit {
     # Mac: "~/Library/Application Support/Slic3r"
     Slic3r::set_data_dir($datadir || Wx::StandardPaths::Get->GetUserDataDir);
     Slic3r::GUI::set_wxapp($self);
+    Slic3r::GUI::load_language();
     
     $self->{notifier} = Slic3r::GUI::Notifier->new;
     $self->{app_config} = Slic3r::GUI::AppConfig->new;
@@ -114,10 +119,12 @@ sub OnInit {
         # If set, the "Controller" tab for the control of the printer over serial line and the serial port settings are hidden.
         no_controller   => $self->{app_config}->get('no_controller'),
         no_plater       => $no_plater,
+        lang_ch_event   => $LANGUAGE_CHANGE_EVENT,
     );
     $self->SetTopWindow($frame);
 
-    EVT_IDLE($frame, sub {
+    #EVT_IDLE($frame, sub {
+    EVT_IDLE($self->{mainframe}, sub {
         while (my $cb = shift @cb) {
             $cb->();
         }
@@ -132,10 +139,42 @@ sub OnInit {
             $self->{mainframe}->config_wizard(1);
         });
     }
+
+    # The following event is emited by the C++ menu implementation of application language change.
+    EVT_COMMAND($self, -1, $LANGUAGE_CHANGE_EVENT, sub{
+        $self->recreate_GUI;
+    });
     
     return 1;
 }
 
+sub recreate_GUI{
+    my ($self) = @_;
+    my $topwindow = $self->GetTopWindow();
+    $self->{mainframe} = my $frame = Slic3r::GUI::MainFrame->new(
+        # If set, the "Controller" tab for the control of the printer over serial line and the serial port settings are hidden.
+        no_controller   => $self->{app_config}->get('no_controller'),
+        no_plater       => $no_plater,
+        lang_ch_event   => $LANGUAGE_CHANGE_EVENT,
+    );
+
+    if($topwindow)
+    {
+        $self->SetTopWindow($frame);
+        $topwindow->Destroy;
+    }
+
+    my $run_wizard = 1 if $self->{preset_bundle}->has_defauls_only;
+    if ($run_wizard) {
+        # On OSX the UI was not initialized correctly if the wizard was called
+        # before the UI was up and running.
+        $self->CallAfter(sub {
+            # Run the config wizard, don't offer the "reset user profile" checkbox.
+            $self->{mainframe}->config_wizard(1);
+        });
+    }
+}
+
 sub about {
     my ($self) = @_;
     my $about = Slic3r::GUI::AboutDialog->new(undef);
diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm
index 730216a8b..b16f7db42 100644
--- a/lib/Slic3r/GUI/3DScene.pm
+++ b/lib/Slic3r/GUI/3DScene.pm
@@ -4,7 +4,7 @@
 # Slic3r::GUI::3DScene;
 #
 # Slic3r::GUI::Plater::3D derives from Slic3r::GUI::3DScene,
-# Slic3r::GUI::Plater::3DPreview, Slic3r::GUI::Plater::3DToolpaths, 
+# Slic3r::GUI::Plater::3DPreview,
 # Slic3r::GUI::Plater::ObjectCutDialog and Slic3r::GUI::Plater::ObjectPartsPanel
 # own $self->{canvas} of the Slic3r::GUI::3DScene type.
 #
@@ -66,8 +66,12 @@ __PACKAGE__->mk_accessors( qw(_quat _dirty init
                               _camera_target
                               _camera_distance
                               _zoom
+                              
+                              _legend_enabled
+                              _apply_zoom_to_volumes_filter
+                                                            
                               ) );
-
+                              
 use constant TRACKBALLSIZE  => 0.8;
 use constant TURNTABLE_MODE => 1;
 use constant GROUND_Z       => -0.02;
@@ -137,7 +141,9 @@ sub new {
     $self->_stheta(45);
     $self->_sphi(45);
     $self->_zoom(1);
+    $self->_legend_enabled(0);
     $self->use_plain_shader(0);
+    $self->_apply_zoom_to_volumes_filter(0);
 
     # Collection of GLVolume objects
     $self->volumes(Slic3r::GUI::_3DScene::GLVolume::Collection->new);
@@ -209,6 +215,11 @@ sub new {
     return $self;
 }
 
+sub set_legend_enabled {
+    my ($self, $value) = @_;
+   $self->_legend_enabled($value);
+}
+
 sub Destroy {
     my ($self) = @_;
     $self->{layer_height_edit_timer}->Stop;
@@ -695,14 +706,18 @@ sub zoom_to_volume {
 
 sub zoom_to_volumes {
     my ($self) = @_;
+    $self->_apply_zoom_to_volumes_filter(1);
     $self->zoom_to_bounding_box($self->volumes_bounding_box);
+    $self->_apply_zoom_to_volumes_filter(0);
 }
 
 sub volumes_bounding_box {
     my ($self) = @_;
     
     my $bb = Slic3r::Geometry::BoundingBoxf3->new;
-    $bb->merge($_->transformed_bounding_box) for @{$self->volumes};
+    foreach my $v (@{$self->volumes}) {
+        $bb->merge($v->transformed_bounding_box) if (! $self->_apply_zoom_to_volumes_filter || $v->zoom_to_volumes);
+    }
     return $bb;
 }
 
@@ -1316,6 +1331,9 @@ sub Render {
         glDisable(GL_BLEND);
     }
 
+    # draw gcode preview legend
+    $self->draw_legend;
+    
     $self->draw_active_object_annotations;
     
     $self->SwapBuffers();
@@ -1449,12 +1467,18 @@ sub _variable_layer_thickness_load_reset_image {
 # Paint the tooltip.
 sub _render_image {
     my ($self, $image, $l, $r, $b, $t) = @_;
+    $self->_render_texture($image->{texture_id}, $l, $r, $b, $t);
+}
+
+sub _render_texture {
+    my ($self, $tex_id, $l, $r, $b, $t) = @_;
+    
     glColor4f(1.,1.,1.,1.);
     glDisable(GL_LIGHTING);
     glEnable(GL_BLEND);
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     glEnable(GL_TEXTURE_2D);
-    glBindTexture(GL_TEXTURE_2D, $image->{texture_id});
+    glBindTexture(GL_TEXTURE_2D, $tex_id);
     glBegin(GL_QUADS);
     glTexCoord2d(0.,1.); glVertex3f($l, $b, 0);
     glTexCoord2d(1.,1.); glVertex3f($r, $b, 0);
@@ -1579,6 +1603,38 @@ sub draw_active_object_annotations {
     glEnable(GL_DEPTH_TEST);
 }
 
+sub draw_legend {
+    my ($self) = @_;
+ 
+    if ($self->_legend_enabled)
+    {
+        # If the legend texture has not been loaded into the GPU, do it now.
+        my $tex_id = Slic3r::GUI::_3DScene::finalize_legend_texture;
+        if ($tex_id > 0)
+        {
+            my $tex_w = Slic3r::GUI::_3DScene::get_legend_texture_width;
+            my $tex_h = Slic3r::GUI::_3DScene::get_legend_texture_height;
+            if (($tex_w > 0) && ($tex_h > 0))
+            {
+                glDisable(GL_DEPTH_TEST);
+                glPushMatrix();
+                glLoadIdentity();
+        
+                my ($cw, $ch) = $self->GetSizeWH;
+                
+                my $l = (-0.5 * $cw) / $self->_zoom;
+                my $t = (0.5 * $ch) / $self->_zoom;
+                my $r = $l + $tex_w / $self->_zoom;
+                my $b = $t - $tex_h / $self->_zoom;
+                $self->_render_texture($tex_id, $l, $r, $b, $t);
+
+                glPopMatrix();
+                glEnable(GL_DEPTH_TEST);
+            }
+        }
+    }
+}
+
 sub opengl_info
 {
     my ($self, %params) = @_;
@@ -1979,9 +2035,20 @@ sub load_wipe_tower_toolpaths {
         if ($print->step_done(STEP_WIPE_TOWER));
 }
 
+sub load_gcode_preview {
+    my ($self, $print, $gcode_preview_data, $colors) = @_;
+
+    $self->SetCurrent($self->GetContext) if $self->UseVBOs;
+    Slic3r::GUI::_3DScene::load_gcode_preview($print, $gcode_preview_data, $self->volumes, $colors, $self->UseVBOs);
+}
+
 sub set_toolpaths_range {
     my ($self, $min_z, $max_z) = @_;
     $self->volumes->set_range($min_z, $max_z);
 }
 
+sub reset_legend_texture {
+    Slic3r::GUI::_3DScene::reset_legend_texture();
+}
+
 1;
diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm
index 6b07d761d..a3ebea0b8 100644
--- a/lib/Slic3r/GUI/MainFrame.pm
+++ b/lib/Slic3r/GUI/MainFrame.pm
@@ -11,13 +11,23 @@ use List::Util qw(min first);
 use Slic3r::Geometry qw(X Y);
 use Wx qw(:frame :bitmap :id :misc :notebook :panel :sizer :menu :dialog :filedialog
     :font :icon wxTheApp);
-use Wx::Event qw(EVT_CLOSE EVT_MENU EVT_NOTEBOOK_PAGE_CHANGED);
+use Wx::Event qw(EVT_CLOSE EVT_COMMAND EVT_MENU EVT_NOTEBOOK_PAGE_CHANGED);
 use base 'Wx::Frame';
 
 our $qs_last_input_file;
 our $qs_last_output_file;
 our $last_config;
 
+# Events to be sent from a C++ Tab implementation:
+# 1) To inform about a change of a configuration value.
+our $VALUE_CHANGE_EVENT    = Wx::NewEventType;
+# 2) To inform about a preset selection change or a "modified" status change.
+our $PRESETS_CHANGED_EVENT = Wx::NewEventType;
+# 3) To inform about a click on Browse button
+our $BUTTON_BROWSE_EVENT   = Wx::NewEventType;
+# 4) To inform about a click on Test button
+our $BUTTON_TEST_EVENT     = Wx::NewEventType;
+
 sub new {
     my ($class, %params) = @_;
     
@@ -37,6 +47,7 @@ sub new {
     $self->{no_controller} = $params{no_controller};
     $self->{no_plater} = $params{no_plater};
     $self->{loaded} = 0;
+    $self->{lang_ch_event} = $params{lang_ch_event};
     
     # initialize tabpanel and menubar
     $self->_init_tabpanel;
@@ -106,33 +117,41 @@ sub _init_tabpanel {
             $panel->AddPage($self->{controller} = Slic3r::GUI::Controller->new($panel), "Controller");
         }
     }
-    $self->{options_tabs} = {};
     
-    for my $tab_name (qw(print filament printer)) {
-        my $tab;
-        $tab = $self->{options_tabs}{$tab_name} = ("Slic3r::GUI::Tab::" . ucfirst $tab_name)->new(
-            $panel, 
-            no_controller => $self->{no_controller});
-        # Callback to be executed after any of the configuration fields (Perl class Slic3r::GUI::OptionsGroup::Field) change their value.
-        $tab->on_value_change(sub {
-            my ($opt_key, $value) = @_;
-            my $config = $tab->{presets}->get_current_preset->config;
-            if ($self->{plater}) {
-                $self->{plater}->on_config_change($config); # propagate config change events to the plater
-                $self->{plater}->on_extruders_change($value) if $opt_key eq 'extruders_count';
+    #TODO this is an example of a Slic3r XS interface call to add a new preset editor page to the main view.
+    # The following event is emited by the C++ Tab implementation on config value change.
+    EVT_COMMAND($self, -1, $VALUE_CHANGE_EVENT, sub {
+        my ($self, $event) = @_;
+        my $str = $event->GetString;
+        my ($opt_key, $name) = ($str =~ /(.*) (.*)/);
+        #print "VALUE_CHANGE_EVENT: ", $opt_key, "\n";
+        my $tab = Slic3r::GUI::get_preset_tab($name);
+        my $config = $tab->get_config;
+        if ($self->{plater}) {
+            $self->{plater}->on_config_change($config); # propagate config change events to the plater
+            if ($opt_key eq 'extruders_count'){
+                my $value = $event->GetInt();
+                $self->{plater}->on_extruders_change($value);
             }
-            # don't save while loading for the first time
-            $self->config->save($Slic3r::GUI::autosave) if $Slic3r::GUI::autosave && $self->{loaded};
-        });
-        # Install a callback for the tab to update the platter and print controller presets, when
-        # a preset changes at Slic3r::GUI::Tab.
-        $tab->on_presets_changed(sub {
-            if ($self->{plater}) {
-                # Update preset combo boxes (Print settings, Filament, Printer) from their respective tabs.
-                $self->{plater}->update_presets($tab_name, @_);
+        }
+        # don't save while loading for the first time
+        $self->config->save($Slic3r::GUI::autosave) if $Slic3r::GUI::autosave && $self->{loaded};        
+    });
+    # The following event is emited by the C++ Tab implementation on preset selection,
+    # or when the preset's "modified" status changes.
+    EVT_COMMAND($self, -1, $PRESETS_CHANGED_EVENT, sub {
+        my ($self, $event) = @_;
+        my $tab_name = $event->GetString;
+
+        my $tab = Slic3r::GUI::get_preset_tab($tab_name);
+        if ($self->{plater}) {
+            # Update preset combo boxes (Print settings, Filament, Printer) from their respective tabs.
+            my $presets = $tab->get_presets;
+            if (defined $presets){
+                my $reload_dependent_tabs = $tab->get_dependent_tabs;
+                $self->{plater}->update_presets($tab_name, $reload_dependent_tabs, $presets);
                 if ($tab_name eq 'printer') {
                     # Printer selected at the Printer tab, update "compatible" marks at the print and filament selectors.
-                    my ($presets, $reload_dependent_tabs) = @_;
                     for my $tab_name_other (qw(print filament)) {
                         # If the printer tells us that the print or filament preset has been switched or invalidated,
                         # refresh the print or filament tab page. Otherwise just refresh the combo box.
@@ -141,23 +160,76 @@ sub _init_tabpanel {
                         $self->{options_tabs}{$tab_name_other}->$update_action;
                     }
                     # Update the controller printers.
-                    $self->{controller}->update_presets(@_) if $self->{controller};
+                    $self->{controller}->update_presets($presets) if $self->{controller};
                 }
-                $self->{plater}->on_config_change($tab->{presets}->get_current_preset->config);
+                $self->{plater}->on_config_change($tab->get_config);
             }
-        });
-        # Load the currently selected preset into the GUI, update the preset selection box.
-        $tab->load_current_preset;
-        $panel->AddPage($tab, $tab->title);
-    }
+        }
+    });
+    # The following event is emited by the C++ Tab implementation ,
+    # when the Browse button was clicked
+    EVT_COMMAND($self, -1, $BUTTON_BROWSE_EVENT, sub {
+        my ($self, $event) = @_;
+        my $msg = $event->GetString;
+        print "BUTTON_BROWSE_EVENT: ", $msg, "\n";
 
-#TODO this is an example of a Slic3r XS interface call to add a new preset editor page to the main view.
-#    Slic3r::GUI::create_preset_tab("print");
+        # look for devices
+        my $entries;
+        {
+            my $res = Net::Bonjour->new('http');
+            $res->discover;
+            $entries = [ $res->entries ];
+        }
+        if (@{$entries}) {
+            my $dlg = Slic3r::GUI::BonjourBrowser->new($self, $entries);
+            my $tab = Slic3r::GUI::get_preset_tab("printer");
+            $tab->load_key_value('octoprint_host', $dlg->GetValue . ":" . $dlg->GetPort)
+                if $dlg->ShowModal == wxID_OK;
+        } else {
+            Wx::MessageDialog->new($self, 'No Bonjour device found', 'Device Browser', wxOK | wxICON_INFORMATION)->ShowModal;
+        }
+    });
+    # The following event is emited by the C++ Tab implementation ,
+    # when the Test button was clicked
+    EVT_COMMAND($self, -1, $BUTTON_TEST_EVENT, sub {
+        my ($self, $event) = @_;
+        my $msg = $event->GetString;
+        print "BUTTON_TEST_EVENT: ", $msg, "\n";
+
+        my $ua = LWP::UserAgent->new;
+        $ua->timeout(10);
+
+        my $config = Slic3r::GUI::get_preset_tab("printer")->get_config;
+        my $res = $ua->get(
+            "http://" . $config->octoprint_host . "/api/version",
+            'X-Api-Key' => $config->octoprint_apikey,
+        );
+        if ($res->is_success) {
+            Slic3r::GUI::show_info($self, "Connection to OctoPrint works correctly.", "Success!");
+        } else {
+            Slic3r::GUI::show_error($self,
+                "I wasn't able to connect to OctoPrint (" . $res->status_line . "). "
+                . "Check hostname and OctoPrint version (at least 1.1.0 is required).");
+        }
+    });
+    # A variable to inform C++ Tab implementation about disabling of Browse button
+    $self->{is_disabled_button_browse} = (!eval "use Net::Bonjour; 1") ? 1 : 0 ;
+    # A variable to inform C++ Tab implementation about user_agent
+    $self->{is_user_agent} = (eval "use LWP::UserAgent; 1") ? 1 : 0 ;    
+    Slic3r::GUI::create_preset_tabs(wxTheApp->{preset_bundle}, wxTheApp->{app_config}, 
+                                    $self->{no_controller}, $self->{is_disabled_button_browse},
+                                    $self->{is_user_agent},
+                                    $VALUE_CHANGE_EVENT, $PRESETS_CHANGED_EVENT,
+                                    $BUTTON_BROWSE_EVENT, $BUTTON_TEST_EVENT);
+    $self->{options_tabs} = {};
+    for my $tab_name (qw(print filament printer)) {
+        $self->{options_tabs}{$tab_name} = Slic3r::GUI::get_preset_tab("$tab_name");
+    }
     
     if ($self->{plater}) {
         $self->{plater}->on_select_preset(sub {
             my ($group, $name) = @_;
-	        $self->{options_tabs}{$group}->select_preset($name);
+            $self->{options_tabs}{$group}->select_preset($name);
         });
         # load initial config
         my $full_config = wxTheApp->{preset_bundle}->full_config;
@@ -244,6 +316,9 @@ sub _init_menubar {
         $self->_append_menu_item($self->{plater_menu}, "Export plate as AMF...", 'Export current plate as AMF', sub {
             $plater->export_amf;
         }, undef, 'brick_go.png');
+        $self->_append_menu_item($self->{plater_menu}, "Export plate as 3MF...", 'Export current plate as 3MF', sub {
+            $plater->export_3mf;
+        }, undef, 'brick_go.png');
         
         $self->{object_menu} = $self->{plater}->object_menu;
         $self->on_plater_selection_changed(0);
@@ -341,9 +416,11 @@ sub _init_menubar {
         $menubar->Append($self->{object_menu}, "&Object") if $self->{object_menu};
         $menubar->Append($windowMenu, "&Window");
         $menubar->Append($self->{viewMenu}, "&View") if $self->{viewMenu};
+        # Add an optional debug menu 
+        # (Select application language from the list of installed languages)
+        # In production code, the add_debug_menu() call should do nothing.
+        Slic3r::GUI::add_debug_menu($menubar, $self->{lang_ch_event});
         $menubar->Append($helpMenu, "&Help");
-        # Add an optional debug menu. In production code, the add_debug_menu() call should do nothing.
-        Slic3r::GUI::add_debug_menu($menubar);
         $self->SetMenuBar($menubar);
     }
 }
@@ -374,7 +451,7 @@ sub quick_slice {
         # select input file
         my $input_file;
         if (!$params{reslice}) {
-            my $dialog = Wx::FileDialog->new($self, 'Choose a file to slice (STL/OBJ/AMF/PRUSA):', 
+            my $dialog = Wx::FileDialog->new($self, 'Choose a file to slice (STL/OBJ/AMF/3MF/PRUSA):', 
                 wxTheApp->{app_config}->get_last_dir, "", 
                 &Slic3r::GUI::MODEL_WILDCARD, wxFD_OPEN | wxFD_FILE_MUST_EXIST);
             if ($dialog->ShowModal != wxID_OK) {
@@ -596,7 +673,7 @@ sub load_configbundle {
     wxTheApp->{app_config}->update_config_dir(dirname($file));
 
     my $presets_imported = 0;
-    eval { $presets_imported = wxTheApp->{preset_bundle}->load_configbundle($file, $reset_user_profile ? 1 : 0); };
+    eval { $presets_imported = wxTheApp->{preset_bundle}->load_configbundle($file); };
     Slic3r::GUI::catch_error($self) and return;
 
     # Load the currently selected preset into the GUI, update the preset selection box.
@@ -611,7 +688,7 @@ sub load_configbundle {
 # Load a provied DynamicConfig into the Print / Filament / Printer tabs, thus modifying the active preset.
 # Also update the platter with the new presets.
 sub load_config {
-    my ($self, $config) = @_;    
+    my ($self, $config) = @_;
     $_->load_config($config) foreach values %{$self->{options_tabs}};
     $self->{plater}->on_config_change($config) if $self->{plater};
 }
@@ -661,7 +738,7 @@ sub check_unsaved_changes {
     
     my @dirty = ();
     foreach my $tab (values %{$self->{options_tabs}}) {
-        push @dirty, $tab->title if $tab->{presets}->current_is_dirty;
+        push @dirty, $tab->title if $tab->current_preset_is_dirty;
     }
     
     if (@dirty) {
diff --git a/lib/Slic3r/GUI/OptionsGroup.pm b/lib/Slic3r/GUI/OptionsGroup.pm
index 7ffb2067b..962e6ffc0 100644
--- a/lib/Slic3r/GUI/OptionsGroup.pm
+++ b/lib/Slic3r/GUI/OptionsGroup.pm
@@ -158,7 +158,9 @@ sub _build_field {
     
     my $opt_id = $opt->opt_id;
     my $on_change = sub {
+        #! This function will be called from Field.
         my ($opt_id, $value) = @_;
+        #! Call OptionGroup._on_change(...)
         $self->_on_change($opt_id, $value)
             unless $self->_disabled;
     };
@@ -213,6 +215,8 @@ sub _build_field {
     }
     return undef if !$field;
     
+    #! setting up a function that will be triggered when the field changes
+    #! think of it as $field->on_change = ($on_change)
     $field->on_change($on_change);
     $field->on_kill_focus($on_kill_focus);
     $self->_fields->{$opt_id} = $field;
diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm
index da2d12aa0..3328c689b 100644
--- a/lib/Slic3r/GUI/Plater.pm
+++ b/lib/Slic3r/GUI/Plater.pm
@@ -60,10 +60,14 @@ sub new {
     $self->{print} = Slic3r::Print->new;
     # List of Perl objects Slic3r::GUI::Plater::Object, representing a 2D preview of the platter.
     $self->{objects} = [];
+    $self->{gcode_preview_data} = Slic3r::GCode::PreviewData->new;
     
     $self->{print}->set_status_cb(sub {
         my ($percent, $message) = @_;
-        Wx::PostEvent($self, Wx::PlThreadEvent->new(-1, $PROGRESS_BAR_EVENT, shared_clone([$percent, $message])));
+        my $event = Wx::CommandEvent->new($PROGRESS_BAR_EVENT);
+        $event->SetString($message);
+        $event->SetInt($percent);
+        Wx::PostEvent($self, $event);
     });
     
     # Initialize preview notebook
@@ -137,7 +141,7 @@ sub new {
     
     # Initialize 3D toolpaths preview
     if ($Slic3r::GUI::have_OpenGL) {
-        $self->{preview3D} = Slic3r::GUI::Plater::3DPreview->new($self->{preview_notebook}, $self->{print}, $self->{config});
+        $self->{preview3D} = Slic3r::GUI::Plater::3DPreview->new($self->{preview_notebook}, $self->{print}, $self->{gcode_preview_data}, $self->{config});
         $self->{preview3D}->canvas->on_viewport_changed(sub {
             $self->{canvas3D}->set_viewport_from_scene($self->{preview3D}->canvas);
         });
@@ -153,8 +157,15 @@ sub new {
     
     EVT_NOTEBOOK_PAGE_CHANGED($self, $self->{preview_notebook}, sub {
         my $preview = $self->{preview_notebook}->GetCurrentPage;
-        $self->{preview3D}->load_print(1) if ($preview == $self->{preview3D});
-        $preview->OnActivate if $preview->can('OnActivate');
+        if ($preview == $self->{preview3D})
+        {
+            $self->{preview3D}->canvas->set_legend_enabled(1);
+            $self->{preview3D}->load_print(1);
+        } else {
+            $self->{preview3D}->canvas->set_legend_enabled(0);
+        }
+
+        $preview->OnActivate if $preview->can('OnActivate');        
     });
     
     # toolbar for object manipulation
@@ -307,23 +318,22 @@ sub new {
     
     EVT_COMMAND($self, -1, $PROGRESS_BAR_EVENT, sub {
         my ($self, $event) = @_;
-        my ($percent, $message) = @{$event->GetData};
-        $self->on_progress_event($percent, $message);
+        $self->on_progress_event($event->GetInt, $event->GetString);
     });
     
     EVT_COMMAND($self, -1, $ERROR_EVENT, sub {
         my ($self, $event) = @_;
-        Slic3r::GUI::show_error($self, @{$event->GetData});
+        Slic3r::GUI::show_error($self, $event->GetString);
     });
     
     EVT_COMMAND($self, -1, $EXPORT_COMPLETED_EVENT, sub {
         my ($self, $event) = @_;
-        $self->on_export_completed($event->GetData);
+        $self->on_export_completed($event->GetInt);
     });
     
     EVT_COMMAND($self, -1, $PROCESS_COMPLETED_EVENT, sub {
         my ($self, $event) = @_;
-        $self->on_process_completed($event->GetData);
+        $self->on_process_completed($event->GetInt ? undef : $event->GetString);
     });
     
     {
@@ -365,7 +375,9 @@ sub new {
                 my $text = Wx::StaticText->new($self, -1, "$group_labels{$group}:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
                 $text->SetFont($Slic3r::GUI::small_font);
                 my $choice = Wx::BitmapComboBox->new($self, -1, "", wxDefaultPosition, wxDefaultSize, [], wxCB_READONLY);
-                EVT_LEFT_DOWN($choice, sub { $self->filament_color_box_lmouse_down(0, @_); } );
+                if ($group eq 'filament') {
+                    EVT_LEFT_DOWN($choice, sub { $self->filament_color_box_lmouse_down(0, @_); } );
+                }
                 $self->{preset_choosers}{$group} = [$choice];
                 # setup the listener
                 EVT_COMBOBOX($choice, $choice, sub {
@@ -431,9 +443,10 @@ sub new {
             $print_info_sizer->Add($grid_sizer, 0, wxEXPAND);
             my @info = (
                 fil_m   => "Used Filament (m)",
-                fil_mm3 => "Used Filament (mm^3)",
+                fil_mm3 => "Used Filament (mm\x{00B3})",
                 fil_g   => "Used Filament (g)",
                 cost    => "Cost",
+                time    => "Estimated printing time",
             );
             while (my $field = shift @info) {
                 my $label = shift @info;
@@ -609,7 +622,7 @@ sub load_files {
     # One of the files is potentionally a bundle of files. Don't bundle them, but load them one by one.
     # Only bundle .stls or .objs if the printer has multiple extruders.
     my $one_by_one = (@$nozzle_dmrs <= 1) || (@$input_files == 1) || 
-        defined(first { $_ =~ /.[aA][mM][fF]$/ || $_ =~ /.3[mM][fF]$/ || $_ =~ /.[pP][rR][uI][sS][aA]$/ } @$input_files);
+       defined(first { $_ =~ /.[aA][mM][fF]$/ || $_ =~ /.[aA][mM][fF].[xX][mM][lL]$/ || $_ =~ /.[zZ][iI][pP].[aA][mM][fF]$/ || $_ =~ /.3[mM][fF]$/ || $_ =~ /.[pP][rR][uI][sS][aA]$/ } @$input_files);
         
     my $process_dialog = Wx::ProgressDialog->new('Loading…', "Processing input file\n" . basename($input_files->[0]), 100, $self, 0);
     $process_dialog->Pulse;
@@ -627,8 +640,19 @@ sub load_files {
         my $input_file = $input_files->[$i];
         $process_dialog->Update(100. * $i / @$input_files, "Processing input file\n" . basename($input_file));
 
-        my $model = eval { Slic3r::Model->read_from_file($input_file, 0) };
-        Slic3r::GUI::show_error($self, $@) if $@;
+        my $model;
+        if (($input_file =~ /.3[mM][fF]$/) || ($input_file =~ /.[zZ][iI][pP].[aA][mM][fF]$/))
+        {
+            $model = eval { Slic3r::Model->read_from_archive($input_file, wxTheApp->{preset_bundle}, 0) };
+            Slic3r::GUI::show_error($self, $@) if $@;
+            $_->load_current_preset for (values %{$self->GetFrame->{options_tabs}});
+            wxTheApp->{app_config}->update_config_dir(dirname($input_file));
+        }
+        else
+        {
+            $model = eval { Slic3r::Model->read_from_file($input_file, 0) };
+            Slic3r::GUI::show_error($self, $@) if $@;
+        }
 
         next if ! defined $model;
         
@@ -1148,6 +1172,7 @@ sub async_apply_config {
     # Reset preview canvases. If the print has been invalidated, the preview canvases will be cleared.
     # Otherwise they will be just refreshed.
     if ($invalidated) {
+        $self->{gcode_preview_data}->reset;
         $self->{toolpaths2D}->reload_print if $self->{toolpaths2D};
         $self->{preview3D}->reload_print if $self->{preview3D};
     }
@@ -1183,12 +1208,15 @@ sub start_background_process {
         eval {
             $self->{print}->process;
         };
+        my $event = Wx::CommandEvent->new($PROCESS_COMPLETED_EVENT);
         if ($@) {
             Slic3r::debugf "Background process error: $@\n";
-            Wx::PostEvent($self, Wx::PlThreadEvent->new(-1, $PROCESS_COMPLETED_EVENT, $@));
+            $event->SetInt(0);
+            $event->SetString($@);
         } else {
-            Wx::PostEvent($self, Wx::PlThreadEvent->new(-1, $PROCESS_COMPLETED_EVENT, undef));
+            $event->SetInt(1);
         }
+        Wx::PostEvent($self, $event);
         Slic3r::thread_cleanup();
     });
     Slic3r::debugf "Background processing started.\n";
@@ -1364,14 +1392,21 @@ sub on_process_completed {
         
         $self->{export_thread} = Slic3r::spawn_thread(sub {
             eval {
-                $_thread_self->{print}->export_gcode(output_file => $_thread_self->{export_gcode_output_file});
+                $_thread_self->{print}->export_gcode(output_file => $_thread_self->{export_gcode_output_file}, gcode_preview_data => $_thread_self->{gcode_preview_data});
             };
+            my $export_completed_event = Wx::CommandEvent->new($EXPORT_COMPLETED_EVENT);
             if ($@) {
-                Wx::PostEvent($_thread_self, Wx::PlThreadEvent->new(-1, $ERROR_EVENT, shared_clone([ $@ ])));
-                Wx::PostEvent($_thread_self, Wx::PlThreadEvent->new(-1, $EXPORT_COMPLETED_EVENT, 0));
+                {
+                    my $error_event = Wx::CommandEvent->new($ERROR_EVENT);
+                    $error_event->SetString($@);
+                    Wx::PostEvent($_thread_self, $error_event);
+                }
+                $export_completed_event->SetInt(0);
+                $export_completed_event->SetString($@);
             } else {
-                Wx::PostEvent($_thread_self, Wx::PlThreadEvent->new(-1, $EXPORT_COMPLETED_EVENT, 1));
+                $export_completed_event->SetInt(1);
             }
+            Wx::PostEvent($_thread_self, $export_completed_event);
             Slic3r::thread_cleanup();
         });
         Slic3r::debugf "Background G-code export started.\n";
@@ -1428,11 +1463,16 @@ sub on_export_completed {
     $self->{"print_info_cost"}->SetLabel(sprintf("%.2f" , $self->{print}->total_cost));
     $self->{"print_info_fil_g"}->SetLabel(sprintf("%.2f" , $self->{print}->total_weight));
     $self->{"print_info_fil_mm3"}->SetLabel(sprintf("%.2f" , $self->{print}->total_extruded_volume));
+    $self->{"print_info_time"}->SetLabel($self->{print}->estimated_print_time);
     $self->{"print_info_fil_m"}->SetLabel(sprintf("%.2f" , $self->{print}->total_used_filament / 1000));
     $self->{"print_info_box_show"}->(1);
 
     # this updates buttons status
     $self->object_list_changed;
+    
+    # refresh preview
+    $self->{toolpaths2D}->reload_print if $self->{toolpaths2D};
+    $self->{preview3D}->reload_print if $self->{preview3D};
 }
 
 sub do_print {
@@ -1460,15 +1500,19 @@ sub send_gcode {
     my $ua = LWP::UserAgent->new;
     $ua->timeout(180);
     
-    my $enc_path = Slic3r::encode_path($self->{send_gcode_file});
     my $res = $ua->post(
         "http://" . $self->{config}->octoprint_host . "/api/files/local",
         Content_Type => 'form-data',
         'X-Api-Key' => $self->{config}->octoprint_apikey,
         Content => [
-            # OctoPrint doesn't like Windows paths so we use basename()
-            # Also, since we need to read from filesystem we process it through encode_path()
-            file => [ $enc_path, basename($enc_path) ],
+            file => [ 
+                # On Windows, the path has to be encoded in local code page for perl to be able to open it.
+                Slic3r::encode_path($self->{send_gcode_file}),
+                # Remove the UTF-8 flag from the perl string, so the LWP::UserAgent can insert 
+                # the UTF-8 encoded string into the request as a byte stream.
+                Slic3r::path_to_filename_raw($self->{send_gcode_file})
+            ],
+            print => $self->{send_gcode_file_print} ? 1 : 0,
         ],
     );
     
@@ -1540,15 +1584,50 @@ sub export_amf {
     return if !@{$self->{objects}};
     # Ask user for a file name to write into.
     my $output_file = $self->_get_export_file('AMF') or return;
-    $self->{model}->store_amf($output_file);
-    $self->statusbar->SetStatusText("AMF file exported to $output_file");
+    my $res = $self->{model}->store_amf($output_file, $self->{print});
+    if ($res)
+    {
+        $self->statusbar->SetStatusText("AMF file exported to $output_file");
+    }
+    else
+    {
+        $self->statusbar->SetStatusText("Error exporting AMF file $output_file");
+    }
+}
+
+sub export_3mf {
+    my ($self) = @_;
+    return if !@{$self->{objects}};
+    # Ask user for a file name to write into.
+    my $output_file = $self->_get_export_file('3MF') or return;
+    my $res = $self->{model}->store_3mf($output_file, $self->{print});
+    if ($res)
+    {
+        $self->statusbar->SetStatusText("3MF file exported to $output_file");
+    }
+    else
+    {
+        $self->statusbar->SetStatusText("Error exporting 3MF file $output_file");
+    }
 }
 
 # Ask user to select an output file for a given file format (STl, AMF, 3MF).
 # Propose a default file name based on the 'output_filename_format' configuration value.
 sub _get_export_file {
     my ($self, $format) = @_;    
-    my $suffix = $format eq 'STL' ? '.stl' : '.amf.xml';
+    my $suffix = '';
+    if ($format eq 'STL')
+    {
+        $suffix = '.stl';
+    }
+    elsif ($format eq 'AMF')
+    {
+        $suffix = '.zip.amf';
+    }
+    elsif ($format eq '3MF')
+    {
+        $suffix = '.3mf';
+    }
     my $output_file = eval { $self->{print}->output_filepath($main::opt{output} // '') };
     Slic3r::GUI::catch_error($self) and return undef;
     $output_file =~ s/\.[gG][cC][oO][dD][eE]$/$suffix/;
@@ -2057,8 +2136,8 @@ sub OnDropFiles {
     # stop scalars leaking on older perl
     # https://rt.perl.org/rt3/Public/Bug/Display.html?id=70602
     @_ = ();
-    # only accept STL, OBJ and AMF files
-    return 0 if grep !/\.(?:[sS][tT][lL]|[oO][bB][jJ]|[aA][mM][fF](?:\.[xX][mM][lL])?|[pP][rR][uU][sS][aA])$/, @$filenames;
+    # only accept STL, OBJ, AMF, 3MF and PRUSA files
+    return 0 if grep !/\.(?:[sS][tT][lL]|[oO][bB][jJ]|[aA][mM][fF]|[3][mM][fF]|[aA][mM][fF].[xX][mM][lL]|[zZ][iI][pP].[aA][mM][lL]|[pP][rR][uU][sS][aA])$/, @$filenames;
     $self->{window}->load_files($filenames);
 }
 
diff --git a/lib/Slic3r/GUI/Plater/3DPreview.pm b/lib/Slic3r/GUI/Plater/3DPreview.pm
index c7d4cc4a8..554b9e35a 100644
--- a/lib/Slic3r/GUI/Plater/3DPreview.pm
+++ b/lib/Slic3r/GUI/Plater/3DPreview.pm
@@ -4,20 +4,22 @@ use warnings;
 use utf8;
 
 use Slic3r::Print::State ':steps';
-use Wx qw(:misc :sizer :slider :statictext :keycode wxWHITE);
-use Wx::Event qw(EVT_SLIDER EVT_KEY_DOWN EVT_CHECKBOX);
+use Wx qw(:misc :sizer :slider :statictext :keycode wxWHITE wxCB_READONLY);
+use Wx::Event qw(EVT_SLIDER EVT_KEY_DOWN EVT_CHECKBOX EVT_CHOICE EVT_CHECKLISTBOX);
 use base qw(Wx::Panel Class::Accessor);
 
-__PACKAGE__->mk_accessors(qw(print enabled _loaded canvas slider_low slider_high single_layer));
+__PACKAGE__->mk_accessors(qw(print gcode_preview_data enabled _loaded canvas slider_low slider_high single_layer auto_zoom));
 
 sub new {
     my $class = shift;
-    my ($parent, $print, $config) = @_;
+    my ($parent, $print, $gcode_preview_data, $config) = @_;
     
     my $self = $class->SUPER::new($parent, -1, wxDefaultPosition);
     $self->{config} = $config;
     $self->{number_extruders} = 1;
+    # Show by feature type by default.
     $self->{preferred_color_mode} = 'feature';
+    $self->auto_zoom(1);
 
     # init GUI elements
     my $canvas = Slic3r::GUI::3DScene->new($self);
@@ -56,10 +58,35 @@ sub new {
     $z_label_high->SetFont($Slic3r::GUI::small_font);
 
     $self->single_layer(0);
-    $self->{color_by_extruder} = 0;
     my $checkbox_singlelayer = $self->{checkbox_singlelayer} = Wx::CheckBox->new($self, -1, "1 Layer");
-    my $checkbox_color_by_extruder = $self->{checkbox_color_by_extruder} = Wx::CheckBox->new($self, -1, "Tool");
     
+    my $label_view_type = $self->{label_view_type} = Wx::StaticText->new($self, -1, "View");
+    
+    my $choice_view_type = $self->{choice_view_type} = Wx::Choice->new($self, -1);
+    $choice_view_type->Append("Feature type");
+    $choice_view_type->Append("Height");
+    $choice_view_type->Append("Width");
+    $choice_view_type->Append("Speed");
+    $choice_view_type->Append("Tool");
+    $choice_view_type->SetSelection(0);
+
+    my $label_show_features = $self->{label_show_features} = Wx::StaticText->new($self, -1, "Show");
+    
+    my $combochecklist_features = $self->{combochecklist_features} = Wx::ComboCtrl->new();
+    $combochecklist_features->Create($self, -1, "Feature types", wxDefaultPosition, [200, -1], wxCB_READONLY);
+    #FIXME If the following line is removed, the combo box popup list will not react to mouse clicks.
+    # On the other side, with this line the combo box popup cannot be closed by clicking on the combo button on Windows 10.
+    $combochecklist_features->UseAltPopupWindow();
+    $combochecklist_features->EnablePopupAnimation(0);
+    my $feature_text = "Feature types";
+    my $feature_items = "Perimeter|External perimeter|Overhang perimeter|Internal infill|Solid infill|Top solid infill|Bridge infill|Gap fill|Skirt|Support material|Support material interface|Wipe tower";
+    Slic3r::GUI::create_combochecklist($combochecklist_features, $feature_text, $feature_items, 1);
+    
+    my $checkbox_travel         = $self->{checkbox_travel}          = Wx::CheckBox->new($self, -1, "Travel");
+    my $checkbox_retractions    = $self->{checkbox_retractions}     = Wx::CheckBox->new($self, -1, "Retractions");    
+    my $checkbox_unretractions  = $self->{checkbox_unretractions}   = Wx::CheckBox->new($self, -1, "Unretractions");
+    my $checkbox_shells         = $self->{checkbox_shells}          = Wx::CheckBox->new($self, -1, "Shells");
+
     my $hsizer = Wx::BoxSizer->new(wxHORIZONTAL);
     my $vsizer = Wx::BoxSizer->new(wxVERTICAL);
     my $vsizer_outer = Wx::BoxSizer->new(wxVERTICAL);
@@ -72,11 +99,29 @@ sub new {
     $hsizer->Add($vsizer, 0, wxEXPAND, 0);
     $vsizer_outer->Add($hsizer, 3, wxALIGN_CENTER_HORIZONTAL, 0);
     $vsizer_outer->Add($checkbox_singlelayer, 0, wxTOP | wxALIGN_CENTER_HORIZONTAL, 5);
-    $vsizer_outer->Add($checkbox_color_by_extruder, 0, wxTOP | wxALIGN_CENTER_HORIZONTAL, 5);
 
+    my $bottom_sizer = Wx::BoxSizer->new(wxHORIZONTAL);
+    $bottom_sizer->Add($label_view_type, 0, wxALIGN_CENTER_VERTICAL, 5);
+    $bottom_sizer->Add($choice_view_type, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, 5);
+    $bottom_sizer->AddSpacer(10);
+    $bottom_sizer->Add($label_show_features, 0, wxALIGN_CENTER_VERTICAL, 5);
+    $bottom_sizer->Add($combochecklist_features, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, 5);
+    $bottom_sizer->AddSpacer(20);
+    $bottom_sizer->Add($checkbox_travel, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, 5);
+    $bottom_sizer->AddSpacer(10);
+    $bottom_sizer->Add($checkbox_retractions, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, 5);
+    $bottom_sizer->AddSpacer(10);
+    $bottom_sizer->Add($checkbox_unretractions, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, 5);
+    $bottom_sizer->AddSpacer(10);
+    $bottom_sizer->Add($checkbox_shells, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, 5);
+    
     my $sizer = Wx::BoxSizer->new(wxHORIZONTAL);
     $sizer->Add($canvas, 1, wxALL | wxEXPAND, 0);
     $sizer->Add($vsizer_outer, 0, wxTOP | wxBOTTOM | wxEXPAND, 5);
+
+    my $main_sizer = Wx::BoxSizer->new(wxVERTICAL);
+    $main_sizer->Add($sizer, 1, wxALL | wxEXPAND, 0);
+    $main_sizer->Add($bottom_sizer, 0, wxALL | wxEXPAND, 0); 
     
     EVT_SLIDER($self, $slider_low,  sub {
         $slider_high->SetValue($slider_low->GetValue) if $self->single_layer;
@@ -147,18 +192,73 @@ sub new {
             $self->set_z_idx_high($slider_high->GetValue);
         }
     });
-    EVT_CHECKBOX($self, $checkbox_color_by_extruder, sub {
-        $self->{color_by_extruder} = $checkbox_color_by_extruder->GetValue();
-        $self->{preferred_color_mode} = $self->{color_by_extruder} ? 'tool' : 'feature';
+    EVT_CHOICE($self, $choice_view_type, sub {
+        my $selection = $choice_view_type->GetCurrentSelection();
+        $self->{preferred_color_mode} = ($selection == 4) ? 'tool' : 'feature';
+        $self->gcode_preview_data->set_type($selection);
+        $self->auto_zoom(0);
         $self->reload_print;
+        $self->auto_zoom(1);
+    });
+    EVT_CHECKLISTBOX($self, $combochecklist_features, sub {
+        my $flags = Slic3r::GUI::combochecklist_get_flags($combochecklist_features);
+        
+        $self->gcode_preview_data->set_extrusion_flags($flags);
+        $self->auto_zoom(0);
+        $self->refresh_print;
+        $self->auto_zoom(1);
+    });    
+    EVT_CHECKBOX($self, $checkbox_travel, sub {
+        $self->gcode_preview_data->set_travel_visible($checkbox_travel->IsChecked());
+        $self->auto_zoom(0);
+        $self->refresh_print;
+        $self->auto_zoom(1);
+    });    
+    EVT_CHECKBOX($self, $checkbox_retractions, sub {
+        $self->gcode_preview_data->set_retractions_visible($checkbox_retractions->IsChecked());
+        $self->auto_zoom(0);
+        $self->refresh_print;
+        $self->auto_zoom(1);
+    });
+    EVT_CHECKBOX($self, $checkbox_unretractions, sub {
+        $self->gcode_preview_data->set_unretractions_visible($checkbox_unretractions->IsChecked());
+        $self->auto_zoom(0);
+        $self->refresh_print;
+        $self->auto_zoom(1);
+    });
+    EVT_CHECKBOX($self, $checkbox_shells, sub {
+        $self->gcode_preview_data->set_shells_visible($checkbox_shells->IsChecked());
+        $self->auto_zoom(0);
+        $self->refresh_print;
+        $self->auto_zoom(1);
     });
     
-    $self->SetSizer($sizer);
+    $self->SetSizer($main_sizer);
     $self->SetMinSize($self->GetSize);
     $sizer->SetSizeHints($self);
     
     # init canvas
     $self->print($print);
+    $self->gcode_preview_data($gcode_preview_data);
+    
+    # sets colors for gcode preview extrusion roles
+    my @extrusion_roles_colors = (
+                                    'Perimeter'                  => 'FFA500',
+                                    'External perimeter'         => 'FFFF66',
+                                    'Overhang perimeter'         => '0000FF',
+                                    'Internal infill'            => 'FF0000',
+                                    'Solid infill'               => 'CD00CD',
+                                    'Top solid infill'           => 'FF3333',
+                                    'Bridge infill'              => '9999FF',
+                                    'Gap fill'                   => 'FFFFFF',
+                                    'Skirt'                      => '7F0000',
+                                    'Support material'           => '00FF00',
+                                    'Support material interface' => '008000',
+                                    'Wipe tower'                 => 'B3E3AB',
+                                 );
+    $self->gcode_preview_data->set_extrusion_paths_colors(\@extrusion_roles_colors);
+    
+    $self->show_hide_ui_elements('none');
     $self->reload_print;
     
     return $self;
@@ -171,7 +271,19 @@ sub reload_print {
     $self->_loaded(0);
 
     if (! $self->IsShown && ! $force) {
-        $self->{reload_delayed} = 1;
+#        $self->{reload_delayed} = 1;
+        return;
+    }
+
+    $self->load_print;
+}
+
+sub refresh_print {
+    my ($self) = @_;
+
+    $self->_loaded(0);
+    
+    if (! $self->IsShown) {
         return;
     }
 
@@ -203,6 +315,9 @@ sub load_print {
         $self->set_z_range(0,0);
         $self->slider_low->Hide;
         $self->slider_high->Hide;
+        $self->{z_label_low}->SetLabel("");
+        $self->{z_label_high}->SetLabel("");
+        $self->canvas->reset_legend_texture();
         $self->canvas->Refresh;  # clears canvas
         return;
     }
@@ -232,21 +347,20 @@ sub load_print {
     $self->slider_high->Show;
     $self->Layout;
 
-    my $by_tool = $self->{color_by_extruder};
     if ($self->{preferred_color_mode} eq 'tool_or_feature') {
         # It is left to Slic3r to decide whether the print shall be colored by the tool or by the feature.
         # Color by feature if it is a single extruder print.
         my $extruders = $self->{print}->extruders;
-        $by_tool = scalar(@{$extruders}) > 1;
-        $self->{color_by_extruder} = $by_tool;
-        $self->{checkbox_color_by_extruder}->SetValue($by_tool);
+        my $type = (scalar(@{$extruders}) > 1) ? 4 : 0;
+        $self->gcode_preview_data->set_type($type);
+        $self->{choice_view_type}->SetSelection($type);
+        # If the ->SetSelection changed the following line, revert it to "decide yourself".
         $self->{preferred_color_mode} = 'tool_or_feature';
     }
 
     # Collect colors per extruder.
-    # Leave it empty, if the print should be colored by a feature.
     my @colors = ();
-    if ($by_tool) {
+    if (! $self->gcode_preview_data->empty() || $self->gcode_preview_data->type == 4) {
         my @extruder_colors = @{$self->{config}->extruder_colour};
         my @filament_colors = @{$self->{config}->filament_colour};
         for (my $i = 0; $i <= $#extruder_colors; $i += 1) {
@@ -258,18 +372,24 @@ sub load_print {
     }
 
     if ($self->IsShown) {
-        # load skirt and brim
-        $self->canvas->load_print_toolpaths($self->print, \@colors);
-        $self->canvas->load_wipe_tower_toolpaths($self->print, \@colors);
-        
-        foreach my $object (@{$self->print->objects}) {
-            $self->canvas->load_print_object_toolpaths($object, \@colors);
-            
-            # Show the objects in very transparent color.
-            #my @volume_ids = $self->canvas->load_object($object->model_object);
-            #$self->canvas->volumes->[$_]->color->[3] = 0.2 for @volume_ids;
+        if ($self->gcode_preview_data->empty) {
+            # load skirt and brim
+            $self->canvas->load_print_toolpaths($self->print, \@colors);
+            $self->canvas->load_wipe_tower_toolpaths($self->print, \@colors);        
+            foreach my $object (@{$self->print->objects}) {
+                $self->canvas->load_print_object_toolpaths($object, \@colors);            
+                # Show the objects in very transparent color.
+                #my @volume_ids = $self->canvas->load_object($object->model_object);
+                #$self->canvas->volumes->[$_]->color->[3] = 0.2 for @volume_ids;
+            }
+            $self->show_hide_ui_elements('simple');
+        } else {
+            $self->canvas->load_gcode_preview($self->print, $self->gcode_preview_data, \@colors);
+            $self->show_hide_ui_elements('full');
+        }
+        if ($self->auto_zoom) {
+            $self->canvas->zoom_to_volumes;
         }
-        $self->canvas->zoom_to_volumes;
         $self->_loaded(1);
     }
     
@@ -322,17 +442,27 @@ sub set_number_extruders {
     my ($self, $number_extruders) = @_;
     if ($self->{number_extruders} != $number_extruders) {
         $self->{number_extruders} = $number_extruders;
-        my $by_tool = $number_extruders > 1;
-        $self->{color_by_extruder} = $by_tool;
-        $self->{checkbox_color_by_extruder}->SetValue($by_tool);
-        $self->{preferred_color_mode} = $by_tool ? 'tool_or_feature' : 'feature';
+        my $type = ($number_extruders > 1) ?
+              4  # color by a tool number
+            : 0; # color by a feature type
+        $self->{choice_view_type}->SetSelection($type);
+        $self->gcode_preview_data->set_type($type);
+        $self->{preferred_color_mode} = ($type == 4) ? 'tool_or_feature' : 'feature';
     }
 }
 
+sub show_hide_ui_elements {
+    my ($self, $what) = @_;
+    my $method = ($what eq 'full') ? 'Enable' : 'Disable';
+    $self->{$_}->$method for qw(label_show_features combochecklist_features checkbox_travel checkbox_retractions checkbox_unretractions checkbox_shells);
+    $method = ($what eq 'none') ? 'Disable' : 'Enable';
+    $self->{$_}->$method for qw(label_view_type choice_view_type);
+}
+
 # Called by the Platter wxNotebook when this page is activated.
 sub OnActivate {
-    my ($self) = @_;
-    $self->reload_print(1) if ($self->{reload_delayed});
+#    my ($self) = @_;
+#    $self->reload_print(1) if ($self->{reload_delayed});
 }
 
 1;
diff --git a/lib/Slic3r/GUI/Plater/3DToolpaths.pm b/lib/Slic3r/GUI/Plater/3DToolpaths.pm
deleted file mode 100644
index fb904b0fd..000000000
--- a/lib/Slic3r/GUI/Plater/3DToolpaths.pm
+++ /dev/null
@@ -1,156 +0,0 @@
-package Slic3r::GUI::Plater::3DToolpaths;
-use strict;
-use warnings;
-use utf8;
-
-use Slic3r::Print::State ':steps';
-use Wx qw(:misc :sizer :slider :statictext wxWHITE);
-use Wx::Event qw(EVT_SLIDER EVT_KEY_DOWN);
-use base qw(Wx::Panel Class::Accessor);
-
-__PACKAGE__->mk_accessors(qw(print enabled _loaded canvas slider));
-
-sub new {
-    my $class = shift;
-    my ($parent, $print) = @_;
-    
-    my $self = $class->SUPER::new($parent, -1, wxDefaultPosition);
-    
-    # init GUI elements
-    my $canvas = Slic3r::GUI::3DScene->new($self);
-    $self->canvas($canvas);
-    my $slider = Wx::Slider->new(
-        $self, -1,
-        0,                              # default
-        0,                              # min
-        # we set max to a bogus non-zero value because the MSW implementation of wxSlider
-        # will skip drawing the slider if max <= min:
-        1,                              # max
-        wxDefaultPosition,
-        wxDefaultSize,
-        wxVERTICAL | wxSL_INVERSE,
-    );
-    $self->slider($slider);
-    
-    my $z_label = $self->{z_label} = Wx::StaticText->new($self, -1, "", wxDefaultPosition,
-        [40,-1], wxALIGN_CENTRE_HORIZONTAL);
-    $z_label->SetFont($Slic3r::GUI::small_font);
-    
-    my $vsizer = Wx::BoxSizer->new(wxVERTICAL);
-    $vsizer->Add($slider, 1, wxALL | wxEXPAND | wxALIGN_CENTER, 3);
-    $vsizer->Add($z_label, 0, wxALL | wxEXPAND | wxALIGN_CENTER, 3);
-    
-    my $sizer = Wx::BoxSizer->new(wxHORIZONTAL);
-    $sizer->Add($canvas, 1, wxALL | wxEXPAND, 0);
-    $sizer->Add($vsizer, 0, wxTOP | wxBOTTOM | wxEXPAND, 5);
-    
-    EVT_SLIDER($self, $slider, sub {
-        $self->set_z($self->{layers_z}[$slider->GetValue])
-            if $self->enabled;
-    });
-    EVT_KEY_DOWN($canvas, sub {
-        my ($s, $event) = @_;
-        if ($event->HasModifiers) {
-            $event->Skip;
-        } else {
-            my $key = $event->GetKeyCode;
-            if ($key == 85 || $key == 315) {
-                $slider->SetValue($slider->GetValue + 1);
-                $self->set_z($self->{layers_z}[$slider->GetValue]);
-            } elsif ($key == 68 || $key == 317) {
-                $slider->SetValue($slider->GetValue - 1);
-                $self->set_z($self->{layers_z}[$slider->GetValue]);
-            } else {
-                $event->Skip;
-            }
-        }
-    });
-    
-    $self->SetSizer($sizer);
-    $self->SetMinSize($self->GetSize);
-    $sizer->SetSizeHints($self);
-    
-    # init canvas
-    $self->print($print);
-    $self->reload_print;
-    
-    return $self;
-}
-
-sub reload_print {
-    my ($self) = @_;
-    
-    $self->canvas->reset_objects;
-    $self->_loaded(0);
-    $self->load_print;
-}
-
-sub load_print {
-    my ($self) = @_;
-    
-    return if $self->_loaded;
-    
-    # we require that there's at least one object and the posSlice step
-    # is performed on all of them (this ensures that _shifted_copies was
-    # populated and we know the number of layers)
-    if (!$self->print->object_step_done(STEP_SLICE)) {
-        $self->enabled(0);
-        $self->slider->Hide;
-        $self->canvas->Refresh;  # clears canvas
-        return;
-    }
-    
-    my $z_idx;
-    {
-        my %z = ();  # z => 1
-        foreach my $object (@{$self->{print}->objects}) {
-            foreach my $layer (@{$object->layers}, @{$object->support_layers}) {
-                $z{$layer->print_z} = 1;
-            }
-        }
-        $self->enabled(1);
-        $self->{layers_z} = [ sort { $a <=> $b } keys %z ];
-        $self->slider->SetRange(0, scalar(@{$self->{layers_z}})-1);
-        if (($z_idx = $self->slider->GetValue) <= $#{$self->{layers_z}} && $self->slider->GetValue != 0) {
-            # use $z_idx
-        } else {
-            $self->slider->SetValue(scalar(@{$self->{layers_z}})-1);
-            $z_idx = @{$self->{layers_z}} ? -1 : undef;
-        }
-        $self->slider->Show;
-        $self->Layout;
-    }
-    
-    if ($self->IsShown) {
-        # load skirt and brim
-        $self->canvas->load_print_toolpaths($self->print);
-        
-        foreach my $object (@{$self->print->objects}) {
-            $self->canvas->load_print_object_toolpaths($object);
-            
-            # Show the objects in very transparent color.
-            #my @volume_ids = $self->canvas->load_object($object->model_object);
-            #$self->canvas->volumes->[$_]->color->[3] = 0.2 for @volume_ids;
-        }
-        $self->canvas->zoom_to_volumes;
-        $self->_loaded(1);
-    }
-    
-    $self->set_z($self->{layers_z}[$z_idx]);
-}
-
-sub set_z {
-    my ($self, $z) = @_;
-    
-    return if !$self->enabled;
-    $self->{z_label}->SetLabel(sprintf '%.2f', $z);
-    $self->canvas->set_toolpaths_range(0, $z);
-    $self->canvas->Refresh if $self->IsShown;
-}
-
-sub set_bed_shape {
-    my ($self, $bed_shape) = @_;
-    $self->canvas->set_bed_shape($bed_shape);
-}
-
-1;
diff --git a/lib/Slic3r/GUI/Tab.pm b/lib/Slic3r/GUI/Tab.pm
deleted file mode 100644
index 7050cfa11..000000000
--- a/lib/Slic3r/GUI/Tab.pm
+++ /dev/null
@@ -1,1818 +0,0 @@
-# The "Expert" tab at the right of the main tabbed window.
-
-# This file implements following packages:
-#   Slic3r::GUI::Tab;
-#       Slic3r::GUI::Tab::Print;
-#       Slic3r::GUI::Tab::Filament;
-#       Slic3r::GUI::Tab::Printer;
-#   Slic3r::GUI::Tab::Page
-#       - Option page: For example, the Slic3r::GUI::Tab::Print has option pages "Layers and perimeters", "Infill", "Skirt and brim" ...
-#   Slic3r::GUI::SavePresetWindow
-#       - Dialog to select a new preset name to store the configuration.
-#   Slic3r::GUI::Tab::Preset;
-#       - Single preset item: name, file is default or external.
-
-package Slic3r::GUI::Tab;
-use strict;
-use warnings;
-use utf8;
-
-use File::Basename qw(basename);
-use List::Util qw(first);
-use Wx qw(:bookctrl :dialog :keycode :icon :id :misc :panel :sizer :treectrl :window
-    :button wxTheApp wxCB_READONLY);
-use Wx::Event qw(EVT_BUTTON EVT_COMBOBOX EVT_KEY_DOWN EVT_CHECKBOX EVT_TREE_SEL_CHANGED);
-use base qw(Wx::Panel Class::Accessor);
-
-sub new {
-    my ($class, $parent, %params) = @_;
-    my $self = $class->SUPER::new($parent, -1, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL);
-    
-    # Vertical sizer to hold the choice menu and the rest of the page.
-    $self->{sizer} = Wx::BoxSizer->new(wxVERTICAL);
-    $self->{sizer}->SetSizeHints($self);
-    $self->SetSizer($self->{sizer});
-    
-    # preset chooser
-    {
-        
-        # choice menu
-        $self->{presets_choice} = Wx::BitmapComboBox->new($self, -1, "", wxDefaultPosition, [270, -1], [], wxCB_READONLY);
-        $self->{presets_choice}->SetFont($Slic3r::GUI::small_font);
-        
-        # buttons
-        $self->{btn_save_preset} = Wx::BitmapButton->new($self, -1, Wx::Bitmap->new(Slic3r::var("disk.png"), wxBITMAP_TYPE_PNG), 
-            wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
-        $self->{btn_delete_preset} = Wx::BitmapButton->new($self, -1, Wx::Bitmap->new(Slic3r::var("delete.png"), wxBITMAP_TYPE_PNG), 
-            wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
-        $self->{show_incompatible_presets} = 0;
-        $self->{bmp_show_incompatible_presets} = Wx::Bitmap->new(Slic3r::var("flag-red-icon.png"), wxBITMAP_TYPE_PNG);
-        $self->{bmp_hide_incompatible_presets} = Wx::Bitmap->new(Slic3r::var("flag-green-icon.png"), wxBITMAP_TYPE_PNG);
-        $self->{btn_hide_incompatible_presets} = Wx::BitmapButton->new($self, -1, 
-            $self->{bmp_hide_incompatible_presets},
-            wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
-        $self->{btn_save_preset}->SetToolTipString("Save current " . lc($self->title));
-        $self->{btn_delete_preset}->SetToolTipString("Delete this preset");
-        $self->{btn_delete_preset}->Disable;
-        
-        my $hsizer = Wx::BoxSizer->new(wxHORIZONTAL); 
-        $self->{sizer}->Add($hsizer, 0, wxBOTTOM, 3);
-        $hsizer->Add($self->{presets_choice}, 1, wxLEFT | wxRIGHT | wxTOP | wxALIGN_CENTER_VERTICAL, 3);
-        $hsizer->AddSpacer(4);
-        $hsizer->Add($self->{btn_save_preset}, 0, wxALIGN_CENTER_VERTICAL);
-        $hsizer->AddSpacer(4);
-        $hsizer->Add($self->{btn_delete_preset}, 0, wxALIGN_CENTER_VERTICAL);
-        $hsizer->AddSpacer(16);
-        $hsizer->Add($self->{btn_hide_incompatible_presets}, 0, wxALIGN_CENTER_VERTICAL);
-    }
-
-    # Horizontal sizer to hold the tree and the selected page.
-    $self->{hsizer} = Wx::BoxSizer->new(wxHORIZONTAL);
-    $self->{sizer}->Add($self->{hsizer}, 1, wxEXPAND, 0);
-    
-    # left vertical sizer
-    my $left_sizer = Wx::BoxSizer->new(wxVERTICAL);
-    $self->{hsizer}->Add($left_sizer, 0, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, 3);
-    
-    # tree
-    $self->{treectrl} = Wx::TreeCtrl->new($self, -1, wxDefaultPosition, [185, -1], wxTR_NO_BUTTONS | wxTR_HIDE_ROOT | wxTR_SINGLE | wxTR_NO_LINES | wxBORDER_SUNKEN | wxWANTS_CHARS);
-    $left_sizer->Add($self->{treectrl}, 1, wxEXPAND);
-    $self->{icons} = Wx::ImageList->new(16, 16, 1);
-    # Map from an icon file name to its index in $self->{icons}.
-    $self->{icon_index} = {};
-    # Index of the last icon inserted into $self->{icons}.
-    $self->{icon_count} = -1;
-    $self->{treectrl}->AssignImageList($self->{icons});
-    $self->{treectrl}->AddRoot("root");
-    $self->{pages} = [];
-    $self->{treectrl}->SetIndent(0);
-    $self->{disable_tree_sel_changed_event} = 0;
-    EVT_TREE_SEL_CHANGED($parent, $self->{treectrl}, sub {
-        return if $self->{disable_tree_sel_changed_event};
-        my $page = first { $_->{title} eq $self->{treectrl}->GetItemText($self->{treectrl}->GetSelection) } @{$self->{pages}}
-            or return;
-        $_->Hide for @{$self->{pages}};
-        $page->Show;
-        $self->{hsizer}->Layout;
-        $self->Refresh;
-    });
-    EVT_KEY_DOWN($self->{treectrl}, sub {
-        my ($treectrl, $event) = @_;
-        if ($event->GetKeyCode == WXK_TAB) {
-            $treectrl->Navigate($event->ShiftDown ? &Wx::wxNavigateBackward : &Wx::wxNavigateForward);
-        } else {
-            $event->Skip;
-        }
-    });
-    
-    EVT_COMBOBOX($parent, $self->{presets_choice}, sub {
-        $self->select_preset($self->{presets_choice}->GetStringSelection);
-    });
-    
-    EVT_BUTTON($self, $self->{btn_save_preset}, sub { $self->save_preset });
-    EVT_BUTTON($self, $self->{btn_delete_preset}, sub { $self->delete_preset });
-    EVT_BUTTON($self, $self->{btn_hide_incompatible_presets}, sub { $self->_toggle_show_hide_incompatible });
-    
-    # Initialize the DynamicPrintConfig by default keys/values.
-    # Possible %params keys: no_controller
-    $self->build(%params);
-    $self->rebuild_page_tree;
-    $self->_update;
-    
-    return $self;
-}
-
-# Save the current preset into file.
-# This removes the "dirty" flag of the preset, possibly creates a new preset under a new name,
-# and activates the new preset.
-# Wizard calls save_preset with a name "My Settings", otherwise no name is provided and this method
-# opens a Slic3r::GUI::SavePresetWindow dialog.
-sub save_preset {
-    my ($self, $name) = @_;
-    
-    # since buttons (and choices too) don't get focus on Mac, we set focus manually
-    # to the treectrl so that the EVT_* events are fired for the input field having
-    # focus currently. is there anything better than this?
-    $self->{treectrl}->SetFocus;
-    
-    if (!defined $name) {
-        my $preset = $self->{presets}->get_selected_preset;
-        my $default_name = $preset->default ? 'Untitled' : $preset->name;
-        $default_name =~ s/\.[iI][nN][iI]$//;
-        my $dlg = Slic3r::GUI::SavePresetWindow->new($self,
-            title   => lc($self->title),
-            default => $default_name,
-            values  => [ map $_->name, grep !$_->default && !$_->external, @{$self->{presets}} ],
-        );
-        return unless $dlg->ShowModal == wxID_OK;
-        $name = $dlg->get_name;
-    }
-    # Save the preset into Slic3r::data_dir/presets/section_name/preset_name.ini
-    eval { $self->{presets}->save_current_preset($name); };
-    Slic3r::GUI::catch_error($self) and return;
-    # Mark the print & filament enabled if they are compatible with the currently selected preset.
-    wxTheApp->{preset_bundle}->update_compatible_with_printer(0);
-    # Add the new item into the UI component, remove dirty flags and activate the saved item.
-    $self->update_tab_ui;
-    # Update the selection boxes at the platter.
-    $self->_on_presets_changed;
-}
-
-# Called for a currently selected preset.
-sub delete_preset {
-    my ($self) = @_;
-    my $current_preset = $self->{presets}->get_selected_preset;
-    # Don't let the user delete the '- default -' configuration.
-    my $msg = 'Are you sure you want to ' . ($current_preset->external ? 'remove' : 'delete') . ' the selected preset?';
-    my $title = ($current_preset->external ? 'Remove' : 'Delete') . ' Preset';
-    return if $current_preset->default ||
-        wxID_YES != Wx::MessageDialog->new($self, $msg, $title, wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION)->ShowModal;
-    # Delete the file and select some other reasonable preset.
-    # The 'external' presets will only be removed from the preset list, their files will not be deleted.
-    eval { $self->{presets}->delete_current_preset; };
-    Slic3r::GUI::catch_error($self) and return;
-    # Load the newly selected preset into the UI, update selection combo boxes with their dirty flags.
-    $self->load_current_preset;
-}
-
-sub _toggle_show_hide_incompatible {
-    my ($self) = @_;
-    $self->{show_incompatible_presets} = ! $self->{show_incompatible_presets};
-    $self->_update_show_hide_incompatible_button;
-    $self->update_tab_ui;
-}
-
-sub _update_show_hide_incompatible_button {
-    my ($self) = @_;
-    $self->{btn_hide_incompatible_presets}->SetBitmap($self->{show_incompatible_presets} ?
-        $self->{bmp_show_incompatible_presets} : $self->{bmp_hide_incompatible_presets});
-    $self->{btn_hide_incompatible_presets}->SetToolTipString($self->{show_incompatible_presets} ?
-        "Both compatible an incompatible presets are shown. Click to hide presets not compatible with the current printer." :
-        "Only compatible presets are shown. Click to show both the presets compatible and not compatible with the current printer.");
-}
-
-# Register the on_value_change callback.
-sub on_value_change {
-    my ($self, $cb) = @_;
-    $self->{on_value_change} = $cb;
-}
-
-# Register the on_presets_changed callback.
-sub on_presets_changed {
-    my ($self, $cb) = @_;
-    $self->{on_presets_changed} = $cb;
-}
-
-# This method is called whenever an option field is changed by the user.
-# Propagate event to the parent through the 'on_value_change' callback
-# and call _update.
-# The on_value_change callback triggers Platter::on_config_change() to configure the 3D preview
-# (colors, wipe tower positon etc) and to restart the background slicing process.
-sub _on_value_change {
-    my ($self, $key, $value) = @_;
-    $self->{on_value_change}->($key, $value) if $self->{on_value_change};
-    $self->_update;
-}
-
-# Override this to capture changes of configuration caused either by loading or switching a preset,
-# or by a user changing an option field.
-# This callback is useful for cross-validating configuration values of a single preset.
-sub _update {}
-
-# Call a callback to update the selection of presets on the platter:
-# To update the content of the selection boxes,
-# to update the filament colors of the selection boxes,
-# to update the "dirty" flags of the selection boxes,
-# to uddate number of "filament" selection boxes when the number of extruders change.
-sub _on_presets_changed {
-    my ($self, $reload_dependent_tabs) = @_;
-    $self->{on_presets_changed}->($self->{presets}, $reload_dependent_tabs) 
-        if $self->{on_presets_changed};
-}
-
-# For the printer profile, generate the extruder pages after a preset is loaded.
-sub on_preset_loaded {}
-
-# If the current preset is dirty, the user is asked whether the changes may be discarded.
-# if the current preset was not dirty, or the user agreed to discard the changes, 1 is returned.
-sub may_discard_current_dirty_preset
-{
-    my ($self, $presets, $new_printer_name) = @_;
-    $presets //= $self->{presets};
-    # Display a dialog showing the dirty options in a human readable form.
-    my $old_preset  = $presets->get_current_preset;
-    my $type_name   = $presets->name;
-    my $tab         = '          ';
-    my $name        = $old_preset->default ? 
-        ('Default ' . $type_name . ' preset') :
-        ($type_name . " preset\n$tab" . $old_preset->name);
-    # Collect descriptions of the dirty options.
-    my @option_names = ();
-    foreach my $opt_key (@{$presets->current_dirty_options}) {
-        my $opt = $Slic3r::Config::Options->{$opt_key};
-        my $name = $opt->{full_label} // $opt->{label};
-        $name = $opt->{category} . " > $name" if $opt->{category};
-        push @option_names, $name;
-    }
-    # Show a confirmation dialog with the list of dirty options.
-    my $changes = join "\n", map "$tab$_", @option_names;
-    my $message = (defined $new_printer_name) ?
-        "$name\n\nis not compatible with printer\n$tab$new_printer_name\n\nand it has the following unsaved changes:" :
-        "$name\n\nhas the following unsaved changes:";
-    my $confirm = Wx::MessageDialog->new($self, 
-        $message . "\n$changes\n\nDiscard changes and continue anyway?",
-        'Unsaved Changes', wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION);
-    return $confirm->ShowModal == wxID_YES;
-}
-
-# Called by the UI combo box when the user switches profiles.
-# Select a preset by a name. If ! defined(name), then the default preset is selected.
-# If the current profile is modified, user is asked to save the changes.
-sub select_preset {
-    my ($self, $name, $force) = @_;
-    $force //= 0;
-    my $presets         = $self->{presets};
-    # If no name is provided, select the "-- default --" preset.
-    $name //= $presets->default_preset->name;
-    my $current_dirty   = $presets->current_is_dirty;
-    my $canceled        = 0;
-    my $printer_tab     = $presets->name eq 'printer';
-    my @reload_dependent_tabs = ();
-    if (! $force && $current_dirty && ! $self->may_discard_current_dirty_preset) {
-        $canceled = 1;
-    } elsif ($printer_tab) {
-        # Before switching the printer to a new one, verify, whether the currently active print and filament
-        # are compatible with the new printer.
-        # If they are not compatible and the the current print or filament are dirty, let user decide
-        # whether to discard the changes or keep the current printer selection.
-        my $new_printer_preset      = $presets->find_preset($name, 1);
-        my $print_presets           = wxTheApp->{preset_bundle}->print;
-        my $print_preset_dirty      = $print_presets->current_is_dirty;
-        my $print_preset_compatible = $print_presets->get_edited_preset->is_compatible_with_printer($new_printer_preset);
-        $canceled = ! $force && $print_preset_dirty && ! $print_preset_compatible &&
-            ! $self->may_discard_current_dirty_preset($print_presets, $name);
-        my $filament_presets        = wxTheApp->{preset_bundle}->filament;
-        my $filament_preset_dirty   = $filament_presets->current_is_dirty;
-        my $filament_preset_compatible = $filament_presets->get_edited_preset->is_compatible_with_printer($new_printer_preset);
-        if (! $canceled && ! $force) {
-            $canceled = $filament_preset_dirty && ! $filament_preset_compatible &&
-                ! $self->may_discard_current_dirty_preset($filament_presets, $name);
-        }
-        if (! $canceled) {
-            if (! $print_preset_compatible) {
-                # The preset will be switched to a different, compatible preset, or the '-- default --'.
-                push @reload_dependent_tabs, 'print';
-                $print_presets->discard_current_changes if $print_preset_dirty;                
-            }
-            if (! $filament_preset_compatible) {
-                # The preset will be switched to a different, compatible preset, or the '-- default --'.
-                push @reload_dependent_tabs, 'filament';
-                $filament_presets->discard_current_changes if $filament_preset_dirty;
-            }
-        }
-    }
-    if ($canceled) {
-        $self->update_tab_ui;
-        # Trigger the on_presets_changed event so that we also restore the previous value in the plater selector, 
-        # if this action was initiated from the platter.
-        $self->_on_presets_changed;
-    } else {
-        $presets->discard_current_changes if $current_dirty;
-        $presets->select_preset_by_name($name);
-        # Mark the print & filament enabled if they are compatible with the currently selected preset.
-        # The following method should not discard changes of current print or filament presets on change of a printer profile,
-        # if they are compatible with the current printer.
-        wxTheApp->{preset_bundle}->update_compatible_with_printer(1)
-            if $current_dirty || $printer_tab;
-        # Initialize the UI from the current preset.
-        $self->load_current_preset(\@reload_dependent_tabs);
-    }
-}
-
-# Initialize the UI from the current preset.
-sub load_current_preset {
-    my ($self, $dependent_tab_names) = @_;
-    my $preset = $self->{presets}->get_current_preset;
-    eval {
-        local $SIG{__WARN__} = Slic3r::GUI::warning_catcher($self);
-        my $method = $preset->default ? 'Disable' : 'Enable';
-        $self->{btn_delete_preset}->$method;
-        $self->_update;
-        # For the printer profile, generate the extruder pages.
-        $self->on_preset_loaded;
-        # Reload preset pages with the new configuration values.
-        $self->_reload_config;
-    };
-    # use CallAfter because some field triggers schedule on_change calls using CallAfter,
-    # and we don't want them to be called after this update_dirty() as they would mark the 
-    # preset dirty again
-    # (not sure this is true anymore now that update_dirty is idempotent)
-    wxTheApp->CallAfter(sub {
-        $self->update_tab_ui;
-        $self->_on_presets_changed($dependent_tab_names);
-    });
-}
-
-sub add_options_page {
-    my ($self, $title, $icon, %params) = @_;
-    # Index of $icon in an icon list $self->{icons}.
-    my $icon_idx = 0;
-    if ($icon) {
-        $icon_idx = $self->{icon_index}->{$icon};
-        if (! defined $icon_idx) {
-            # Add a new icon to the icon list.
-            my $bitmap = Wx::Bitmap->new(Slic3r::var($icon), wxBITMAP_TYPE_PNG);
-            $self->{icons}->Add($bitmap);
-            $icon_idx = $self->{icon_count} + 1;
-            $self->{icon_count} = $icon_idx;
-            $self->{icon_index}->{$icon} = $icon_idx;
-        }
-    }
-    # Initialize the page.
-    my $page = Slic3r::GUI::Tab::Page->new($self, $title, $icon_idx);
-    $page->Hide;
-    $self->{hsizer}->Add($page, 1, wxEXPAND | wxLEFT, 5);
-    push @{$self->{pages}}, $page;
-    return $page;
-}
-
-# Reload current $self->{config} (aka $self->{presets}->edited_preset->config) into the UI fields.
-sub _reload_config {
-    my ($self) = @_;
-    $self->Freeze;
-    $_->reload_config for @{$self->{pages}};
-    $self->Thaw;
-}
-
-# Regerenerate content of the page tree.
-sub rebuild_page_tree {
-    my ($self) = @_;
-    $self->Freeze;
-    # get label of the currently selected item
-    my $selected = $self->{treectrl}->GetItemText($self->{treectrl}->GetSelection);    
-    my $rootItem = $self->{treectrl}->GetRootItem;
-    $self->{treectrl}->DeleteChildren($rootItem);
-    my $have_selection = 0;
-    foreach my $page (@{$self->{pages}}) {
-        my $itemId = $self->{treectrl}->AppendItem($rootItem, $page->{title}, $page->{iconID});
-        if ($page->{title} eq $selected) {
-            $self->{disable_tree_sel_changed_event} = 1;
-            $self->{treectrl}->SelectItem($itemId);
-            $self->{disable_tree_sel_changed_event} = 0;
-            $have_selection = 1;
-        }
-    }
-    if (!$have_selection) {
-        # this is triggered on first load, so we don't disable the sel change event
-        $self->{treectrl}->SelectItem($self->{treectrl}->GetFirstChild($rootItem));
-    }
-    $self->Thaw;
-}
-
-# Update the combo box label of the selected preset based on its "dirty" state,
-# comparing the selected preset config with $self->{config}.
-sub update_dirty {
-    my ($self) = @_;
-    $self->{presets}->update_dirty_ui($self->{presets_choice});
-    $self->_on_presets_changed;
-}
-
-# Load a provied DynamicConfig into the tab, modifying the active preset.
-# This could be used for example by setting a Wipe Tower position by interactive manipulation in the 3D view.
-sub load_config {
-    my ($self, $config) = @_;
-    my $modified = 0;
-    foreach my $opt_key (@{$self->{config}->diff($config)}) {
-        $self->{config}->set($opt_key, $config->get($opt_key));
-        $modified = 1;
-    }
-    if ($modified) {
-        $self->update_dirty;
-        # Initialize UI components with the config values.
-        $self->_reload_config;
-        $self->_update;
-    }
-}
-
-# To be called by custom widgets, load a value into a config, 
-# update the preset selection boxes (the dirty flags)
-sub _load_key_value {
-    my ($self, $opt_key, $value) = @_;
-    $self->{config}->set($opt_key, $value);
-    # Mark the print & filament enabled if they are compatible with the currently selected preset.
-    if ($opt_key eq 'compatible_printers') {
-#        $opt_key eq 'compatible_printers_condition') {
-        wxTheApp->{preset_bundle}->update_compatible_with_printer(0);
-    }
-    $self->{presets}->update_dirty_ui($self->{presets_choice});
-    $self->_on_presets_changed;
-    $self->_update;
-}
-
-# Find a field with an index over all pages of this tab.
-# This method is used often and everywhere, therefore it shall be quick.
-sub get_field {
-    my ($self, $opt_key, $opt_index) = @_;
-    foreach my $page (@{$self->{pages}}) {
-        my $field = $page->get_field($opt_key, $opt_index);
-        return $field if defined $field;
-    }
-    return undef;
-}
-
-# Set a key/value pair on this page. Return true if the value has been modified.
-# Currently used for distributing extruders_count over preset pages of Slic3r::GUI::Tab::Printer
-# after a preset is loaded.
-sub set_value {
-    my ($self, $opt_key, $value) = @_;
-    my $changed = 0;
-    foreach my $page (@{$self->{pages}}) {
-        $changed = 1 if $page->set_value($opt_key, $value);
-    }
-    return $changed;
-}
-
-# Return a callback to create a Tab widget to mark the preferences as compatible / incompatible to the current printer.
-sub _compatible_printers_widget {
-    my ($self) = @_;
-    
-    return sub {
-        my ($parent) = @_;
-        
-        my $checkbox = $self->{compatible_printers_checkbox} = Wx::CheckBox->new($parent, -1, "All");
-        
-        my $btn = $self->{compatible_printers_btn} = Wx::Button->new($parent, -1, "Set…", wxDefaultPosition, wxDefaultSize,
-            wxBU_LEFT | wxBU_EXACTFIT);
-        $btn->SetFont($Slic3r::GUI::small_font);
-        $btn->SetBitmap(Wx::Bitmap->new(Slic3r::var("printer_empty.png"), wxBITMAP_TYPE_PNG));
-        
-        my $sizer = Wx::BoxSizer->new(wxHORIZONTAL);
-        $sizer->Add($checkbox, 0, wxALIGN_CENTER_VERTICAL);
-        $sizer->Add($btn, 0, wxALIGN_CENTER_VERTICAL);
-        
-        EVT_CHECKBOX($self, $checkbox, sub {
-            my $method = $checkbox->GetValue ? 'Disable' : 'Enable';
-            $btn->$method;
-            # All printers have been made compatible with this preset.
-            $self->_load_key_value('compatible_printers', []) if $checkbox->GetValue;
-            $self->get_field('compatible_printers_condition')->toggle($checkbox->GetValue);
-        });
-        
-        EVT_BUTTON($self, $btn, sub {
-            # Collect names of non-default non-external printer profiles.
-            my @presets = map $_->name, grep !$_->default && !$_->external,
-                @{wxTheApp->{preset_bundle}->printer};
-            my $dlg = Wx::MultiChoiceDialog->new($self,
-                "Select the printers this profile is compatible with.",
-                "Compatible printers", \@presets);
-            # Collect and set indices of printers marked as compatible.
-            my @selections = ();
-            foreach my $preset_name (@{ $self->{config}->get('compatible_printers') }) {
-                my $idx = first { $presets[$_] eq $preset_name } 0..$#presets;
-                push @selections, $idx if defined $idx;
-            }
-            $dlg->SetSelections(@selections);
-            # Show the dialog.
-            if ($dlg->ShowModal == wxID_OK) {
-                my $value = [ @presets[$dlg->GetSelections] ];
-                if (!@$value) {
-                    $checkbox->SetValue(1);
-                    $self->get_field('compatible_printers_condition')->toggle(1);
-                    $btn->Disable;
-                }
-                # All printers have been made compatible with this preset.
-                $self->_load_key_value('compatible_printers', $value);
-            }
-        });
-        
-        return $sizer;
-    };
-}
-
-sub _reload_compatible_printers_widget {
-    my ($self) = @_;
-    my $has_any = int(@{$self->{config}->get('compatible_printers')}) > 0;
-    my $method = $has_any ? 'Enable' : 'Disable';
-    $self->{compatible_printers_checkbox}->SetValue(! $has_any);
-    $self->{compatible_printers_btn}->$method;
-    $self->get_field('compatible_printers_condition')->toggle(! $has_any);
-}
-
-sub update_ui_from_settings {
-    my ($self) = @_;
-    # Show the 'show / hide presets' button only for the print and filament tabs, and only if enabled
-    # in application preferences.
-    my $show   = wxTheApp->{app_config}->get("show_incompatible_presets") && $self->{presets}->name ne 'printer';
-    my $method = $show ? 'Show' : 'Hide';
-    $self->{btn_hide_incompatible_presets}->$method;
-    # If the 'show / hide presets' button is hidden, hide the incompatible presets.
-    if ($show) {
-        $self->_update_show_hide_incompatible_button;
-    } else {
-        if ($self->{show_incompatible_presets}) {
-            $self->{show_incompatible_presets} = 0;
-            $self->update_tab_ui;
-        }
-    }
-}
-sub update_tab_ui {
-    my ($self) = @_;
-    $self->{presets}->update_tab_ui($self->{presets_choice}, $self->{show_incompatible_presets})
-}
-
-package Slic3r::GUI::Tab::Print;
-use base 'Slic3r::GUI::Tab';
-
-use List::Util qw(first);
-use Wx qw(:icon :dialog :id wxTheApp);
-
-sub name { 'print' }
-sub title { 'Print Settings' }
-
-sub build {
-    my $self = shift;
-    
-    $self->{presets} = wxTheApp->{preset_bundle}->print;
-    $self->{config} = $self->{presets}->get_edited_preset->config;
-    
-    {
-        my $page = $self->add_options_page('Layers and perimeters', 'layers.png');
-        {
-            my $optgroup = $page->new_optgroup('Layer height');
-            $optgroup->append_single_option_line('layer_height');
-            $optgroup->append_single_option_line('first_layer_height');
-        }
-        {
-            my $optgroup = $page->new_optgroup('Vertical shells');
-            $optgroup->append_single_option_line('perimeters');
-            $optgroup->append_single_option_line('spiral_vase');
-        }
-        {
-            my $optgroup = $page->new_optgroup('Horizontal shells');
-            my $line = Slic3r::GUI::OptionsGroup::Line->new(
-                label => 'Solid layers',
-            );
-            $line->append_option($optgroup->get_option('top_solid_layers'));
-            $line->append_option($optgroup->get_option('bottom_solid_layers'));
-            $optgroup->append_line($line);
-        }
-        {
-            my $optgroup = $page->new_optgroup('Quality (slower slicing)');
-            $optgroup->append_single_option_line('extra_perimeters');
-            $optgroup->append_single_option_line('ensure_vertical_shell_thickness');
-            $optgroup->append_single_option_line('avoid_crossing_perimeters');
-            $optgroup->append_single_option_line('thin_walls');
-            $optgroup->append_single_option_line('overhangs');
-        }
-        {
-            my $optgroup = $page->new_optgroup('Advanced');
-            $optgroup->append_single_option_line('seam_position');
-            $optgroup->append_single_option_line('external_perimeters_first');
-        }
-    }
-    
-    {
-        my $page = $self->add_options_page('Infill', 'infill.png');
-        {
-            my $optgroup = $page->new_optgroup('Infill');
-            $optgroup->append_single_option_line('fill_density');
-            $optgroup->append_single_option_line('fill_pattern');
-            $optgroup->append_single_option_line('external_fill_pattern');
-        }
-        {
-            my $optgroup = $page->new_optgroup('Reducing printing time');
-            $optgroup->append_single_option_line('infill_every_layers');
-            $optgroup->append_single_option_line('infill_only_where_needed');
-        }
-        {
-            my $optgroup = $page->new_optgroup('Advanced');
-            $optgroup->append_single_option_line('solid_infill_every_layers');
-            $optgroup->append_single_option_line('fill_angle');
-            $optgroup->append_single_option_line('solid_infill_below_area');
-            $optgroup->append_single_option_line('bridge_angle');
-            $optgroup->append_single_option_line('only_retract_when_crossing_perimeters');
-            $optgroup->append_single_option_line('infill_first');
-        }
-    }
-    
-    {
-        my $page = $self->add_options_page('Skirt and brim', 'box.png');
-        {
-            my $optgroup = $page->new_optgroup('Skirt');
-            $optgroup->append_single_option_line('skirts');
-            $optgroup->append_single_option_line('skirt_distance');
-            $optgroup->append_single_option_line('skirt_height');
-            $optgroup->append_single_option_line('min_skirt_length');
-        }
-        {
-            my $optgroup = $page->new_optgroup('Brim');
-            $optgroup->append_single_option_line('brim_width');
-        }
-    }
-    
-    {
-        my $page = $self->add_options_page('Support material', 'building.png');
-        {
-            my $optgroup = $page->new_optgroup('Support material');
-            $optgroup->append_single_option_line('support_material');
-            $optgroup->append_single_option_line('support_material_threshold');
-            $optgroup->append_single_option_line('support_material_enforce_layers');
-        }
-        {
-            my $optgroup = $page->new_optgroup('Raft');
-            $optgroup->append_single_option_line('raft_layers');
-#            $optgroup->append_single_option_line('raft_contact_distance');
-        }
-        {
-            my $optgroup = $page->new_optgroup('Options for support material and raft');
-            $optgroup->append_single_option_line('support_material_contact_distance');
-            $optgroup->append_single_option_line('support_material_pattern');
-            $optgroup->append_single_option_line('support_material_with_sheath');
-            $optgroup->append_single_option_line('support_material_spacing');
-            $optgroup->append_single_option_line('support_material_angle');
-            $optgroup->append_single_option_line('support_material_interface_layers');
-            $optgroup->append_single_option_line('support_material_interface_spacing');
-            $optgroup->append_single_option_line('support_material_interface_contact_loops');
-            $optgroup->append_single_option_line('support_material_buildplate_only');
-            $optgroup->append_single_option_line('support_material_xy_spacing');
-            $optgroup->append_single_option_line('dont_support_bridges');
-            $optgroup->append_single_option_line('support_material_synchronize_layers');
-        }
-    }
-    
-    {
-        my $page = $self->add_options_page('Speed', 'time.png');
-        {
-            my $optgroup = $page->new_optgroup('Speed for print moves');
-            $optgroup->append_single_option_line('perimeter_speed');
-            $optgroup->append_single_option_line('small_perimeter_speed');
-            $optgroup->append_single_option_line('external_perimeter_speed');
-            $optgroup->append_single_option_line('infill_speed');
-            $optgroup->append_single_option_line('solid_infill_speed');
-            $optgroup->append_single_option_line('top_solid_infill_speed');
-            $optgroup->append_single_option_line('support_material_speed');
-            $optgroup->append_single_option_line('support_material_interface_speed');
-            $optgroup->append_single_option_line('bridge_speed');
-            $optgroup->append_single_option_line('gap_fill_speed');
-        }
-        {
-            my $optgroup = $page->new_optgroup('Speed for non-print moves');
-            $optgroup->append_single_option_line('travel_speed');
-        }
-        {
-            my $optgroup = $page->new_optgroup('Modifiers');
-            $optgroup->append_single_option_line('first_layer_speed');
-        }
-        {
-            my $optgroup = $page->new_optgroup('Acceleration control (advanced)');
-            $optgroup->append_single_option_line('perimeter_acceleration');
-            $optgroup->append_single_option_line('infill_acceleration');
-            $optgroup->append_single_option_line('bridge_acceleration');
-            $optgroup->append_single_option_line('first_layer_acceleration');
-            $optgroup->append_single_option_line('default_acceleration');
-        }
-        {
-            my $optgroup = $page->new_optgroup('Autospeed (advanced)');
-            $optgroup->append_single_option_line('max_print_speed');
-            $optgroup->append_single_option_line('max_volumetric_speed');
-            $optgroup->append_single_option_line('max_volumetric_extrusion_rate_slope_positive');
-            $optgroup->append_single_option_line('max_volumetric_extrusion_rate_slope_negative');
-        }
-    }
-    
-    {
-        my $page = $self->add_options_page('Multiple Extruders', 'funnel.png');
-        {
-            my $optgroup = $page->new_optgroup('Extruders');
-            $optgroup->append_single_option_line('perimeter_extruder');
-            $optgroup->append_single_option_line('infill_extruder');
-            $optgroup->append_single_option_line('solid_infill_extruder');
-            $optgroup->append_single_option_line('support_material_extruder');
-            $optgroup->append_single_option_line('support_material_interface_extruder');
-        }
-        {
-            my $optgroup = $page->new_optgroup('Ooze prevention');
-            $optgroup->append_single_option_line('ooze_prevention');
-            $optgroup->append_single_option_line('standby_temperature_delta');
-        }
-        {
-            my $optgroup = $page->new_optgroup('Wipe tower');
-            $optgroup->append_single_option_line('wipe_tower');
-            $optgroup->append_single_option_line('wipe_tower_x');
-            $optgroup->append_single_option_line('wipe_tower_y');
-            $optgroup->append_single_option_line('wipe_tower_width');
-            $optgroup->append_single_option_line('wipe_tower_per_color_wipe');
-            $optgroup->append_single_option_line('wipe_tower_rotation_angle');
-        }
-        {
-            my $optgroup = $page->new_optgroup('Advanced');
-            $optgroup->append_single_option_line('interface_shells');
-        }
-    }
-    
-    {
-        my $page = $self->add_options_page('Advanced', 'wrench.png');
-        {
-            my $optgroup = $page->new_optgroup('Extrusion width',
-                label_width => 180,
-            );
-            $optgroup->append_single_option_line('extrusion_width');
-            $optgroup->append_single_option_line('first_layer_extrusion_width');
-            $optgroup->append_single_option_line('perimeter_extrusion_width');
-            $optgroup->append_single_option_line('external_perimeter_extrusion_width');
-            $optgroup->append_single_option_line('infill_extrusion_width');
-            $optgroup->append_single_option_line('solid_infill_extrusion_width');
-            $optgroup->append_single_option_line('top_infill_extrusion_width');
-            $optgroup->append_single_option_line('support_material_extrusion_width');
-        }
-        {
-            my $optgroup = $page->new_optgroup('Overlap');
-            $optgroup->append_single_option_line('infill_overlap');
-        }
-        {
-            my $optgroup = $page->new_optgroup('Flow');
-            $optgroup->append_single_option_line('bridge_flow_ratio');
-        }
-        {
-            my $optgroup = $page->new_optgroup('Other');
-            $optgroup->append_single_option_line('clip_multipart_objects');
-            $optgroup->append_single_option_line('elefant_foot_compensation');
-            $optgroup->append_single_option_line('xy_size_compensation');
-#            $optgroup->append_single_option_line('threads');
-            $optgroup->append_single_option_line('resolution');
-        }
-    }
-    
-    {
-        my $page = $self->add_options_page('Output options', 'page_white_go.png');
-        {
-            my $optgroup = $page->new_optgroup('Sequential printing');
-            $optgroup->append_single_option_line('complete_objects');
-            my $line = Slic3r::GUI::OptionsGroup::Line->new(
-                label => 'Extruder clearance (mm)',
-            );
-            foreach my $opt_key (qw(extruder_clearance_radius extruder_clearance_height)) {
-                my $option = $optgroup->get_option($opt_key);
-                $option->width(60);
-                $line->append_option($option);
-            }
-            $optgroup->append_line($line);
-        }
-        {
-            my $optgroup = $page->new_optgroup('Output file');
-            $optgroup->append_single_option_line('gcode_comments');
-            
-            {
-                my $option = $optgroup->get_option('output_filename_format');
-                $option->full_width(1);
-                $optgroup->append_single_option_line($option);
-            }
-        }
-        {
-            my $optgroup = $page->new_optgroup('Post-processing scripts',
-                label_width => 0,
-            );
-            my $option = $optgroup->get_option('post_process');
-            $option->full_width(1);
-            $option->height(50);
-            $optgroup->append_single_option_line($option);
-        }
-    }
-    
-    {
-        my $page = $self->add_options_page('Notes', 'note.png');
-        {
-            my $optgroup = $page->new_optgroup('Notes',
-                label_width => 0,
-            );
-            my $option = $optgroup->get_option('notes');
-            $option->full_width(1);
-            $option->height(250);
-            $optgroup->append_single_option_line($option);
-        }
-    }
-
-    {
-        my $page = $self->add_options_page('Dependencies', 'wrench.png');
-        {
-            my $optgroup = $page->new_optgroup('Profile dependencies');
-            {
-                my $line = Slic3r::GUI::OptionsGroup::Line->new(
-                    label       => 'Compatible printers',
-                    widget      => $self->_compatible_printers_widget,
-                );
-                $optgroup->append_line($line);
-
-                my $option = $optgroup->get_option('compatible_printers_condition');
-                $option->full_width(1);
-                $optgroup->append_single_option_line($option);
-            }
-        }
-    }
-}
-
-# Reload current $self->{config} (aka $self->{presets}->edited_preset->config) into the UI fields.
-sub _reload_config {
-    my ($self) = @_;
-    $self->_reload_compatible_printers_widget;
-    $self->SUPER::_reload_config;
-}
-
-# Slic3r::GUI::Tab::Print::_update is called after a configuration preset is loaded or switched, or when a single option is modifed by the user.
-sub _update {
-    my ($self) = @_;
-    $self->Freeze;
-
-    my $config = $self->{config};
-    
-    if ($config->spiral_vase && !($config->perimeters == 1 && $config->top_solid_layers == 0 && $config->fill_density == 0)) {
-        my $dialog = Wx::MessageDialog->new($self,
-            "The Spiral Vase mode requires:\n"
-            . "- one perimeter\n"
-            . "- no top solid layers\n"
-            . "- 0% fill density\n"
-            . "- no support material\n"
-            . "- no ensure_vertical_shell_thickness\n"
-            . "\nShall I adjust those settings in order to enable Spiral Vase?",
-            'Spiral Vase', wxICON_WARNING | wxYES | wxNO);
-        my $new_conf = Slic3r::Config->new;
-        if ($dialog->ShowModal() == wxID_YES) {
-            $new_conf->set("perimeters", 1);
-            $new_conf->set("top_solid_layers", 0);
-            $new_conf->set("fill_density", 0);
-            $new_conf->set("support_material", 0);
-            $new_conf->set("ensure_vertical_shell_thickness", 0);
-        } else {
-            $new_conf->set("spiral_vase", 0);
-        }
-        $self->load_config($new_conf);
-    }
-
-    if ($config->wipe_tower && 
-        ($config->first_layer_height != 0.2 || $config->layer_height < 0.15 || $config->layer_height > 0.35)) {
-        my $dialog = Wx::MessageDialog->new($self,
-            "The Wipe Tower currently supports only:\n"
-            . "- first layer height 0.2mm\n"
-            . "- layer height from 0.15mm to 0.35mm\n"
-            . "\nShall I adjust those settings in order to enable the Wipe Tower?",
-            'Wipe Tower', wxICON_WARNING | wxYES | wxNO);
-        my $new_conf = Slic3r::Config->new;
-        if ($dialog->ShowModal() == wxID_YES) {
-            $new_conf->set("first_layer_height", 0.2);
-            $new_conf->set("layer_height", 0.15) if  $config->layer_height < 0.15;
-            $new_conf->set("layer_height", 0.35) if  $config->layer_height > 0.35;
-        } else {
-            $new_conf->set("wipe_tower", 0);
-        }
-        $self->load_config($new_conf);
-    }
-
-    if ($config->wipe_tower && $config->support_material && $config->support_material_contact_distance > 0. && 
-        ($config->support_material_extruder != 0 || $config->support_material_interface_extruder != 0)) {
-        my $dialog = Wx::MessageDialog->new($self,
-            "The Wipe Tower currently supports the non-soluble supports only\n"
-            . "if they are printed with the current extruder without triggering a tool change.\n"
-            . "(both support_material_extruder and support_material_interface_extruder need to be set to 0).\n"
-            . "\nShall I adjust those settings in order to enable the Wipe Tower?",
-            'Wipe Tower', wxICON_WARNING | wxYES | wxNO);
-        my $new_conf = Slic3r::Config->new;
-        if ($dialog->ShowModal() == wxID_YES) {
-            $new_conf->set("support_material_extruder", 0);
-            $new_conf->set("support_material_interface_extruder", 0);
-        } else {
-            $new_conf->set("wipe_tower", 0);
-        }
-        $self->load_config($new_conf);
-    }
-
-    if ($config->wipe_tower && $config->support_material && $config->support_material_contact_distance == 0 && 
-        ! $config->support_material_synchronize_layers) {
-        my $dialog = Wx::MessageDialog->new($self,
-            "For the Wipe Tower to work with the soluble supports, the support layers\n"
-            . "need to be synchronized with the object layers.\n"
-            . "\nShall I synchronize support layers in order to enable the Wipe Tower?",
-            'Wipe Tower', wxICON_WARNING | wxYES | wxNO);
-        my $new_conf = Slic3r::Config->new;
-        if ($dialog->ShowModal() == wxID_YES) {
-            $new_conf->set("support_material_synchronize_layers", 1);
-        } else {
-            $new_conf->set("wipe_tower", 0);
-        }
-        $self->load_config($new_conf);
-    }
-
-    if ($config->support_material) {
-        # Ask only once.
-        if (! $self->{support_material_overhangs_queried}) {
-            $self->{support_material_overhangs_queried} = 1;
-            if ($config->overhangs != 1) {
-                my $dialog = Wx::MessageDialog->new($self,
-                    "Supports work better, if the following feature is enabled:\n"
-                    . "- Detect bridging perimeters\n"
-                    . "\nShall I adjust those settings for supports?",
-                    'Support Generator', wxICON_WARNING | wxYES | wxNO | wxCANCEL);
-                my $answer = $dialog->ShowModal();
-                my $new_conf = Slic3r::Config->new;
-                if ($answer == wxID_YES) {
-                    # Enable "detect bridging perimeters".
-                    $new_conf->set("overhangs", 1);
-                } elsif ($answer == wxID_NO) {
-                    # Do nothing, leave supports on and "detect bridging perimeters" off.
-                } elsif ($answer == wxID_CANCEL) {
-                    # Disable supports.
-                    $new_conf->set("support_material", 0);
-                    $self->{support_material_overhangs_queried} = 0;
-                }
-                $self->load_config($new_conf);
-            }
-        }
-    } else {
-        $self->{support_material_overhangs_queried} = 0;
-    }
-    
-    if ($config->fill_density == 100
-        && !first { $_ eq $config->fill_pattern } @{$Slic3r::Config::Options->{external_fill_pattern}{values}}) {
-        my $dialog = Wx::MessageDialog->new($self,
-            "The " . $config->fill_pattern . " infill pattern is not supposed to work at 100% density.\n"
-            . "\nShall I switch to rectilinear fill pattern?",
-            'Infill', wxICON_WARNING | wxYES | wxNO);
-        
-        my $new_conf = Slic3r::Config->new;
-        if ($dialog->ShowModal() == wxID_YES) {
-            $new_conf->set("fill_pattern", 'rectilinear');
-            $new_conf->set("fill_density", 100);
-        } else {
-            $new_conf->set("fill_density", 40);
-        }
-        $self->load_config($new_conf);
-    }
-    
-    my $have_perimeters = $config->perimeters > 0;
-    $self->get_field($_)->toggle($have_perimeters)
-        for qw(extra_perimeters ensure_vertical_shell_thickness thin_walls overhangs seam_position external_perimeters_first
-            external_perimeter_extrusion_width
-            perimeter_speed small_perimeter_speed external_perimeter_speed);
-    
-    my $have_infill = $config->fill_density > 0;
-    # infill_extruder uses the same logic as in Print::extruders()
-    $self->get_field($_)->toggle($have_infill)
-        for qw(fill_pattern infill_every_layers infill_only_where_needed solid_infill_every_layers
-            solid_infill_below_area infill_extruder);
-    
-    my $have_solid_infill = ($config->top_solid_layers > 0) || ($config->bottom_solid_layers > 0);
-    # solid_infill_extruder uses the same logic as in Print::extruders()
-    $self->get_field($_)->toggle($have_solid_infill)
-        for qw(external_fill_pattern infill_first solid_infill_extruder solid_infill_extrusion_width
-            solid_infill_speed);
-    
-    $self->get_field($_)->toggle($have_infill || $have_solid_infill)
-        for qw(fill_angle bridge_angle infill_extrusion_width infill_speed bridge_speed);
-    
-    $self->get_field('gap_fill_speed')->toggle($have_perimeters && $have_infill);
-    
-    my $have_top_solid_infill = $config->top_solid_layers > 0;
-    $self->get_field($_)->toggle($have_top_solid_infill)
-        for qw(top_infill_extrusion_width top_solid_infill_speed);
-    
-    my $have_default_acceleration = $config->default_acceleration > 0;
-    $self->get_field($_)->toggle($have_default_acceleration)
-        for qw(perimeter_acceleration infill_acceleration bridge_acceleration first_layer_acceleration);
-    
-    my $have_skirt = $config->skirts > 0 || $config->min_skirt_length > 0;
-    $self->get_field($_)->toggle($have_skirt)
-        for qw(skirt_distance skirt_height);
-    
-    my $have_brim = $config->brim_width > 0;
-    # perimeter_extruder uses the same logic as in Print::extruders()
-    $self->get_field('perimeter_extruder')->toggle($have_perimeters || $have_brim);
-    
-    my $have_raft = $config->raft_layers > 0;
-    my $have_support_material = $config->support_material || $have_raft;
-    my $have_support_interface = $config->support_material_interface_layers > 0;
-    my $have_support_soluble = $have_support_material && $config->support_material_contact_distance == 0;
-    $self->get_field($_)->toggle($have_support_material)
-        for qw(support_material_threshold support_material_pattern support_material_with_sheath
-            support_material_spacing support_material_angle
-            support_material_interface_layers dont_support_bridges
-            support_material_extrusion_width support_material_contact_distance support_material_xy_spacing);
-    $self->get_field($_)->toggle($have_support_material && $have_support_interface)
-        for qw(support_material_interface_spacing support_material_interface_extruder
-            support_material_interface_speed support_material_interface_contact_loops);
-    $self->get_field('support_material_synchronize_layers')->toggle($have_support_soluble);
-
-    $self->get_field('perimeter_extrusion_width')->toggle($have_perimeters || $have_skirt || $have_brim);
-    $self->get_field('support_material_extruder')->toggle($have_support_material || $have_skirt);
-    $self->get_field('support_material_speed')->toggle($have_support_material || $have_brim || $have_skirt);
-    
-    my $have_sequential_printing = $config->complete_objects;
-    $self->get_field($_)->toggle($have_sequential_printing)
-        for qw(extruder_clearance_radius extruder_clearance_height);
-    
-    my $have_ooze_prevention = $config->ooze_prevention;
-    $self->get_field($_)->toggle($have_ooze_prevention)
-        for qw(standby_temperature_delta);
-
-    my $have_wipe_tower = $config->wipe_tower;
-    $self->get_field($_)->toggle($have_wipe_tower)
-        for qw(wipe_tower_x wipe_tower_y wipe_tower_width wipe_tower_per_color_wipe wipe_tower_rotation_angle);
-
-    $self->Thaw;
-}
-
-package Slic3r::GUI::Tab::Filament;
-use base 'Slic3r::GUI::Tab';
-use Wx qw(wxTheApp);
-
-sub name { 'filament' }
-sub title { 'Filament Settings' }
-
-sub build {
-    my $self = shift;
-    
-    $self->{presets} = wxTheApp->{preset_bundle}->filament;
-    $self->{config} = $self->{presets}->get_edited_preset->config;
-    
-    {
-        my $page = $self->add_options_page('Filament', 'spool.png');
-        {
-            my $optgroup = $page->new_optgroup('Filament');
-            $optgroup->append_single_option_line('filament_colour', 0);
-            $optgroup->append_single_option_line('filament_diameter', 0);
-            $optgroup->append_single_option_line('extrusion_multiplier', 0);
-            $optgroup->append_single_option_line('filament_density', 0);
-            $optgroup->append_single_option_line('filament_cost', 0);
-        }
-    
-        {
-            my $optgroup = $page->new_optgroup('Temperature (°C)');
-        
-            {
-                my $line = Slic3r::GUI::OptionsGroup::Line->new(
-                    label => 'Extruder',
-                );
-                $line->append_option($optgroup->get_option('first_layer_temperature', 0));
-                $line->append_option($optgroup->get_option('temperature', 0));
-                $optgroup->append_line($line);
-            }
-        
-            {
-                my $line = Slic3r::GUI::OptionsGroup::Line->new(
-                    label => 'Bed',
-                );
-                $line->append_option($optgroup->get_option('first_layer_bed_temperature', 0));
-                $line->append_option($optgroup->get_option('bed_temperature', 0));
-                $optgroup->append_line($line);
-            }
-        }
-    }
-    
-    {
-        my $page = $self->add_options_page('Cooling', 'hourglass.png');
-        {
-            my $optgroup = $page->new_optgroup('Enable');
-            $optgroup->append_single_option_line('fan_always_on', 0);
-            $optgroup->append_single_option_line('cooling', 0);
-            
-            my $line = Slic3r::GUI::OptionsGroup::Line->new(
-                label       => '',
-                full_width  => 1,
-                widget      => sub {
-                    my ($parent) = @_;
-                    return $self->{cooling_description_line} = Slic3r::GUI::OptionsGroup::StaticText->new($parent);
-                },
-            );
-            $optgroup->append_line($line);
-        }
-        {
-            my $optgroup = $page->new_optgroup('Fan settings');
-            
-            {
-                my $line = Slic3r::GUI::OptionsGroup::Line->new(
-                    label => 'Fan speed',
-                );
-                $line->append_option($optgroup->get_option('min_fan_speed', 0));
-                $line->append_option($optgroup->get_option('max_fan_speed', 0));
-                $optgroup->append_line($line);
-            }
-            
-            $optgroup->append_single_option_line('bridge_fan_speed', 0);
-            $optgroup->append_single_option_line('disable_fan_first_layers', 0);
-        }
-        {
-            my $optgroup = $page->new_optgroup('Cooling thresholds',
-                label_width => 250,
-            );
-            $optgroup->append_single_option_line('fan_below_layer_time', 0);
-            $optgroup->append_single_option_line('slowdown_below_layer_time', 0);
-            $optgroup->append_single_option_line('min_print_speed', 0);
-        }
-    }
-
-    {
-        my $page = $self->add_options_page('Advanced', 'wrench.png');
-        {
-            my $optgroup = $page->new_optgroup('Filament properties');
-            $optgroup->append_single_option_line('filament_type', 0);
-            $optgroup->append_single_option_line('filament_soluble', 0);
-            
-            $optgroup = $page->new_optgroup('Print speed override');
-            $optgroup->append_single_option_line('filament_max_volumetric_speed', 0);
-
-            my $line = Slic3r::GUI::OptionsGroup::Line->new(
-                label       => '',
-                full_width  => 1,
-                widget      => sub {
-                    my ($parent) = @_;
-                    return $self->{volumetric_speed_description_line} = Slic3r::GUI::OptionsGroup::StaticText->new($parent);
-                },
-            );
-            $optgroup->append_line($line);
-        }
-    }
-
-    {
-        my $page = $self->add_options_page('Custom G-code', 'cog.png');
-        {
-            my $optgroup = $page->new_optgroup('Start G-code',
-                label_width => 0,
-            );
-            my $option = $optgroup->get_option('start_filament_gcode', 0);
-            $option->full_width(1);
-            $option->height(150);
-            $optgroup->append_single_option_line($option);
-        }
-        {
-            my $optgroup = $page->new_optgroup('End G-code',
-                label_width => 0,
-            );
-            my $option = $optgroup->get_option('end_filament_gcode', 0);
-            $option->full_width(1);
-            $option->height(150);
-            $optgroup->append_single_option_line($option);
-        }
-    }
-    
-    {
-        my $page = $self->add_options_page('Notes', 'note.png');
-        {
-            my $optgroup = $page->new_optgroup('Notes',
-                label_width => 0,
-            );
-            my $option = $optgroup->get_option('filament_notes', 0);
-            $option->full_width(1);
-            $option->height(250);
-            $optgroup->append_single_option_line($option);
-        }
-    }
-
-    {
-        my $page = $self->add_options_page('Dependencies', 'wrench.png');
-        {
-            my $optgroup = $page->new_optgroup('Profile dependencies');
-            {
-                my $line = Slic3r::GUI::OptionsGroup::Line->new(
-                    label       => 'Compatible printers',
-                    widget      => $self->_compatible_printers_widget,
-                );
-                $optgroup->append_line($line);
-
-                my $option = $optgroup->get_option('compatible_printers_condition');
-                $option->full_width(1);
-                $optgroup->append_single_option_line($option);
-            }
-        }
-    }
-}
-
-# Reload current $self->{config} (aka $self->{presets}->edited_preset->config) into the UI fields.
-sub _reload_config {
-    my ($self) = @_;
-    $self->_reload_compatible_printers_widget;
-    $self->SUPER::_reload_config;
-}
-
-# Slic3r::GUI::Tab::Filament::_update is called after a configuration preset is loaded or switched, or when a single option is modifed by the user.
-sub _update {
-    my ($self) = @_;
-    
-    $self->{cooling_description_line}->SetText(
-        Slic3r::GUI::PresetHints::cooling_description($self->{presets}->get_edited_preset));
-    $self->{volumetric_speed_description_line}->SetText(
-        Slic3r::GUI::PresetHints::maximum_volumetric_flow_description(wxTheApp->{preset_bundle}));
-    
-    my $cooling = $self->{config}->cooling->[0];
-    my $fan_always_on = $cooling || $self->{config}->fan_always_on->[0];
-    $self->get_field($_, 0)->toggle($cooling)
-        for qw(max_fan_speed fan_below_layer_time slowdown_below_layer_time min_print_speed);
-    $self->get_field($_, 0)->toggle($fan_always_on)
-        for qw(min_fan_speed disable_fan_first_layers);
-}
-
-sub OnActivate {
-    my ($self) = @_;
-    $self->{volumetric_speed_description_line}->SetText(
-        Slic3r::GUI::PresetHints::maximum_volumetric_flow_description(wxTheApp->{preset_bundle}));
-}
-
-package Slic3r::GUI::Tab::Printer;
-use base 'Slic3r::GUI::Tab';
-use Wx qw(wxTheApp :sizer :button :bitmap :misc :id :icon :dialog);
-use Wx::Event qw(EVT_BUTTON);
-
-sub name { 'printer' }
-sub title { 'Printer Settings' }
-
-sub build {
-    my ($self, %params) = @_;
-    
-    $self->{presets} = wxTheApp->{preset_bundle}->printer;
-    $self->{config} = $self->{presets}->get_edited_preset->config;
-    $self->{extruders_count} = scalar @{$self->{config}->nozzle_diameter};
-
-    my $bed_shape_widget = sub {
-        my ($parent) = @_;
-        
-        my $btn = Wx::Button->new($parent, -1, "Set…", wxDefaultPosition, wxDefaultSize,
-            wxBU_LEFT | wxBU_EXACTFIT);
-        $btn->SetFont($Slic3r::GUI::small_font);
-        $btn->SetBitmap(Wx::Bitmap->new(Slic3r::var("printer_empty.png"), wxBITMAP_TYPE_PNG));
-        
-        my $sizer = Wx::BoxSizer->new(wxHORIZONTAL);
-        $sizer->Add($btn);
-        
-        EVT_BUTTON($self, $btn, sub {
-            my $dlg = Slic3r::GUI::BedShapeDialog->new($self, $self->{config}->bed_shape);
-            $self->_load_key_value('bed_shape', $dlg->GetValue) if $dlg->ShowModal == wxID_OK;
-        });
-        
-        return $sizer;
-    };
-        
-    {
-        my $page = $self->add_options_page('General', 'printer_empty.png');
-        {
-            my $optgroup = $page->new_optgroup('Size and coordinates');
-            
-            my $line = Slic3r::GUI::OptionsGroup::Line->new(
-                label       => 'Bed shape',
-                widget      => $bed_shape_widget,
-            );
-            $optgroup->append_line($line);
-            
-            $optgroup->append_single_option_line('z_offset');
-        }
-        {
-            my $optgroup = $page->new_optgroup('Capabilities');
-            {
-                my $option = Slic3r::GUI::OptionsGroup::Option->new(
-                    opt_id      => 'extruders_count',
-                    type        => 'i',
-                    default     => 1,
-                    label       => 'Extruders',
-                    tooltip     => 'Number of extruders of the printer.',
-                    min         => 1,
-                );
-                $optgroup->append_single_option_line($option);
-                $optgroup->append_single_option_line('single_extruder_multi_material');
-            }
-            $optgroup->on_change(sub {
-                my ($opt_key, $value) = @_;
-                wxTheApp->CallAfter(sub {
-                    if ($opt_key eq 'extruders_count') {
-                        $self->_extruders_count_changed($optgroup->get_value('extruders_count'));
-                        $self->update_dirty;
-                    } else {
-                        $self->update_dirty;
-                        $self->_on_value_change($opt_key, $value);
-                    }
-                });
-            });
-        }
-        if (!$params{no_controller})
-        {
-            my $optgroup = $page->new_optgroup('USB/Serial connection');
-            my $line = Slic3r::GUI::OptionsGroup::Line->new(
-                label => 'Serial port',
-            );
-            my $serial_port = $optgroup->get_option('serial_port');
-            $serial_port->side_widget(sub {
-                my ($parent) = @_;
-                
-                my $btn = Wx::BitmapButton->new($parent, -1, Wx::Bitmap->new(Slic3r::var("arrow_rotate_clockwise.png"), wxBITMAP_TYPE_PNG),
-                    wxDefaultPosition, wxDefaultSize, &Wx::wxBORDER_NONE);
-                $btn->SetToolTipString("Rescan serial ports")
-                    if $btn->can('SetToolTipString');
-                EVT_BUTTON($self, $btn, \&_update_serial_ports);
-                
-                return $btn;
-            });
-            my $serial_test = sub {
-                my ($parent) = @_;
-                
-                my $btn = $self->{serial_test_btn} = Wx::Button->new($parent, -1,
-                    "Test", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
-                $btn->SetFont($Slic3r::GUI::small_font);
-                $btn->SetBitmap(Wx::Bitmap->new(Slic3r::var("wrench.png"), wxBITMAP_TYPE_PNG));
-                
-                EVT_BUTTON($self, $btn, sub {
-                    my $sender = Slic3r::GCode::Sender->new;
-                    my $res = $sender->connect(
-                        $self->{config}->serial_port,
-                        $self->{config}->serial_speed,
-                    );
-                    if ($res && $sender->wait_connected) {
-                        Slic3r::GUI::show_info($self, "Connection to printer works correctly.", "Success!");
-                    } else {
-                        Slic3r::GUI::show_error($self, "Connection failed.");
-                    }
-                });
-                return $btn;
-            };
-            $line->append_option($serial_port);
-            $line->append_option($optgroup->get_option('serial_speed'));
-            $line->append_widget($serial_test);
-            $optgroup->append_line($line);
-        }
-        {
-            my $optgroup = $page->new_optgroup('OctoPrint upload');
-            
-            # append two buttons to the Host line
-            my $octoprint_host_browse = sub {
-                my ($parent) = @_;
-                
-                my $btn = Wx::Button->new($parent, -1, "Browse…", wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
-                $btn->SetFont($Slic3r::GUI::small_font);
-                $btn->SetBitmap(Wx::Bitmap->new(Slic3r::var("zoom.png"), wxBITMAP_TYPE_PNG));
-                
-                if (!eval "use Net::Bonjour; 1") {
-                    $btn->Disable;
-                }
-                
-                EVT_BUTTON($self, $btn, sub {
-                    # look for devices
-                    my $entries;
-                    {
-                        my $res = Net::Bonjour->new('http');
-                        $res->discover;
-                        $entries = [ $res->entries ];
-                    }
-                    if (@{$entries}) {
-                        my $dlg = Slic3r::GUI::BonjourBrowser->new($self, $entries);
-                        $self->_load_key_value('octoprint_host', $dlg->GetValue . ":" . $dlg->GetPort)
-                            if $dlg->ShowModal == wxID_OK;
-                    } else {
-                        Wx::MessageDialog->new($self, 'No Bonjour device found', 'Device Browser', wxOK | wxICON_INFORMATION)->ShowModal;
-                    }
-                });
-                
-                return $btn;
-            };
-            my $octoprint_host_test = sub {
-                my ($parent) = @_;
-                
-                my $btn = $self->{octoprint_host_test_btn} = Wx::Button->new($parent, -1,
-                    "Test", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
-                $btn->SetFont($Slic3r::GUI::small_font);
-                $btn->SetBitmap(Wx::Bitmap->new(Slic3r::var("wrench.png"), wxBITMAP_TYPE_PNG));
-                
-                EVT_BUTTON($self, $btn, sub {
-                    my $ua = LWP::UserAgent->new;
-                    $ua->timeout(10);
-    
-                    my $res = $ua->get(
-                        "http://" . $self->{config}->octoprint_host . "/api/version",
-                        'X-Api-Key' => $self->{config}->octoprint_apikey,
-                    );
-                    if ($res->is_success) {
-                        Slic3r::GUI::show_info($self, "Connection to OctoPrint works correctly.", "Success!");
-                    } else {
-                        Slic3r::GUI::show_error($self,
-                            "I wasn't able to connect to OctoPrint (" . $res->status_line . "). "
-                            . "Check hostname and OctoPrint version (at least 1.1.0 is required).");
-                    }
-                });
-                return $btn;
-            };
-            
-            my $host_line = $optgroup->create_single_option_line('octoprint_host');
-            $host_line->append_widget($octoprint_host_browse);
-            $host_line->append_widget($octoprint_host_test);
-            $optgroup->append_line($host_line);
-            $optgroup->append_single_option_line('octoprint_apikey');
-        }
-        {
-            my $optgroup = $page->new_optgroup('Firmware');
-            $optgroup->append_single_option_line('gcode_flavor');
-        }
-        {
-            my $optgroup = $page->new_optgroup('Advanced');
-            $optgroup->append_single_option_line('use_relative_e_distances');
-            $optgroup->append_single_option_line('use_firmware_retraction');
-            $optgroup->append_single_option_line('use_volumetric_e');
-            $optgroup->append_single_option_line('variable_layer_height');
-        }
-    }
-    {
-        my $page = $self->add_options_page('Custom G-code', 'cog.png');
-        {
-            my $optgroup = $page->new_optgroup('Start G-code',
-                label_width => 0,
-            );
-            my $option = $optgroup->get_option('start_gcode');
-            $option->full_width(1);
-            $option->height(150);
-            $optgroup->append_single_option_line($option);
-        }
-        {
-            my $optgroup = $page->new_optgroup('End G-code',
-                label_width => 0,
-            );
-            my $option = $optgroup->get_option('end_gcode');
-            $option->full_width(1);
-            $option->height(150);
-            $optgroup->append_single_option_line($option);
-        }
-        {
-            my $optgroup = $page->new_optgroup('Before layer change G-code',
-                label_width => 0,
-            );
-            my $option = $optgroup->get_option('before_layer_gcode');
-            $option->full_width(1);
-            $option->height(150);
-            $optgroup->append_single_option_line($option);
-        }
-        {
-            my $optgroup = $page->new_optgroup('After layer change G-code',
-                label_width => 0,
-            );
-            my $option = $optgroup->get_option('layer_gcode');
-            $option->full_width(1);
-            $option->height(150);
-            $optgroup->append_single_option_line($option);
-        }
-        {
-            my $optgroup = $page->new_optgroup('Tool change G-code',
-                label_width => 0,
-            );
-            my $option = $optgroup->get_option('toolchange_gcode');
-            $option->full_width(1);
-            $option->height(150);
-            $optgroup->append_single_option_line($option);
-        }
-        {
-            my $optgroup = $page->new_optgroup('Between objects G-code (for sequential printing)',
-                label_width => 0,
-            );
-            my $option = $optgroup->get_option('between_objects_gcode');
-            $option->full_width(1);
-            $option->height(150);
-            $optgroup->append_single_option_line($option);
-        }
-    }
-    
-    {
-        my $page = $self->add_options_page('Notes', 'note.png');
-        {
-            my $optgroup = $page->new_optgroup('Notes',
-                label_width => 0,
-            );
-            my $option = $optgroup->get_option('printer_notes');
-            $option->full_width(1);
-            $option->height(250);
-            $optgroup->append_single_option_line($option);
-        }
-    }
-
-    $self->{extruder_pages} = [];
-    $self->_build_extruder_pages;
-
-    $self->_update_serial_ports if (!$params{no_controller});
-}
-
-sub _update_serial_ports {
-    my ($self) = @_;
-    
-    $self->get_field('serial_port')->set_values([ Slic3r::GUI::scan_serial_ports ]);
-}
-
-sub _extruders_count_changed {
-    my ($self, $extruders_count) = @_;
-    $self->{extruders_count} = $extruders_count;
-    wxTheApp->{preset_bundle}->printer->get_edited_preset->set_num_extruders($extruders_count);
-    wxTheApp->{preset_bundle}->update_multi_material_filament_presets;
-    $self->_build_extruder_pages;
-    $self->_on_value_change('extruders_count', $extruders_count);
-}
-
-sub _build_extruder_pages {
-    my ($self) = @_;    
-    my $default_config = Slic3r::Config::Full->new;
-
-    foreach my $extruder_idx (@{$self->{extruder_pages}} .. $self->{extruders_count}-1) {
-        # build page
-        my $page = $self->{extruder_pages}[$extruder_idx] = $self->add_options_page("Extruder " . ($extruder_idx + 1), 'funnel.png');
-        {
-            my $optgroup = $page->new_optgroup('Size');
-            $optgroup->append_single_option_line('nozzle_diameter', $extruder_idx);
-        }
-        {
-            my $optgroup = $page->new_optgroup('Layer height limits');
-            $optgroup->append_single_option_line($_, $extruder_idx)
-                for qw(min_layer_height max_layer_height);
-        }
-        {
-            my $optgroup = $page->new_optgroup('Position (for multi-extruder printers)');
-            $optgroup->append_single_option_line('extruder_offset', $extruder_idx);
-        }
-        {
-            my $optgroup = $page->new_optgroup('Retraction');
-            $optgroup->append_single_option_line($_, $extruder_idx)
-                for qw(retract_length retract_lift);
-            
-            {
-                my $line = Slic3r::GUI::OptionsGroup::Line->new(
-                    label => 'Only lift Z',
-                );
-                $line->append_option($optgroup->get_option('retract_lift_above', $extruder_idx));
-                $line->append_option($optgroup->get_option('retract_lift_below', $extruder_idx));
-                $optgroup->append_line($line);
-            }
-            
-            $optgroup->append_single_option_line($_, $extruder_idx)
-                for qw(retract_speed deretract_speed retract_restart_extra retract_before_travel retract_layer_change wipe retract_before_wipe);
-        }
-        {
-            my $optgroup = $page->new_optgroup('Retraction when tool is disabled (advanced settings for multi-extruder setups)');
-            $optgroup->append_single_option_line($_, $extruder_idx)
-                for qw(retract_length_toolchange retract_restart_extra_toolchange);
-        }
-        {
-            my $optgroup = $page->new_optgroup('Preview');
-            $optgroup->append_single_option_line('extruder_colour', $extruder_idx);
-        }
-    }
-    
-    # remove extra pages
-    if ($self->{extruders_count} <= $#{$self->{extruder_pages}}) {
-        $_->Destroy for @{$self->{extruder_pages}}[$self->{extruders_count}..$#{$self->{extruder_pages}}];
-        splice @{$self->{extruder_pages}}, $self->{extruders_count};
-    }
-    
-    # rebuild page list
-    my @pages_without_extruders = (grep $_->{title} !~ /^Extruder \d+/, @{$self->{pages}});
-    my $page_notes = pop @pages_without_extruders;
-    @{$self->{pages}} = (
-        @pages_without_extruders,
-        @{$self->{extruder_pages}}[ 0 .. $self->{extruders_count}-1 ],
-        $page_notes
-    );
-    $self->rebuild_page_tree;
-}
-
-# Slic3r::GUI::Tab::Printer::_update is called after a configuration preset is loaded or switched, or when a single option is modifed by the user.
-sub _update {
-    my ($self) = @_;
-    $self->Freeze;
-
-    my $config = $self->{config};
-    
-    my $serial_speed = $self->get_field('serial_speed');
-    if ($serial_speed) {
-        $self->get_field('serial_speed')->toggle($config->get('serial_port'));
-        if ($config->get('serial_speed') && $config->get('serial_port')) {
-            $self->{serial_test_btn}->Enable;
-        } else {
-            $self->{serial_test_btn}->Disable;
-        }
-    }
-    if ($config->get('octoprint_host') && eval "use LWP::UserAgent; 1") {
-        $self->{octoprint_host_test_btn}->Enable;
-    } else {
-        $self->{octoprint_host_test_btn}->Disable;
-    }
-    $self->get_field('octoprint_apikey')->toggle($config->get('octoprint_host'));
-    
-    my $have_multiple_extruders = $self->{extruders_count} > 1;
-    $self->get_field('toolchange_gcode')->toggle($have_multiple_extruders);
-    $self->get_field('single_extruder_multi_material')->toggle($have_multiple_extruders);
-    
-    for my $i (0 .. ($self->{extruders_count}-1)) {
-        my $have_retract_length = $config->get_at('retract_length', $i) > 0;
-        
-        # when using firmware retraction, firmware decides retraction length
-        $self->get_field('retract_length', $i)->toggle(!$config->use_firmware_retraction);
-        
-        # user can customize travel length if we have retraction length or we're using
-        # firmware retraction
-        $self->get_field('retract_before_travel', $i)->toggle($have_retract_length || $config->use_firmware_retraction);
-        
-        # user can customize other retraction options if retraction is enabled
-        my $retraction = ($have_retract_length || $config->use_firmware_retraction);
-        $self->get_field($_, $i)->toggle($retraction)
-            for qw(retract_lift retract_layer_change);
-        
-        # retract lift above/below only applies if using retract lift
-        $self->get_field($_, $i)->toggle($retraction && $config->get_at('retract_lift', $i) > 0)
-            for qw(retract_lift_above retract_lift_below);
-        
-        # some options only apply when not using firmware retraction
-        $self->get_field($_, $i)->toggle($retraction && !$config->use_firmware_retraction)
-            for qw(retract_speed deretract_speed retract_before_wipe retract_restart_extra wipe);
-
-        my $wipe = $config->get_at('wipe', $i);
-        $self->get_field('retract_before_wipe', $i)->toggle($wipe);
-
-        if ($config->use_firmware_retraction && $wipe) {
-            my $dialog = Wx::MessageDialog->new($self,
-                "The Wipe option is not available when using the Firmware Retraction mode.\n"
-                . "\nShall I disable it in order to enable Firmware Retraction?",
-                'Firmware Retraction', wxICON_WARNING | wxYES | wxNO);
-            
-            my $new_conf = Slic3r::Config->new;
-            if ($dialog->ShowModal() == wxID_YES) {
-                my $wipe = $config->wipe;
-                $wipe->[$i] = 0;
-                $new_conf->set("wipe", $wipe);
-            } else {
-                $new_conf->set("use_firmware_retraction", 0);
-            }
-            $self->load_config($new_conf);
-        }
-        
-        $self->get_field('retract_length_toolchange', $i)->toggle($have_multiple_extruders);
-        
-        my $toolchange_retraction = $config->get_at('retract_length_toolchange', $i) > 0;
-        $self->get_field('retract_restart_extra_toolchange', $i)->toggle
-            ($have_multiple_extruders && $toolchange_retraction);
-    }
-
-    $self->Thaw;
-}
-
-# this gets executed after preset is loaded and before GUI fields are updated
-sub on_preset_loaded {
-    my ($self) = @_;
-    # update the extruders count field
-    my $extruders_count = scalar @{ $self->{config}->nozzle_diameter };
-    $self->set_value('extruders_count', $extruders_count);
-    # update the GUI field according to the number of nozzle diameters supplied
-    $self->_extruders_count_changed($extruders_count);
-}
-
-# Single Tab page containing a {vsizer} of {optgroups}
-package Slic3r::GUI::Tab::Page;
-use Wx qw(wxTheApp :misc :panel :sizer);
-use base 'Wx::ScrolledWindow';
-
-sub new {
-    my ($class, $parent, $title, $iconID) = @_;
-    my $self = $class->SUPER::new($parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
-    $self->{optgroups}  = [];
-    $self->{title}      = $title;
-    $self->{iconID}     = $iconID;
-    
-    $self->SetScrollbars(1, 1, 1, 1);
-    
-    $self->{vsizer} = Wx::BoxSizer->new(wxVERTICAL);
-    $self->SetSizer($self->{vsizer});
-    
-    return $self;
-}
-
-sub new_optgroup {
-    my ($self, $title, %params) = @_;
-    
-    my $optgroup = Slic3r::GUI::ConfigOptionsGroup->new(
-        parent          => $self,
-        title           => $title,
-        config          => $self->GetParent->{config},
-        label_width     => $params{label_width} // 200,
-        on_change       => sub {
-            my ($opt_key, $value) = @_;
-            wxTheApp->CallAfter(sub {
-                $self->GetParent->update_dirty;
-                $self->GetParent->_on_value_change($opt_key, $value);
-            });
-        },
-    );
-    
-    push @{$self->{optgroups}}, $optgroup;
-    $self->{vsizer}->Add($optgroup->sizer, 0, wxEXPAND | wxALL, 10);
-    
-    return $optgroup;
-}
-
-sub reload_config {
-    my ($self) = @_;
-    $_->reload_config for @{$self->{optgroups}};
-}
-
-sub get_field {
-    my ($self, $opt_key, $opt_index) = @_;
-    foreach my $optgroup (@{ $self->{optgroups} }) {
-        my $field = $optgroup->get_fieldc($opt_key, $opt_index);
-        return $field if defined $field;
-    }
-    return undef;
-}
-
-sub set_value {
-    my ($self, $opt_key, $value) = @_;    
-    my $changed = 0;
-    foreach my $optgroup (@{$self->{optgroups}}) {
-        $changed = 1 if $optgroup->set_value($opt_key, $value);
-    }
-    return $changed;
-}
-
-# Dialog to select a new file name for a modified preset to be saved.
-# Called from Tab::save_preset().
-package Slic3r::GUI::SavePresetWindow;
-use Wx qw(:combobox :dialog :id :misc :sizer);
-use Wx::Event qw(EVT_BUTTON EVT_TEXT_ENTER);
-use base 'Wx::Dialog';
-
-sub new {
-    my ($class, $parent, %params) = @_;
-    my $self = $class->SUPER::new($parent, -1, "Save preset", wxDefaultPosition, wxDefaultSize);
-    
-    my @values = @{$params{values}};
-    
-    my $text = Wx::StaticText->new($self, -1, "Save " . lc($params{title}) . " as:", wxDefaultPosition, wxDefaultSize);
-    $self->{combo} = Wx::ComboBox->new($self, -1, $params{default}, wxDefaultPosition, wxDefaultSize, \@values,
-                                       wxTE_PROCESS_ENTER);
-    my $buttons = $self->CreateStdDialogButtonSizer(wxOK | wxCANCEL);
-    
-    my $sizer = Wx::BoxSizer->new(wxVERTICAL);
-    $sizer->Add($text, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 10);
-    $sizer->Add($self->{combo}, 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
-    $sizer->Add($buttons, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
-    
-    EVT_BUTTON($self, wxID_OK, \&accept);
-    EVT_TEXT_ENTER($self, $self->{combo}, \&accept);
-    
-    $self->SetSizer($sizer);
-    $sizer->SetSizeHints($self);
-    
-    return $self;
-}
-
-sub accept {
-    my ($self, $event) = @_;
-    if (($self->{chosen_name} = Slic3r::normalize_utf8_nfc($self->{combo}->GetValue))) {
-        if ($self->{chosen_name} !~ /^[^<>:\/\\|?*\"]+$/) {
-            Slic3r::GUI::show_error($self, "The supplied name is not valid; the following characters are not allowed: <>:/\|?*\"");
-        } elsif ($self->{chosen_name} eq '- default -') {
-            Slic3r::GUI::show_error($self, "The supplied name is not available.");
-        } else {
-            $self->EndModal(wxID_OK);
-        }
-    }
-}
-
-sub get_name {
-    my ($self) = @_;
-    return $self->{chosen_name};
-}
-
-1;
diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm
index 12ad2f12f..8300fdbed 100644
--- a/lib/Slic3r/Print.pm
+++ b/lib/Slic3r/Print.pm
@@ -81,13 +81,20 @@ sub export_gcode {
     $self->status_cb->(90, "Exporting G-code" . ($output_file ? " to $output_file" : ""));
 
     # The following line may die for multiple reasons.
-    Slic3r::GCode->new->do_export($self, $output_file);
+    my $gcode = Slic3r::GCode->new;
+    if (defined $params{gcode_preview_data}) {
+        $gcode->do_export_w_preview($self, $output_file, $params{gcode_preview_data});
+    } else {
+        $gcode->do_export($self, $output_file);
+    }
     
     # run post-processing scripts
     if (@{$self->config->post_process}) {
         $self->status_cb->(95, "Running post-processing scripts");
         $self->config->setenv;
         for my $script (@{$self->config->post_process}) {
+            # Ignore empty post processing script lines.
+            next if $script =~ /^\s*$/;
             Slic3r::debugf "  '%s' '%s'\n", $script, $output_file;
             # -x doesn't return true on Windows except for .exe files
             if (($^O eq 'MSWin32') ? !(-e $script) : !(-x $script)) {
diff --git a/resources/localization/cs_CZ/Slic3rPE.mo b/resources/localization/cs_CZ/Slic3rPE.mo
new file mode 100644
index 000000000..9ddd8e3b1
Binary files /dev/null and b/resources/localization/cs_CZ/Slic3rPE.mo differ
diff --git a/resources/localization/cs_CZ/Slic3rPE_cs.po b/resources/localization/cs_CZ/Slic3rPE_cs.po
new file mode 100644
index 000000000..b6af76f35
--- /dev/null
+++ b/resources/localization/cs_CZ/Slic3rPE_cs.po
@@ -0,0 +1,2704 @@
+# Oleksandra Iushchenko <yusanka@gmail.com>, 2018.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: SLIC3R PE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2018-02-13 17:18+0100\n"
+"PO-Revision-Date: 2018-02-15 18:26+0100\n"
+"Last-Translator: Oleksandra Iushchenko <yusanka@gmail.com>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 2.0.6\n"
+"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
+"Language: cs_CZ\n"
+"X-Poedit-KeywordsList: _L\n"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:50
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1188
+msgid "Size"
+msgstr "Rozměr"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:51
+msgid "Size in X and Y of the rectangular plate."
+msgstr "Rozměr tiskové podložky v ose X a Y."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:57
+msgid "Origin"
+msgstr "Origin"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:58
+msgid ""
+"Distance of the 0,0 G-code coordinate from the front left corner of the "
+"rectangle."
+msgstr "Vzdálenost souřadnice 0,0 G-kódu od předního levého rohu obdélníku."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:65
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:133
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:204
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:215
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:329
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:340
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:359
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:438
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:783
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:803
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:862
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:880
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:898
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1046
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1054
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1096
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1105
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1115
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1123
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1131
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1217
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1423
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1493
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1529
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1706
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1713
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1720
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1729
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1739
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1749
+msgid "mm"
+msgstr "mm"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:66
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:435
+msgid "Diameter"
+msgstr "Průměr"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:67
+msgid ""
+"Diameter of the print bed. It is assumed that origin (0,0) is located in the "
+"center."
+msgstr ""
+"Průměr tiskové podložky.Přepokládaná souřadnice 0,0 je umístěna uprostřed."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:965
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:312
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:704
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:960
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1274
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1447
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1473
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:432
+msgid "Extruders"
+msgstr "Extrudér"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:966
+msgid "Number of extruders of the printer."
+msgstr "Počet extrudérů tiskárny."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:30
+msgid "Avoid crossing perimeters"
+msgstr "Vyhnout se přejíždění perimetrů"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:31
+msgid ""
+"Optimize travel moves in order to minimize the crossing of perimeters. This "
+"is mostly useful with Bowden extruders which suffer from oozing. This "
+"feature slows down both the print and the G-code generation."
+msgstr ""
+"Optimalizovat přesuny do pořadí aby se minimalizovalo přejíždění perimetrů. "
+"Nejvíce užitečné u Bowdenových extruderů které trpí na vytékáné filamentu. "
+"Toto nastavení zpomaluje tisk i generování G-kódu."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:38
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:939
+msgid "Bed shape"
+msgstr "Tvar tiskové podložky"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:42
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1574
+msgid "Other layers"
+msgstr "Ostatní vrstvy"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:43
+msgid ""
+"Bed temperature for layers after the first one. Set this to zero to disable "
+"bed temperature control commands in the output."
+msgstr ""
+"Teplota tiskové podložky pro další vrstvy po první vrstvě. Nastavením na "
+"hodnotu nula vypnete ovládací příkazy teploty tiskové podložky ve výstupu."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:46
+msgid "Bed temperature"
+msgstr "Teplota tiskové podložky"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:52
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1131
+msgid "Before layer change G-code"
+msgstr "Before layer change G-code"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:53
+msgid ""
+"This custom code is inserted at every layer change, right before the Z move. "
+"Note that you can use placeholder variables for all Slic3r settings as well "
+"as [layer_num] and [layer_z]."
+msgstr ""
+"Tento upravený kód je vložen pro každou změnu vrstvy, předtím než se pohne "
+"Z. Můžete přidávat zástupné proměnné pro veškeré nastavení Slic3ru stejně "
+"tak jako [layer_num] a [layer_z]."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:63
+msgid "Between objects G-code"
+msgstr "G-kód mezi objekty"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:64
+msgid ""
+"This code is inserted between objects when using sequential printing. By "
+"default extruder and bed temperature are reset using non-wait command; "
+"however if M104, M109, M140 or M190 are detected in this custom code, Slic3r "
+"will not add temperature commands. Note that you can use placeholder "
+"variables for all Slic3r settings, so you can put a \"M109 "
+"S[first_layer_temperature]\" command wherever you want."
+msgstr ""
+"Tento kód je vložen mezi objekty, pokud je použit sekvenční tisk. Ve "
+"výchozím nastavení je resetován extrudér a tisková podložka pomocí non-wait "
+"(nečekacím) příkazem; nicméně pokud jsou příkazy M104, M109, 140 nebo M190 "
+"detekovány v tomto upraveném kódu, Slic3r nebude přidávat teplotní příkazy. "
+"Můžete přidávat zástupné proměnné pro veškeré nastavení Slic3ru, takže "
+"můžete vložit příkaz “M109 S[first_layer_temperature]” kamkoliv chcete."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:72
+msgid "Bottom"
+msgstr "Spodek"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:73
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:243
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:294
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:302
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:606
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:764
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:780
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:943
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:991
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1154
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1585
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1641
+msgid "Layers and Perimeters"
+msgstr "Vrstvy a perimetry"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:74
+msgid "Number of solid layers to generate on bottom surfaces."
+msgstr "Počet plných vrstev."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:76
+msgid "Bottom solid layers"
+msgstr "Plné spodní vrstvy"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:81
+msgid "Bridge"
+msgstr "Most"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:82
+msgid ""
+"This is the acceleration your printer will use for bridges. Set zero to "
+"disable acceleration control for bridges."
+msgstr ""
+"Nastavení akcelerace tiskárny při vytváření mostů. Nastavením na nulu "
+"vypnete ovládání akcelerace pro mosty."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:84
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:178
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:578
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:686
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:954
+msgid "mm/s\\u00B2"
+msgstr "mm/s\\u00B2"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:90
+msgid "Bridging angle"
+msgstr "Úhel vytváření mostů"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:91
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:251
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:492
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:506
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:544
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:683
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:693
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:711
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:729
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:748
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1265
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1282
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:347
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:348
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:664
+msgid "Infill"
+msgstr "Výplň"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:92
+msgid ""
+"Bridging angle override. If left to zero, the bridging angle will be "
+"calculated automatically. Otherwise the provided angle will be used for all "
+"bridges. Use 180\\u00B0 for zero angle."
+msgstr ""
+"Přepsání úhlu vytváření mostů. Nastavením hodnoty na nulu se bude úhel "
+"vytváření mostů vypočítávat automaticky. Při zadání jiného úhlu, bude pro "
+"všechny mosty použitý zadaný úhel. Pro nulový úhel zadejte 180\\u00B0."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:95
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:496
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1172
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1183
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1403
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1559
+msgid "\\u00B0"
+msgstr "\\u00B0"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:101
+msgid "Bridges fan speed"
+msgstr "Rychlost ventilátoru při vytváření mostů"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:102
+msgid "This fan speed is enforced during all bridges and overhangs."
+msgstr ""
+"Nastavená rychlost ventilátoru je využita vždy při vytváření mostů a přesahů."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:103
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:508
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:791
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:852
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1062
+msgid "%"
+msgstr "%"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:110
+msgid "Bridge flow ratio"
+msgstr "Poměr průtoku při vytváření mostů"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:111
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:212
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:738
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1735
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:343
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:357
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:450
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:453
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:830
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1112
+msgid "Advanced"
+msgstr "Pokročilé"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:112
+msgid ""
+"This factor affects the amount of plastic for bridging. You can decrease it "
+"slightly to pull the extrudates and prevent sagging, although default "
+"settings are usually good and you should experiment with cooling (use a fan) "
+"before tweaking this."
+msgstr ""
+"Tato hodnota určuje množství vytlačeného plastu při vytváření mostů. Mírným "
+"šnížením této hodnoty můžete předejít pronášení ikdyž, přednastavené hodnoty "
+"jsou většinou dobré a je lepší experimentovat s chlazením (využitím "
+"ventilátoru), než s touto hodnotou."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:121
+msgid "Bridges"
+msgstr "Mosty"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:122
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:282
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:637
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:749
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:981
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1203
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1253
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1304
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1627
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:399
+msgid "Speed"
+msgstr "Rychlost"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:123
+msgid "Speed for printing bridges."
+msgstr "Rychlost pro vytváření mostů."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:124
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:640
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:751
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:813
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:870
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:983
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1139
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1148
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1538
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1651
+msgid "mm/s"
+msgstr "mm/s"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:131
+msgid "Brim width"
+msgstr "Okraj první vrstvy"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:132
+msgid ""
+"Horizontal width of the brim that will be printed around each object on the "
+"first layer."
+msgstr "Šírka okraje první vrsty která bude vytištěna okolo každého objektu."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:139
+msgid "Clip multi-part objects"
+msgstr "Připnutí objektů z více částí k sobě"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:140
+msgid ""
+"When printing multi-material objects, this settings will make slic3r to clip "
+"the overlapping object parts one by the other (2nd part will be clipped by "
+"the 1st, 3rd part will be clipped by the 1st and 2nd etc)."
+msgstr ""
+"Připnutí překrývajících se objektů jednek druhému při multi-materiálovém "
+"tisku. (Druhá část se připne k první, třetí část k první a druhé, atd)."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:147
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:510
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:868
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1673
+msgid "Compatible printers"
+msgstr "Kompatibilní tiskárny"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:151
+msgid "Compatible printers condition"
+msgstr "Stav kompatibilních tiskáren"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:152
+msgid ""
+"A boolean expression using the configuration values of an active printer "
+"profile. If this expression evaluates to true, this profile is considered "
+"compatible with the active printer profile."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:158
+msgid "Complete individual objects"
+msgstr "Dokončení individuálních objektů"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:159
+msgid ""
+"When printing multiple objects or copies, this feature will complete each "
+"object before moving onto next one (and starting it from its bottom layer). "
+"This feature is useful to avoid the risk of ruined prints. Slic3r should "
+"warn and prevent you from extruder collisions, but beware."
+msgstr ""
+"Při tisku více objektů nebo kopií tiskárna kompletně dokončí jeden objekt, "
+"předtím než začne tisknout druhý (začíná od spodní vstvy). Tato vlastnost je "
+"výhodná z důvodů snížení rizika zničených výtisků. Slic3r by měl varovat při "
+"možné kolizi extrudéru s objektem a zabránit mu, přesto doporučujeme "
+"obezřetnost."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:167
+msgid "Enable auto cooling"
+msgstr "Zapnutí automatického chlazení"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:168
+msgid ""
+"This flag enables the automatic cooling logic that adjusts print speed and "
+"fan speed according to layer printing time."
+msgstr ""
+"Zapíná výpočet automatického chlazení který upravuje rychlost tisku a "
+"ventilátoru v závislosti na délce tisku jedné vstvy."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:174
+#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:293
+msgid "Default"
+msgstr "Výchozí"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:175
+msgid ""
+"This is the acceleration your printer will be reset to after the role-"
+"specific acceleration values are used (perimeter/infill). Set zero to "
+"prevent resetting acceleration at all."
+msgstr ""
+"Toto je hodnota akcelerace na kterou se tiskárna vrátí po specifických "
+"úpravách akcelerace například při tisku (perimetru/výplně). Nastavením na "
+"nulu zabráníte návratu rychlostí zcela."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:184
+msgid "Disable fan for the first"
+msgstr "Vypnutí chlazení pro prvních"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:185
+msgid ""
+"You can set this to a positive value to disable fan at all during the first "
+"layers, so that it does not make adhesion worse."
+msgstr ""
+"Nastavením počtu prvních vstev s vypnutým chlazením pro nezhoršování "
+"přilnavosti."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:187
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:696
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1035
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1226
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1287
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1439
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1484
+msgid "layers"
+msgstr "vrstev"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:194
+msgid "Don't support bridges"
+msgstr "Nevytvářet podpory pod mosty"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:195
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1032
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1382
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1389
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1401
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1411
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1419
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1434
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1455
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1466
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1482
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1491
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1500
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1511
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1527
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1535
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1536
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1545
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1553
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1567
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:375
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:376
+msgid "Support material"
+msgstr "Podpory"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:196
+msgid ""
+"Experimental option for preventing support material from being generated "
+"under bridged areas."
+msgstr ""
+"Experimentální nastavení pro zabránění tvorbě podpěr v oblastech po mosty."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:202
+msgid "Distance between copies"
+msgstr "Vzdálenost mezi kopiemi"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:203
+msgid "Distance used for the auto-arrange feature of the plater."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:211
+msgid "Elefant foot compensation"
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:213
+msgid ""
+"The first layer will be shrunk in the XY plane by the configured value to "
+"compensate for the 1st layer squish aka an Elefant Foot effect."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:221
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:231
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:852
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1125
+msgid "End G-code"
+msgstr "Konec G-code"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:222
+msgid ""
+"This end procedure is inserted at the end of the output file. Note that you "
+"can use placeholder variables for all Slic3r settings."
+msgstr ""
+"Tato ukončovací procedůra je vložena na konec výstupního souboru. Můžete "
+"přidávat zástupné proměnné pro veškeré nastavení Slic3ru."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:232
+msgid ""
+"This end procedure is inserted at the end of the output file, before the "
+"printer end gcode. Note that you can use placeholder variables for all "
+"Slic3r settings. If you have multiple extruders, the gcode is processed in "
+"extruder order."
+msgstr ""
+"Tato ukončovací procedůra je vložena na konec výstupního souboru, před "
+"konečným g-kódem tiskárny. Můžete přidávat zástupné proměnné pro veškeré "
+"nastavení Slic3ru. Pokud máte tiskárnu s více extrudéry, g-kód je zpracován "
+"v pořadí extrudérů."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:242
+msgid "Ensure vertical shell thickness"
+msgstr "Zajistit vertikální tloušťku obalu"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:244
+msgid ""
+"Add solid infill near sloping surfaces to guarantee the vertical shell "
+"thickness (top+bottom solid layers)."
+msgstr ""
+"Přidá plnou výplň u šikmých ploch pro garanci vertikální tloušťku obalu "
+"(vrchní a podní plné vrstvy)."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:250
+msgid "Top/bottom fill pattern"
+msgstr "Vzor výplně vrchních/spodních vrstev"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:252
+msgid ""
+"Fill pattern for top/bottom infill. This only affects the external visible "
+"layer, and not its adjacent solid shells."
+msgstr ""
+"Vzor výplně pro vrchní/spodní vrstvy. Ovlivňuje pouze vnější viditelné "
+"vrstvy. Neovlivňuje přilehlé plné obaly."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:271
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:281
+msgid "External perimeters"
+msgstr "Vnější perimetry"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:272
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:381
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:594
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:712
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:969
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1294
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1456
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1616
+msgid "Extrusion Width"
+msgstr "Šíře extruze"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:273
+msgid ""
+"Set this to a non-zero value to set a manual extrusion width for external "
+"perimeters. If left zero, default extrusion width will be used if set, "
+"otherwise 1.125 x nozzle diameter will be used. If expressed as percentage "
+"(for example 200%), it will be computed over layer height."
+msgstr ""
+"Nastavení na kladnou hodnotu, definuje šířku manuální extruze pro vnější "
+"obvod. Pokud je ponechána nula, použije se výchozí šířka extruze, pokud je "
+"nastavena, jinak se použije průměr trysky 1,125 x. Pokud je hodnota "
+"vyjádřena jako procento (například 200%), vypočítá se podle výšky vrstvy."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:276
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:599
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:717
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:974
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1298
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1460
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1621
+msgid "mm or % (leave 0 for default)"
+msgstr "mm nebo % (ponechte 0 jako výchozí)"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:283
+msgid ""
+"This separate setting will affect the speed of external perimeters (the "
+"visible ones). If expressed as percentage (for example: 80%) it will be "
+"calculated on the perimeters speed setting above. Set to zero for auto."
+msgstr ""
+"Toto oddělené nastavení ovlivní rychlost tisku vnějších perimetrů (těch "
+"viditelných). Pokud je hodnota vyjádřena procenty (například: 80%), bude "
+"rychlost vypočítána z hodnoty rychlosti tisku perimetrů, nastavené výše. "
+"Nastavte nulu pro automatický výpočet."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:286
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:621
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1257
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1308
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1503
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1633
+msgid "mm/s or %"
+msgstr "mm nebo %"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:293
+msgid "External perimeters first"
+msgstr "Nejprve tisknout vnější perimetry"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:295
+msgid ""
+"Print contour perimeters from the outermost one to the innermost one instead "
+"of the default inverse order."
+msgstr ""
+"Tisk obrysových perimetrů od vnějších po vnitřní namísto opačného výchozího "
+"pořadí."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:301
+msgid "Extra perimeters if needed"
+msgstr "Extra perimetry pokud jsou potřeba"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:303
+#, no-c-format
+msgid ""
+"Add more perimeters when needed for avoiding gaps in sloping walls. Slic3r "
+"keeps adding perimeters, until more than 70% of the loop immediately above "
+"is supported."
+msgstr ""
+"Přidání více perimetrů, pokud je potřeba, pro vyvarování se tvorbě mezer v "
+"šikmých plochách. Slic3r pokračuje v přidávání perimetrů, dokud není "
+"podepřeno více než 70% perimetrů v následující vrstvě."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:311
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:794
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1231
+msgid "Extruder"
+msgstr "Extrudér"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:313
+msgid ""
+"The extruder to use (unless more specific extruder settings are specified). "
+"This value overrides perimeter and infill extruders, but not the support "
+"extruders."
+msgstr ""
+"Extrudér, který chcete použít (pokud nejsou zvoleny specifičtější nastavení "
+"extruderu). Tato hodnota přepíše nastavení perimetrového a výplňového "
+"exrtuderu, ale ne nastavení extrudéru pro podpory."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:324
+msgid "Height"
+msgstr "Výška"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:325
+msgid ""
+"Set this to the vertical distance between your nozzle tip and (usually) the "
+"X carriage rods. In other words, this is the height of the clearance "
+"cylinder around your extruder, and it represents the maximum depth the "
+"extruder can peek before colliding with other printed objects."
+msgstr ""
+"Zadejte vertikální vzdálenost mezi tryskou a (obvykle) tyčemi osy X. Jinými "
+"slovy, je to výška kolizního prostoru okolo extrudéru a představuje "
+"maximální hloubku, které může extrudér dosáhnout před kolizí s jinými, již "
+"vytištěnými, objekty."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:335
+msgid "Radius"
+msgstr "Rádius"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:336
+msgid ""
+"Set this to the clearance radius around your extruder. If the extruder is "
+"not centered, choose the largest value for safety. This setting is used to "
+"check for collisions and to display the graphical preview in the plater."
+msgstr ""
+"Zadejte horizontální rádius kolizního prostoru okolo extrudéru. Pokud tryska "
+"není v centru tohoto rádiusu, zvolte nejdelší vzdálenost. Toto nastavení "
+"slouží ke kontrole kolizí a zobrazení grafického náhledu v Plater."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:346
+msgid "Extruder Color"
+msgstr "Barva extrudéru"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:347
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:410
+msgid "This is only used in the Slic3r interface as a visual help."
+msgstr "Toto je ve Slic3ru jako názorná pomoc."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:354
+msgid "Extruder offset"
+msgstr "Odsazení extrudéru"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:355
+msgid ""
+"If your firmware doesn't handle the extruder displacement you need the G-"
+"code to take it into account. This option lets you specify the displacement "
+"of each extruder with respect to the first one. It expects positive "
+"coordinates (they will be subtracted from the XY coordinate)."
+msgstr ""
+"Pokud firmware nezpracovává umístění extrudéru správně, potřebujete aby to "
+"vzal G-kód v úvahu. Toto nastavení umožňuje určit odsazení každého extruderu "
+"vzhledem k prvnímu. Očekávají se pozitivní souřadnice (budou odečteny od "
+"souřadnice XY)."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:364
+msgid "Extrusion axis"
+msgstr "Osa extrudéru"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:365
+msgid ""
+"Use this option to set the axis letter associated to your printer's extruder "
+"(usually E but some printers use A)."
+msgstr ""
+"Touto volbou nastavíte písmeno osy přidružené k extruderu tiskárny (obvykle "
+"E, ale některé tiskárny používají A)."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:371
+msgid "Extrusion multiplier"
+msgstr "Násobič extruze"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:372
+msgid ""
+"This factor changes the amount of flow proportionally. You may need to tweak "
+"this setting to get nice surface finish and correct single wall widths. "
+"Usual values are between 0.9 and 1.1. If you think you need to change this "
+"more, check filament diameter and your firmware E steps."
+msgstr ""
+"Tento faktor mění poměrné množství toku. Možná bude třeba toto nastavení "
+"vyladit, pro dosažení hezkého povrchu a správné šířky jednotlivých stěn. "
+"Obvyklé hodnoty jsou mezi 0,9 a 1,1. Pokud si myslíte, že hodnotu "
+"potřebujete změnit více, zkontrolujte průměr vlákna a E kroky ve firmwaru."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:380
+msgid "Default extrusion width"
+msgstr "Výchozí šířka extruze"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:382
+msgid ""
+"Set this to a non-zero value to allow a manual extrusion width. If left to "
+"zero, Slic3r derives extrusion widths from the nozzle diameter (see the "
+"tooltips for perimeter extrusion width, infill extrusion width etc). If "
+"expressed as percentage (for example: 230%), it will be computed over layer "
+"height."
+msgstr ""
+"Nastavením kladné hodnoty povolíte manuální šířku extruze. Pokud je hodnota "
+"ponechána na nule, Slic3r odvozuje šířku extruze z průměru trysky (viz "
+"nápovědy pro šířku extruze perimetru, šířku extruze výplně apod.). Pokud je "
+"hodnota vyjádřena procenty (například: 230%), vypočítá se z výšky vrstvy."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:386
+msgid "mm or % (leave 0 for auto)"
+msgstr "mm or % (pro automatické ponechte 0)"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:391
+msgid "Keep fan always on"
+msgstr "Ventilátor vždy zapnutý"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:392
+msgid ""
+"If this is enabled, fan will never be disabled and will be kept running at "
+"least at its minimum speed. Useful for PLA, harmful for ABS."
+msgstr ""
+"Pokud je tato funkce zapnutá, ventilátor nebude nikdy vypnut a bude udržován "
+"v chodu alespoň rychlostí která je nastavena jako minimální rychlost. "
+"Užitečné pro PLA, škodlivé pro ABS."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:398
+msgid "Enable fan if layer print time is below"
+msgstr "Zapnout ventilátor pokud je doba tisku vrstvy kratší než"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:399
+msgid ""
+"If layer print time is estimated below this number of seconds, fan will be "
+"enabled and its speed will be calculated by interpolating the minimum and "
+"maximum speeds."
+msgstr ""
+"Pokud je doba tisku vrstvy odhadnuta jako kratší než tato nastavená hodnota "
+"ve vteřinách, ventilátor bude aktivován a jeho rychlost bude vypočtena "
+"interpolací minimální a maximální rychlosti."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:401
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1244
+msgid "approximate seconds"
+msgstr "vteřin přibližně"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:409
+msgid "Color"
+msgstr "Barva"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:416
+msgid "Filament notes"
+msgstr "Poznámky k filamentu"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:417
+msgid "You can put your notes regarding the filament here."
+msgstr "Zde můžete vložit poznámky týkající se filamentu."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:425
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:819
+msgid "Max volumetric speed"
+msgstr "Maximální objemová rychlost"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:426
+msgid ""
+"Maximum volumetric speed allowed for this filament. Limits the maximum "
+"volumetric speed of a print to the minimum of print and filament volumetric "
+"speed. Set to zero for no limit."
+msgstr ""
+"Maximální povolený objem průtoku pro tento filament. Omezuje maximální "
+"rychlost průtoku pro tisk až na minimální rychlost průtoku pro tisk a "
+"filament. Zadejte nulu pro nastavení bez omezení."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:429
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:822
+msgid "mm\\u00B3/s"
+msgstr "mm\\u00B3/s"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:436
+msgid ""
+"Enter your filament diameter here. Good precision is required, so use a "
+"caliper and do multiple measurements along the filament, then compute the "
+"average."
+msgstr ""
+"Zde zadejte průměr filamentu. Je zapotřebí správné přesnosti, proto použijte "
+"šupleru a proveďte několik měření podél vlákna, poté vypočtete průměr."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:444
+msgid "Density"
+msgstr "Hustota"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:445
+msgid ""
+"Enter your filament density here. This is only for statistical information. "
+"A decent way is to weigh a known length of filament and compute the ratio of "
+"the length to volume. Better is to calculate the volume directly through "
+"displacement."
+msgstr ""
+"Zde zadejte hustotu filamentu. Toto je pouze pro statistické informace. "
+"Přípustný způsob je zvážit známou délku vlákna a vypočítat poměr délky k "
+"objemu. Je lepší vypočítat objem přímo přes posun."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:448
+msgid "g/cm\\u00B3"
+msgstr "g/cm\\u00B3"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:454
+msgid "Filament type"
+msgstr "Typ filamentu"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:455
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1004
+msgid ""
+"If you want to process the output G-code through custom scripts, just list "
+"their absolute paths here. Separate multiple scripts with a semicolon. "
+"Scripts will be passed the absolute path to the G-code file as the first "
+"argument, and they can access the Slic3r config settings by reading "
+"environment variables."
+msgstr ""
+"Pokud chcete zpracovat výstupní G-kód pomocí vlastních skriptů, stačí zde "
+"uvést jejich absolutní cesty. Oddělte více skriptů středníkem. Skripty "
+"předají absolutní cestu k souboru G-kódu jako první argument a mohou "
+"přistupovat k nastavení konfigurace Slic3ru čtením proměnných prostředí."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:474
+msgid "Soluble material"
+msgstr "Rozpustný materiál"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:475
+msgid "Soluble material is most likely used for a soluble support."
+msgstr "Rozpustný materiál je převážně používán pro tisk rozpustných podpor."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:480
+msgid "Cost"
+msgstr "Náklady"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:481
+msgid ""
+"Enter your filament cost per kg here. This is only for statistical "
+"information."
+msgstr ""
+"Zde zadejte cenu filamentu za kg. Slouží pouze pro statistické informace."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:482
+msgid "money/kg"
+msgstr "korun/kg"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:491
+msgid "Fill angle"
+msgstr "Úhel výplně"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:493
+msgid ""
+"Default base angle for infill orientation. Cross-hatching will be applied to "
+"this. Bridges will be infilled using the best direction Slic3r can detect, "
+"so this setting does not affect them."
+msgstr ""
+"Výchozí základní úhel pro orientaci výplně. Na toto bude použito křížové "
+"šrafování. Mosty budou vyplněny nejlepším směrem, který Slic3r dokáže "
+"rozpoznat, takže toto nastavení je neovlivní."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:505
+msgid "Fill density"
+msgstr "Hustota výplně"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:507
+#, no-c-format
+msgid "Density of internal infill, expressed in the range 0% - 100%."
+msgstr "Hustota vnitřní výplně, vyjádřená v rozmezí 0% až 100%."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:543
+msgid "Fill pattern"
+msgstr "Vzor výplně"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:545
+msgid "Fill pattern for general low-density infill."
+msgstr "Vzor výplně pro obecnou výplň s nízkou hustotou."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:575
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:584
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:593
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:627
+msgid "First layer"
+msgstr "První vrstva"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:576
+msgid ""
+"This is the acceleration your printer will use for first layer. Set zero to "
+"disable acceleration control for first layer."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:585
+msgid ""
+"Heated build plate temperature for the first layer. Set this to zero to "
+"disable bed temperature control commands in the output."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:595
+msgid ""
+"Set this to a non-zero value to set a manual extrusion width for first "
+"layer. You can use this to force fatter extrudates for better adhesion. If "
+"expressed as percentage (for example 120%) it will be computed over first "
+"layer height. If set to zero, it will use the default extrusion width."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:605
+msgid "First layer height"
+msgstr "Výška první vrstvy"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:607
+msgid ""
+"When printing with very low layer heights, you might still want to print a "
+"thicker bottom layer to improve adhesion and tolerance for non perfect build "
+"plates. This can be expressed as an absolute value or as a percentage (for "
+"example: 150%) over the default layer height."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:611
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:742
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1392
+msgid "mm or %"
+msgstr "mm nebo %"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:617
+msgid "First layer speed"
+msgstr "Rychlost první vrstvy"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:618
+msgid ""
+"If expressed as absolute value in mm/s, this speed will be applied to all "
+"the print moves of the first layer, regardless of their type. If expressed "
+"as a percentage (for example: 40%) it will scale the default speeds."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:628
+msgid ""
+"Extruder temperature for first layer. If you want to control temperature "
+"manually during print, set this to zero to disable temperature control "
+"commands in the output file."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:636
+msgid "Gap fill"
+msgstr "Výplň mezer"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:638
+msgid ""
+"Speed for filling small gaps using short zigzag moves. Keep this reasonably "
+"low to avoid too much shaking and resonance issues. Set zero to disable gaps "
+"filling."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:646
+msgid "Verbose G-code"
+msgstr "Verbose G-code"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:647
+msgid ""
+"Enable this to get a commented G-code file, with each line explained by a "
+"descriptive text. If you print from SD card, the additional weight of the "
+"file could make your firmware slow down."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:654
+msgid "G-code flavor"
+msgstr "Druh G-kódu"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:655
+msgid ""
+"Some G/M-code commands, including temperature control and others, are not "
+"universal. Set this option to your printer's firmware to get a compatible "
+"output. The \"No extrusion\" flavor prevents Slic3r from exporting any "
+"extrusion value at all."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:684
+msgid ""
+"This is the acceleration your printer will use for infill. Set zero to "
+"disable acceleration control for infill."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:692
+msgid "Combine infill every"
+msgstr "Kombinovat výplň každou"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:694
+msgid ""
+"This feature allows to combine infill and speed up your print by extruding "
+"thicker infill layers while preserving thin perimeters, thus accuracy."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:698
+msgid "Combine infill every n layers"
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:703
+msgid "Infill extruder"
+msgstr "Extruder pro výplň"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:705
+msgid "The extruder to use when printing infill."
+msgstr "Extruder který se použije pro tisk výplní."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:713
+msgid ""
+"Set this to a non-zero value to set a manual extrusion width for infill. If "
+"left zero, default extrusion width will be used if set, otherwise 1.125 x "
+"nozzle diameter will be used. You may want to use fatter extrudates to speed "
+"up the infill and make your parts stronger. If expressed as percentage (for "
+"example 90%) it will be computed over layer height."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:722
+msgid "Infill before perimeters"
+msgstr "Tisknout výplň před tiskem perimetrů"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:723
+msgid ""
+"This option will switch the print order of perimeters and infill, making the "
+"latter first."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:728
+msgid "Only infill where needed"
+msgstr "Výplň pouze kde je potřeba"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:730
+msgid ""
+"This option will limit infill to the areas actually needed for supporting "
+"ceilings (it will act as internal support material). If enabled, slows down "
+"the G-code generation due to the multiple checks involved."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:737
+msgid "Infill/perimeters overlap"
+msgstr "Přesah pro výplň/perimetry"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:739
+msgid ""
+"This setting applies an additional overlap between infill and perimeters for "
+"better bonding. Theoretically this shouldn't be needed, but backlash might "
+"cause gaps. If expressed as percentage (example: 15%) it is calculated over "
+"perimeter extrusion width."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:750
+msgid "Speed for printing the internal fill. Set to zero for auto."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:759
+msgid "Interface shells"
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:760
+msgid ""
+"Force the generation of solid shells between adjacent materials/volumes. "
+"Useful for multi-extruder prints with translucent materials or manual "
+"soluble support material."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:768
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1137
+msgid "After layer change G-code"
+msgstr "After layer change G-code"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:769
+msgid ""
+"This custom code is inserted at every layer change, right after the Z move "
+"and before the extruder moves to the first layer point. Note that you can "
+"use placeholder variables for all Slic3r settings as well as [layer_num] and "
+"[layer_z]."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:779
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:315
+msgid "Layer height"
+msgstr "Výška vrstvy"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:781
+msgid ""
+"This setting controls the height (and thus the total number) of the slices/"
+"layers. Thinner layers give better accuracy but take more time to print."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:789
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:798
+msgid "Max"
+msgstr "Maximálně"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:790
+msgid "This setting represents the maximum speed of your fan."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:799
+#, no-c-format
+msgid ""
+"This is the highest printable layer height for this extruder, used to cap "
+"the variable layer height and support layer height. Maximum recommended "
+"layer height is 75% of the extrusion width to achieve reasonable inter-layer "
+"adhesion. If set to 0, layer height is limited to 75% of the nozzle diameter."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:809
+msgid "Max print speed"
+msgstr "Maximální rychlost tisku"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:810
+msgid ""
+"When setting other speed settings to 0 Slic3r will autocalculate the optimal "
+"speed in order to keep constant extruder pressure. This experimental setting "
+"is used to set the highest print speed you want to allow."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:820
+msgid ""
+"This experimental setting is used to set the maximum volumetric speed your "
+"extruder supports."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:828
+msgid "Max volumetric slope positive"
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:829
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:840
+msgid ""
+"This experimental setting is used to limit the speed of change in extrusion "
+"rate. A value of 1.8 mm\\u00B3/s\\u00B2 ensures, that a change from the "
+"extrusion rate of 1.8 mm\\u00B3/s (0.45mm extrusion width, 0.2mm extrusion "
+"height, feedrate 20 mm/s) to 5.4 mm\\u00B3/s (feedrate 60 mm/s) will take at "
+"least 2 seconds."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:833
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:844
+msgid "mm\\u00B3/s\\u00B2"
+msgstr "mm\\u00B3/s\\u00B2"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:839
+msgid "Max volumetric slope negative"
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:850
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:859
+msgid "Min"
+msgstr "Minimálně"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:851
+msgid "This setting represents the minimum PWM your fan needs to work."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:860
+msgid ""
+"This is the lowest printable layer height for this extruder and limits the "
+"resolution for variable layer height. Typical values are between 0.05 mm and "
+"0.1 mm."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:868
+msgid "Min print speed"
+msgstr "Minimální rychlost tisku"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:869
+msgid "Slic3r will not scale speed down below this speed."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:876
+msgid "Minimum extrusion length"
+msgstr "Minimální délka extruze"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:877
+msgid ""
+"Generate no less than the number of skirt loops required to consume the "
+"specified amount of filament on the bottom layer. For multi-extruder "
+"machines, this minimum applies to each extruder."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:886
+msgid "Configuration notes"
+msgstr "Configurační poznámky"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:887
+msgid ""
+"You can put here your personal notes. This text will be added to the G-code "
+"header comments."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:896
+msgid "Nozzle diameter"
+msgstr "Průměr trysky"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:897
+msgid ""
+"This is the diameter of your extruder nozzle (for example: 0.5, 0.35 etc.)"
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:903
+msgid "API Key"
+msgstr "Klíč API"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:904
+msgid ""
+"Slic3r can upload G-code files to OctoPrint. This field should contain the "
+"API Key required for authentication."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:910
+msgid "Host or IP"
+msgstr "Host nebo IP"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:911
+msgid ""
+"Slic3r can upload G-code files to OctoPrint. This field should contain the "
+"hostname or IP address of the OctoPrint instance."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:917
+msgid "Only retract when crossing perimeters"
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:918
+msgid ""
+"Disables retraction when the travel path does not exceed the upper layer's "
+"perimeters (and thus any ooze will be probably invisible)."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:924
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1697
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:805
+msgid "Enable"
+msgstr "Zapnout"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:925
+msgid ""
+"This option will drop the temperature of the inactive extruders to prevent "
+"oozing. It will enable a tall skirt automatically and move extruders outside "
+"such skirt when changing temperatures."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:932
+msgid "Output filename format"
+msgstr "Formát výstupního názvu"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:933
+msgid ""
+"You can use all configuration options as variables inside this template. For "
+"example: [layer_height], [fill_density] etc. You can also use [timestamp], "
+"[year], [month], [day], [hour], [minute], [second], [version], "
+"[input_filename], [input_filename_base]."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:942
+msgid "Detect bridging perimeters"
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:944
+msgid ""
+"Experimental option to adjust flow for overhangs (bridge flow will be used), "
+"to apply bridge speed to them and enable fan."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:950
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:968
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:980
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:990
+msgid "Perimeters"
+msgstr "Perimetry"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:951
+msgid ""
+"This is the acceleration your printer will use for perimeters. A high value "
+"like 9000 usually gives good results if your hardware is up to the job. Set "
+"zero to disable acceleration control for perimeters."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:959
+msgid "Perimeter extruder"
+msgstr "Extruder pro perimetry"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:961
+msgid ""
+"The extruder to use when printing perimeters and brim. First extruder is 1."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:970
+msgid ""
+"Set this to a non-zero value to set a manual extrusion width for perimeters. "
+"You may want to use thinner extrudates to get more accurate surfaces. If "
+"left zero, default extrusion width will be used if set, otherwise 1.125 x "
+"nozzle diameter will be used. If expressed as percentage (for example 200%) "
+"it will be computed over layer height."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:982
+msgid ""
+"Speed for perimeters (contours, aka vertical shells). Set to zero for auto."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:992
+msgid ""
+"This option sets the number of perimeters to generate for each layer. Note "
+"that Slic3r may increase this number automatically when it detects sloping "
+"surfaces which benefit from a higher number of perimeters if the Extra "
+"Perimeters option is enabled."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:996
+msgid "(minimum)"
+msgstr "(minimálně)"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1003
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:495
+msgid "Post-processing scripts"
+msgstr "Post-processing scripts"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1016
+msgid "Printer notes"
+msgstr "Poznámky o tiskárně"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1017
+msgid "You can put your notes regarding the printer here."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1031
+msgid "Raft layers"
+msgstr "Vrstev raftu"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1033
+msgid ""
+"The object will be raised by this number of layers, and support material "
+"will be generated under it."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1041
+msgid "Resolution"
+msgstr "Rozlišení"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1042
+msgid ""
+"Minimum detail resolution, used to simplify the input file for speeding up "
+"the slicing job and reducing memory usage. High-resolution models often "
+"carry more detail than printers can render. Set to zero to disable any "
+"simplification and use full resolution from input."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1052
+msgid "Minimum travel after retraction"
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1053
+msgid ""
+"Retraction is not triggered when travel moves are shorter than this length."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1059
+msgid "Retract amount before wipe"
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1060
+msgid ""
+"With bowden extruders, it may be wise to do some amount of quick retract "
+"before doing the wipe movement."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1067
+msgid "Retract on layer change"
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1068
+msgid "This flag enforces a retraction whenever a Z move is done."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1073
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1082
+msgid "Length"
+msgstr "Vzdálenost"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1074
+msgid "Retraction Length"
+msgstr "Vzdálenost retrakce"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1075
+msgid ""
+"When retraction is triggered, filament is pulled back by the specified "
+"amount (the length is measured on raw filament, before it enters the "
+"extruder)."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1077
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1087
+msgid "mm (zero to disable)"
+msgstr "mm (nula pro vypnutí)"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1083
+msgid "Retraction Length (Toolchange)"
+msgstr "Vzdálenost retrakce (při změně nástroje)"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1084
+msgid ""
+"When retraction is triggered before changing tool, filament is pulled back "
+"by the specified amount (the length is measured on raw filament, before it "
+"enters the extruder)."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1092
+msgid "Lift Z"
+msgstr "Zvednout Z"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1093
+msgid ""
+"If you set this to a positive value, Z is quickly raised every time a "
+"retraction is triggered. When using multiple extruders, only the setting for "
+"the first extruder will be considered."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1101
+msgid "Above Z"
+msgstr "Nad Z"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1102
+msgid "Only lift Z above"
+msgstr "Zvednout Z pouze nad"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1103
+msgid ""
+"If you set this to a positive value, Z lift will only take place above the "
+"specified absolute Z. You can tune this setting for skipping lift on the "
+"first layers."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1110
+msgid "Below Z"
+msgstr "Pod Z"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1111
+msgid "Only lift Z below"
+msgstr "Zvednout Z pouze pod"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1112
+msgid ""
+"If you set this to a positive value, Z lift will only take place below the "
+"specified absolute Z. You can tune this setting for limiting lift to the "
+"first layers."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1120
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1128
+msgid "Extra length on restart"
+msgstr "Extra vzdálenost při restartu"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1121
+msgid ""
+"When the retraction is compensated after the travel move, the extruder will "
+"push this additional amount of filament. This setting is rarely needed."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1129
+msgid ""
+"When the retraction is compensated after changing tool, the extruder will "
+"push this additional amount of filament."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1136
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1137
+msgid "Retraction Speed"
+msgstr "Rychlost retrakce"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1138
+msgid "The speed for retractions (it only applies to the extruder motor)."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1144
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1145
+msgid "Deretraction Speed"
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1146
+msgid ""
+"The speed for loading of a filament into extruder after retraction (it only "
+"applies to the extruder motor). If left to zero, the retraction speed is "
+"used."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1153
+msgid "Seam position"
+msgstr "Pozice švu"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1155
+msgid "Position of perimeters starting points."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1171
+msgid "Direction"
+msgstr "Směr"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1173
+msgid "Preferred direction of the seam"
+msgstr "Preferovaný směr švu"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1174
+msgid "Seam preferred direction"
+msgstr "Preferovaný směr švu"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1182
+msgid "Jitter"
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1184
+msgid "Seam preferred direction jitter"
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1185
+msgid "Preferred direction of the seam - jitter"
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1195
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:989
+msgid "Serial port"
+msgstr "Sériový port"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1196
+msgid "USB/serial port for printer connection."
+msgstr "USB/sériový port pro připojení tiskárny."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1204
+msgid "Serial port speed"
+msgstr "Rychlost sériového portu"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1205
+msgid "Speed (baud) of USB/serial port for printer connection."
+msgstr "Rychlost (baud) USB/sériového portu pro připojení tiskárny."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1214
+msgid "Distance from object"
+msgstr "Vzdálenost od objektu"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1215
+msgid ""
+"Distance between skirt and object(s). Set this to zero to attach the skirt "
+"to the object(s) and get a brim for better adhesion."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1223
+msgid "Skirt height"
+msgstr "Výška skirtu"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1224
+msgid ""
+"Height of skirt expressed in layers. Set this to a tall value to use skirt "
+"as a shield against drafts."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1231
+msgid "Loops (minimum)"
+msgstr "Smyček (minimálně)"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1232
+msgid "Skirt Loops"
+msgstr "Smyček skirtu"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1233
+msgid ""
+"Number of loops for the skirt. If the Minimum Extrusion Length option is "
+"set, the number of loops might be greater than the one configured here. Set "
+"this to zero to disable skirt completely."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1241
+msgid "Slow down if layer print time is below"
+msgstr "Zpomalit tisk pokud je doba tisku kratší než"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1242
+msgid ""
+"If layer print time is estimated below this number of seconds, print moves "
+"speed will be scaled down to extend duration to this value."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1252
+msgid "Small perimeters"
+msgstr "Malé perimetry"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1254
+msgid ""
+"This separate setting will affect the speed of perimeters having radius <= "
+"6.5mm (usually holes). If expressed as percentage (for example: 80%) it will "
+"be calculated on the perimeters speed setting above. Set to zero for auto."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1264
+msgid "Solid infill threshold area"
+msgstr "Prahová hodnota plochy pro plnou výplň"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1266
+msgid ""
+"Force solid infill for regions having a smaller area than the specified "
+"threshold."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1267
+msgid "mm\\u00B2"
+msgstr "mm\\u00B2"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1273
+msgid "Solid infill extruder"
+msgstr "Extrudér pro plnou výplň"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1275
+msgid "The extruder to use when printing solid infill."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1281
+msgid "Solid infill every"
+msgstr "Plná výplň každou"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1283
+msgid ""
+"This feature allows to force a solid layer every given number of layers. "
+"Zero to disable. You can set this to any value (for example 9999); Slic3r "
+"will automatically choose the maximum possible number of layers to combine "
+"according to nozzle diameter and layer height."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1293
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1303
+msgid "Solid infill"
+msgstr "Plná výplň"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1295
+msgid ""
+"Set this to a non-zero value to set a manual extrusion width for infill for "
+"solid surfaces. If left zero, default extrusion width will be used if set, "
+"otherwise 1.125 x nozzle diameter will be used. If expressed as percentage "
+"(for example 90%) it will be computed over layer height."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1305
+msgid ""
+"Speed for printing solid regions (top/bottom/internal horizontal shells). "
+"This can be expressed as a percentage (for example: 80%) over the default "
+"infill speed above. Set to zero for auto."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1316
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:331
+msgid "Solid layers"
+msgstr "Plných vrstev"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1317
+msgid "Number of solid layers to generate on top and bottom surfaces."
+msgstr "Počet plných vstev generovaných vrchních a spodních površích."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1324
+msgid "Spiral vase"
+msgstr "Spirálová váza"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1325
+msgid ""
+"This feature will raise Z gradually while printing a single-walled object in "
+"order to remove any visible seam. This option requires a single perimeter, "
+"no infill, no top solid layers and no support material. You can still set "
+"any number of bottom solid layers as well as skirt/brim loops. It won't work "
+"when printing more than an object."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1334
+msgid "Temperature variation"
+msgstr "Temperature variation"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1335
+msgid ""
+"Temperature difference to be applied when an extruder is not active. Enables "
+"a full-height \"sacrificial\" skirt on which the nozzles are periodically "
+"wiped."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1344
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1359
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:846
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1119
+msgid "Start G-code"
+msgstr "Začátek G-kódu"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1345
+msgid ""
+"This start procedure is inserted at the beginning, after bed has reached the "
+"target temperature and extruder just started heating, and before extruder "
+"has finished heating. If Slic3r detects M104 or M190 in your custom codes, "
+"such commands will not be prepended automatically so you're free to "
+"customize the order of heating commands and other custom actions. Note that "
+"you can use placeholder variables for all Slic3r settings, so you can put a "
+"\"M109 S[first_layer_temperature]\" command wherever you want."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1360
+msgid ""
+"This start procedure is inserted at the beginning, after any printer start "
+"gcode. This is used to override settings for a specific filament. If Slic3r "
+"detects M104, M109, M140 or M190 in your custom codes, such commands will "
+"not be prepended automatically so you're free to customize the order of "
+"heating commands and other custom actions. Note that you can use placeholder "
+"variables for all Slic3r settings, so you can put a \"M109 "
+"S[first_layer_temperature]\" command wherever you want. If you have multiple "
+"extruders, the gcode is processed in extruder order."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1375
+msgid "Single Extruder Multi Material"
+msgstr "Multi Materiálový tisk s jedním extrudérem"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1376
+msgid "The printer multiplexes filaments into a single hot end."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1381
+msgid "Generate support material"
+msgstr "Generovat podpory"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1383
+msgid "Enable support material generation."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1388
+msgid "XY separation between an object and its support"
+msgstr "XY vzdálenost mezi objektem a podporami"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1390
+msgid ""
+"XY separation between an object and its support. If expressed as percentage "
+"(for example 50%), it will be calculated over external perimeter width."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1400
+msgid "Pattern angle"
+msgstr "Úhel vzoru"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1402
+msgid ""
+"Use this setting to rotate the support material pattern on the horizontal "
+"plane."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1410
+msgid "Support on build plate only"
+msgstr "Podpory pouze na tiskové ploše"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1412
+msgid ""
+"Only create support if it lies on a build plate. Don't create support on a "
+"print."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1418
+msgid "Contact Z distance"
+msgstr "Kontaktní vzdálenost Z"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1420
+msgid ""
+"The vertical distance between object and support material interface. Setting "
+"this to 0 will also prevent Slic3r from using bridge flow and speed for the "
+"first object layer."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1433
+msgid "Enforce support for the first"
+msgstr "Zesílit podpory pro prvních"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1435
+msgid ""
+"Generate support material for the specified number of layers counting from "
+"bottom, regardless of whether normal support material is enabled or not and "
+"regardless of any angle threshold. This is useful for getting more adhesion "
+"of objects having a very thin or poor footprint on the build plate."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1441
+msgid "Enforce support for the first n layers"
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1446
+msgid "Support material/raft/skirt extruder"
+msgstr "Support material/raft/skirt extruder"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1448
+msgid ""
+"The extruder to use when printing support material, raft and skirt (1+, 0 to "
+"use the current extruder to minimize tool changes)."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1457
+msgid ""
+"Set this to a non-zero value to set a manual extrusion width for support "
+"material. If left zero, default extrusion width will be used if set, "
+"otherwise nozzle diameter will be used. If expressed as percentage (for "
+"example 90%) it will be computed over layer height."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1465
+msgid "Interface loops"
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1467
+msgid ""
+"Cover the top contact layer of the supports with loops. Disabled by default."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1472
+msgid "Support material/raft interface extruder"
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1474
+msgid ""
+"The extruder to use when printing support material interface (1+, 0 to use "
+"the current extruder to minimize tool changes). This affects raft too."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1481
+msgid "Interface layers"
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1483
+msgid ""
+"Number of interface layers to insert between the object(s) and support "
+"material."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1490
+msgid "Interface pattern spacing"
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1492
+msgid "Spacing between interface lines. Set zero to get a solid interface."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1499
+msgid "Support material interface"
+msgstr "Support material interface"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1501
+msgid ""
+"Speed for printing support material interface layers. If expressed as "
+"percentage (for example 50%) it will be calculated over support material "
+"speed."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1510
+msgid "Pattern"
+msgstr "Vzor"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1512
+msgid "Pattern used to generate support material."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1526
+msgid "Pattern spacing"
+msgstr "Vzdálenost vzoru"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1528
+msgid "Spacing between support material lines."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1537
+msgid "Speed for printing support material."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1544
+msgid "Synchronize with object layers"
+msgstr "Synchronizovat s vrstvami objektu"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1546
+msgid ""
+"Synchronize support layers with the object print layers. This is useful with "
+"multi-material printers, where the extruder switch is expensive."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1552
+msgid "Overhang threshold"
+msgstr "Práh přesahu"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1554
+msgid ""
+"Support material will not be generated for overhangs whose slope angle "
+"(90\\u00B0 = vertical) is above the given threshold. In other words, this "
+"value represent the most horizontal slope (measured from the horizontal "
+"plane) that you can print without support material. Set to zero for "
+"automatic detection (recommended)."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1566
+msgid "With sheath around the support"
+msgstr "S pouzdrem okolo podpor"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1568
+msgid ""
+"Add a sheath (a single perimeter line) around the base support. This makes "
+"the support more reliable, but also more difficult to remove."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1575
+msgid ""
+"Extruder temperature for layers after the first one. Set this to zero to "
+"disable temperature control commands in the output."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1578
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:793
+msgid "Temperature"
+msgstr "Teplota"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1584
+msgid "Detect thin walls"
+msgstr "Detekovat tenké zdi"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1586
+msgid ""
+"Detect single-width walls (parts where two extrusions don't fit and we need "
+"to collapse them into a single trace)."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1592
+msgid "Threads"
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1593
+msgid ""
+"Threads are used to parallelize long-running tasks. Optimal threads number "
+"is slightly above the number of available cores/processors."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1604
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1143
+msgid "Tool change G-code"
+msgstr "Tool change G-code"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1605
+msgid ""
+"This custom code is inserted right before every extruder change. Note that "
+"you can use placeholder variables for all Slic3r settings as well as "
+"[previous_extruder] and [next_extruder]."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1615
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1626
+msgid "Top solid infill"
+msgstr "Vrchní plná výplň"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1617
+msgid ""
+"Set this to a non-zero value to set a manual extrusion width for infill for "
+"top surfaces. You may want to use thinner extrudates to fill all narrow "
+"regions and get a smoother finish. If left zero, default extrusion width "
+"will be used if set, otherwise nozzle diameter will be used. If expressed as "
+"percentage (for example 90%) it will be computed over layer height."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1628
+msgid ""
+"Speed for printing top solid layers (it only applies to the uppermost "
+"external layers and not to their internal solid layers). You may want to "
+"slow down this to get a nicer surface finish. This can be expressed as a "
+"percentage (for example: 80%) over the solid infill speed above. Set to zero "
+"for auto."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1640
+msgid "Top"
+msgstr "Vrchní"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1642
+msgid "Number of solid layers to generate on top surfaces."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1644
+msgid "Top solid layers"
+msgstr "Vrchních plných vrstev"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1649
+msgid "Travel"
+msgstr "Přesun"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1650
+msgid "Speed for travel moves (jumps between distant extrusion points)."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1658
+msgid "Use firmware retraction"
+msgstr "Použít retrakce z firmware"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1659
+msgid ""
+"This experimental setting uses G10 and G11 commands to have the firmware "
+"handle the retraction. This is only supported in recent Marlin."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1665
+msgid "Use relative E distances"
+msgstr "Použít relativní E vzdálenosti"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1666
+msgid ""
+"If your firmware requires relative E values, check this, otherwise leave it "
+"unchecked. Most firmwares use absolute values."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1672
+msgid "Use volumetric E"
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1673
+msgid ""
+"This experimental setting uses outputs the E values in cubic millimeters "
+"instead of linear millimeters. If your firmware doesn't already know "
+"filament diameter(s), you can put commands like 'M200 D[filament_diameter_0] "
+"T0' in your start G-code in order to turn volumetric mode on and use the "
+"filament diameter associated to the filament selected in Slic3r. This is "
+"only supported in recent Marlin."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1683
+msgid "Enable variable layer height feature"
+msgstr "Zapnout variabilní výšku vrstev"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1684
+msgid ""
+"Some printers or printer setups may have difficulties printing with a "
+"variable layer height. Enabled by default."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1690
+msgid "Wipe while retracting"
+msgstr "Očistit při retrakci"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1691
+msgid ""
+"This flag will move the nozzle while retracting to minimize the possible "
+"blob on leaky extruders."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1698
+msgid ""
+"Multi material printers may need to prime or purge extruders on tool "
+"changes. Extrude the excess material into the wipe tower."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1704
+msgid "Position X"
+msgstr "Pozice X"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1705
+msgid "X coordinate of the left front corner of a wipe tower"
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1711
+msgid "Position Y"
+msgstr "Pozice Y"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1712
+msgid "Y coordinate of the left front corner of a wipe tower"
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1718
+msgid "Width"
+msgstr "Šířka"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1719
+msgid "Width of a wipe tower"
+msgstr "Šířka čistící věže"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1725
+msgid "Per color change depth"
+msgstr "Hloubka výměny pro barvu"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1726
+msgid ""
+"Depth of a wipe color per color change. For N colors, there will be maximum "
+"(N-1) tool switches performed, therefore the total depth of the wipe tower "
+"will be (N-1) times this value."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1734
+msgid "XY Size Compensation"
+msgstr "Kompenzace XY rozměrů"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1736
+msgid ""
+"The object will be grown/shrunk in the XY plane by the configured value "
+"(negative = inwards, positive = outwards). This might be useful for fine-"
+"tuning hole sizes."
+msgstr ""
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1744
+msgid "Z offset"
+msgstr "Odsazení Z"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1745
+msgid ""
+"This value will be added (or subtracted) from all the Z coordinates in the "
+"output G-code. It is used to compensate for bad Z endstop position: for "
+"example, if your endstop zero actually leaves the nozzle 0.3mm far from the "
+"print bed, set this to -0.3 (or fix your endstop)."
+msgstr ""
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:39
+msgid "Shape"
+msgstr "Tvar"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:46
+msgid "Rectangular"
+msgstr "Obdélníkový"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:62
+msgid "Circular"
+msgstr "Kruhový"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:75
+msgid "Load shape from STL..."
+msgstr "Načíst tvar ze souboru STL…"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:120
+msgid "Settings"
+msgstr "Nastavení"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:298
+msgid "Choose a file to import bed shape from (STL/OBJ/AMF/PRUSA):"
+msgstr "Výběr souboru pro import tvaru tiskové podložky (STL/OBJ/AMF/PRUSA):"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:315
+msgid "Error! "
+msgstr "Chyba! "
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:324
+msgid "The selected file contains no geometry."
+msgstr "Vybraný soubor neobsahuje geometrii."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:328
+msgid ""
+"The selected file contains several disjoint areas. This is not supported."
+msgstr ""
+"Vybraný soubor obsahuje několik nespojených ploch. Tato možnost není "
+"podporována."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.hpp:42
+msgid "Bed Shape"
+msgstr "Tvar tiskové podložky"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:468
+msgid "Error"
+msgstr "Chyba"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:473
+msgid "Notice"
+msgstr "Oznámení"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:50
+msgid "Save current "
+msgstr "Uložit stávající "
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:51
+msgid "Delete this preset"
+msgstr "Smazat přednastavení"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:330
+msgid "Horizontal shells"
+msgstr "Horizontal shells"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:336
+msgid "Quality (slower slicing)"
+msgstr "Kvalita (pomalejší slicing)"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:353
+msgid "Reducing printing time"
+msgstr "Zkracování tiskového času"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:365
+msgid "Skirt and brim"
+msgstr "Skirt and brim"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:381
+msgid "Raft"
+msgstr "Raft"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:412
+msgid "Speed for non-print moves"
+msgstr "Speed for non-print moves"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:415
+msgid "Modifiers"
+msgstr "Modifikátory"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:418
+msgid "Acceleration control (advanced)"
+msgstr "Kontrola akcelerací (pokročilé)"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:425
+msgid "Autospeed (advanced)"
+msgstr "Automatická rychlost (pokročilé)"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:431
+msgid "Multiple Extruders"
+msgstr "Multiple Extruders"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:439
+msgid "Ooze prevention"
+msgstr "Ooze prevention"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:464
+msgid "Overlap"
+msgstr "Překrytí"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:467
+msgid "Flow"
+msgstr "Průtok"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:470
+msgid "Other"
+msgstr "Ostatní"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:477
+msgid "Output options"
+msgstr "Možnosti výstupu"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:478
+msgid "Sequential printing"
+msgstr "Sekvenční tisk"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:501
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:502
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:858
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:859
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1155
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1156
+msgid "Notes"
+msgstr "Poznámky"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:508
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:866
+msgid "Dependencies"
+msgstr "Závislosti"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:509
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:867
+msgid "Profile dependencies"
+msgstr "Profilové závislosti"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:799
+msgid "Bed"
+msgstr "Tisková podložka"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:804
+msgid "Cooling"
+msgstr "Chlazení"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:816
+msgid "Fan settings"
+msgstr "Nastavení ventilátoru"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:835
+msgid "Print speed override"
+msgstr "Přepsání rychlosti tisku"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:845
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1118
+msgid "Custom G-code"
+msgstr "Upravený G-kód"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:936
+msgid "General"
+msgstr "Obecné"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:937
+msgid "Size and coordinates"
+msgstr "Rozměr a souřadnice"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:941
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1642
+msgid "Set"
+msgstr "Nastavit"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:961
+msgid "Capabilities"
+msgstr "Možnosti"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1003
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1071
+msgid "Test"
+msgstr "Test"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1016
+msgid "Connection to printer works correctly."
+msgstr "Připojení k tiskárně pracuje správně."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1016
+msgid "Success!"
+msgstr "Úspěch!"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1019
+msgid "Connection failed."
+msgstr "Připojení selhalo."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1031
+msgid "OctoPrint upload"
+msgstr "OctoPrint nahrávání"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1034
+msgid "Browse"
+msgstr "Procházet"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1046
+msgid "Button BROWSE was clicked!"
+msgstr "Tlačítko PROCHÁZET bylo stisknuto!"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1081
+msgid "Button TEST was clicked!"
+msgstr "Tlačítko TEST bylo stisknuto!"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1109
+msgid "Firmware"
+msgstr "Firmware"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1191
+msgid "Layer height limits"
+msgstr "Výskové limity vrstvy"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1196
+msgid "Position (for multi-extruder printers)"
+msgstr "Position (for multi-extruder printers)"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1215
+msgid ""
+"Retraction when tool is disabled (advanced settings for multi-extruder "
+"setups)"
+msgstr ""
+"Retraction when tool is disabled (advanced settings for multi-extruder "
+"setups)"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1219
+msgid "Preview"
+msgstr "Náhled"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1310
+msgid ""
+"The Wipe option is not available when using the Firmware Retraction mode.\n"
+"\n"
+"Shall I disable it in order to enable Firmware Retraction?"
+msgstr ""
+"The Wipe option is not available when using the Firmware Retraction mode.\n"
+"\n"
+"Shall I disable it in order to enable Firmware Retraction?"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1558
+msgid "The supplied name is empty. It can't be saved."
+msgstr "The supplied name is empty. It can't be saved."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1569
+msgid "Something is wrong. It can't be saved."
+msgstr "Něco se pokazilo. Nemůže být uloženo."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1586
+msgid "remove"
+msgstr "odebrat"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1586
+msgid "delete"
+msgstr "smazat"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1587
+msgid "Are you sure you want to "
+msgstr "Jste si jistý že chcete "
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1587
+msgid " the selected preset?"
+msgstr " zvolené přednastavení?"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1588
+msgid "Remove"
+msgstr "Odebrat"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1588
+msgid "Delete"
+msgstr "Smazat"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1589
+msgid " Preset"
+msgstr " Přednastavení"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1641
+msgid "All"
+msgstr "Vše"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1672
+msgid "Select the printers this profile is compatible with."
+msgstr "Select the printers this profile is compatible with."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1756
+msgid "Save "
+msgstr "Uložit "
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1756
+msgid " as:"
+msgstr " jako:"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1790
+msgid ""
+"The supplied name is not valid; the following characters are not allowed:"
+msgstr ""
+"The supplied name is not valid; the following characters are not allowed:"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1793
+msgid "The supplied name is not available."
+msgstr "The supplied name is not available."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:182
+msgid "Print Settings"
+msgstr "Nastavení tisku"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:202
+msgid "Filament Settings"
+msgstr "Nastavení Filamentu"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:248
+msgid "Save preset"
+msgstr "Uložit přednastavení"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Field.cpp:35
+msgid "default"
+msgstr "výchozí"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:71
+msgid "Custom"
+msgstr "Upravený"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:212
+msgid "Array of language names and identifiers should have the same size."
+msgstr ""
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:223
+msgid "Select the language"
+msgstr "Výběr jazyka"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:223
+msgid "Language"
+msgstr "Jazyk"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:321
+msgid "Change Application Language"
+msgstr "Změnit Jazyk Aplikace"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:314
+msgid "Layers and perimeters"
+msgstr "Vrstvy a perimetry"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:319
+msgid "Vertical shells"
+msgstr "Vertical shells"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:366
+msgid "Skirt"
+msgstr "Skirt"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:372
+msgid "Brim"
+msgstr "Brim"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:385
+msgid "Options for support material and raft"
+msgstr "Options for support material and raft"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:400
+msgid "Speed for print moves"
+msgstr "Speed for print moves"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:443
+msgid "Wipe tower"
+msgstr "Čistící věž"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:454
+msgid "Extrusion width"
+msgstr "Šířka extruze"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:480
+msgid "Extruder clearance (mm)"
+msgstr ""
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:489
+msgid "Output file"
+msgstr "Výstupní soubor"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:534
+#, no-c-format
+msgid ""
+"The Spiral Vase mode requires:\n"
+"- one perimeter\n"
+"- no top solid layers\n"
+"- 0% fill density\n"
+"- no support material\n"
+"- no ensure_vertical_shell_thickness\n"
+"\n"
+"Shall I adjust those settings in order to enable Spiral Vase?"
+msgstr ""
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:541
+msgid "Spiral Vase"
+msgstr "Spirálová váza"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:560
+msgid ""
+"The Wipe Tower currently supports only:\n"
+"- first layer height 0.2mm\n"
+"- layer height from 0.15mm to 0.35mm\n"
+"\n"
+"Shall I adjust those settings in order to enable the Wipe Tower?"
+msgstr ""
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:564
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:585
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:602
+msgid "Wipe Tower"
+msgstr "Čistící věž"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:581
+msgid ""
+"The Wipe Tower currently supports the non-soluble supports only\n"
+"if they are printed with the current extruder without triggering a tool "
+"change.\n"
+"(both support_material_extruder and support_material_interface_extruder need "
+"to be set to 0).\n"
+"\n"
+"Shall I adjust those settings in order to enable the Wipe Tower?"
+msgstr ""
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:599
+msgid ""
+"For the Wipe Tower to work with the soluble supports, the support layers\n"
+"need to be synchronized with the object layers.\n"
+"\n"
+"Shall I synchronize support layers in order to enable the Wipe Tower?"
+msgstr ""
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:617
+msgid ""
+"Supports work better, if the following feature is enabled:\n"
+"- Detect bridging perimeters\n"
+"\n"
+"Shall I adjust those settings for supports?"
+msgstr ""
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:620
+msgid "Support Generator"
+msgstr "Generátor Podpor"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:662
+msgid "The "
+msgstr ""
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:662
+#, no-c-format
+msgid ""
+" infill pattern is not supposed to work at 100% density.\n"
+"\n"
+"Shall I switch to rectilinear fill pattern?"
+msgstr ""
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:785
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:786
+msgid "Filament"
+msgstr "Filament"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:817
+msgid "Fan speed"
+msgstr "Rychlost ventilátoru"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:825
+msgid "Cooling thresholds"
+msgstr "Práh chlazení"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:831
+msgid "Filament properties"
+msgstr "Vlastnosti filamentu"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:988
+msgid "USB/Serial connection"
+msgstr "USB/Sériové připojení"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:994
+msgid "Rescan serial ports"
+msgstr "Znovu prohledat sériové porty"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1149
+msgid "Between objects G-code (for sequential printing)"
+msgstr "Between objects G-code (for sequential printing)"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1185
+msgid "Extruder "
+msgstr "Extrudér "
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1199
+msgid "Retraction"
+msgstr "Retrakce"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1202
+msgid "Only lift Z"
+msgstr "Pouze zvednout Z"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1312
+msgid "Firmware Retraction"
+msgstr "Firmware Retrakce"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1467
+msgid "Default "
+msgstr "Výchozí "
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1467
+msgid " preset"
+msgstr " přednastavení"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1468
+msgid " preset\n"
+msgstr " přednastavení\n"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1486
+msgid ""
+"\n"
+"\n"
+"is not compatible with printer\n"
+msgstr ""
+"\n"
+"\n"
+"není kompatibilní s tiskárnou\n"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1486
+msgid ""
+"\n"
+"\n"
+"and it has the following unsaved changes:"
+msgstr ""
+"\n"
+"\n"
+"a má neuložené následující změny:"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1487
+msgid ""
+"\n"
+"\n"
+"has the following unsaved changes:"
+msgstr ""
+"\n"
+"\n"
+"má neuložené následující změny:"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1489
+msgid ""
+"\n"
+"\n"
+"Discard changes and continue anyway?"
+msgstr ""
+"\n"
+"\n"
+"Zahodit změny a přesto pokračovat?"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1490
+msgid "Unsaved Changes"
+msgstr "Neuložené Změny"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:228
+msgid "Printer Settings"
+msgstr "Nastavení tiskárny"
diff --git a/resources/localization/en_US/Slic3rPE.mo b/resources/localization/en_US/Slic3rPE.mo
new file mode 100644
index 000000000..f967df550
Binary files /dev/null and b/resources/localization/en_US/Slic3rPE.mo differ
diff --git a/resources/localization/en_US/Slic3rPE_en.po b/resources/localization/en_US/Slic3rPE_en.po
new file mode 100644
index 000000000..b0ee7f2e5
--- /dev/null
+++ b/resources/localization/en_US/Slic3rPE_en.po
@@ -0,0 +1,3016 @@
+# Copyright (C) 2018 THE Slic3rPE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the Slic3rPE package.
+# Oleksandra Iushchenko <yusanka@gmail.com>, 2018.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: SLIC3R PE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2018-02-13 17:18+0100\n"
+"PO-Revision-Date: 2018-02-15 18:17+0100\n"
+"Last-Translator: Oleksandra Iushchenko <yusanka@gmail.com>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 2.0.6\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"Language: en_US\n"
+"X-Poedit-KeywordsList: _L\n"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:50
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1188
+msgid "Size"
+msgstr "Size"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:51
+msgid "Size in X and Y of the rectangular plate."
+msgstr "Size in X and Y of the rectangular plate."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:57
+msgid "Origin"
+msgstr "Origin"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:58
+msgid ""
+"Distance of the 0,0 G-code coordinate from the front left corner of the "
+"rectangle."
+msgstr ""
+"Distance of the 0,0 G-code coordinate from the front left corner of the "
+"rectangle."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:65
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:133
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:204
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:215
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:329
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:340
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:359
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:438
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:783
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:803
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:862
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:880
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:898
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1046
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1054
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1096
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1105
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1115
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1123
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1131
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1217
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1423
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1493
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1529
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1706
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1713
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1720
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1729
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1739
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1749
+msgid "mm"
+msgstr "mm"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:66
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:435
+msgid "Diameter"
+msgstr "Diameter"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:67
+msgid ""
+"Diameter of the print bed. It is assumed that origin (0,0) is located in the "
+"center."
+msgstr ""
+"Diameter of the print bed. It is assumed that origin (0,0) is located in the "
+"center."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:965
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:312
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:704
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:960
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1274
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1447
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1473
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:432
+msgid "Extruders"
+msgstr "Extruders"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:966
+msgid "Number of extruders of the printer."
+msgstr "Number of extruders of the printer."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:30
+msgid "Avoid crossing perimeters"
+msgstr "Avoid crossing perimeters"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:31
+msgid ""
+"Optimize travel moves in order to minimize the crossing of perimeters. This "
+"is mostly useful with Bowden extruders which suffer from oozing. This "
+"feature slows down both the print and the G-code generation."
+msgstr ""
+"Optimize travel moves in order to minimize the crossing of perimeters. This "
+"is mostly useful with Bowden extruders which suffer from oozing. This "
+"feature slows down both the print and the G-code generation."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:38
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:939
+msgid "Bed shape"
+msgstr "Bed shape"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:42
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1574
+msgid "Other layers"
+msgstr "Other layers"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:43
+msgid ""
+"Bed temperature for layers after the first one. Set this to zero to disable "
+"bed temperature control commands in the output."
+msgstr ""
+"Bed temperature for layers after the first one. Set this to zero to disable "
+"bed temperature control commands in the output."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:46
+msgid "Bed temperature"
+msgstr "Bed temperature"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:52
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1131
+msgid "Before layer change G-code"
+msgstr "Before layer change G-code"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:53
+msgid ""
+"This custom code is inserted at every layer change, right before the Z move. "
+"Note that you can use placeholder variables for all Slic3r settings as well "
+"as [layer_num] and [layer_z]."
+msgstr ""
+"This custom code is inserted at every layer change, right before the Z move. "
+"Note that you can use placeholder variables for all Slic3r settings as well "
+"as [layer_num] and [layer_z]."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:63
+msgid "Between objects G-code"
+msgstr "Between objects G-code"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:64
+msgid ""
+"This code is inserted between objects when using sequential printing. By "
+"default extruder and bed temperature are reset using non-wait command; "
+"however if M104, M109, M140 or M190 are detected in this custom code, Slic3r "
+"will not add temperature commands. Note that you can use placeholder "
+"variables for all Slic3r settings, so you can put a \"M109 "
+"S[first_layer_temperature]\" command wherever you want."
+msgstr ""
+"This code is inserted between objects when using sequential printing. By "
+"default extruder and bed temperature are reset using non-wait command; "
+"however if M104, M109, M140 or M190 are detected in this custom code, Slic3r "
+"will not add temperature commands. Note that you can use placeholder "
+"variables for all Slic3r settings, so you can put a \"M109 "
+"S[first_layer_temperature]\" command wherever you want."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:72
+msgid "Bottom"
+msgstr "Bottom"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:73
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:243
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:294
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:302
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:606
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:764
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:780
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:943
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:991
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1154
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1585
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1641
+msgid "Layers and Perimeters"
+msgstr "Layers and perimeters"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:74
+msgid "Number of solid layers to generate on bottom surfaces."
+msgstr "Number of solid layers to generate on bottom surfaces."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:76
+msgid "Bottom solid layers"
+msgstr "Bottom solid layers"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:81
+msgid "Bridge"
+msgstr "Bridge"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:82
+msgid ""
+"This is the acceleration your printer will use for bridges. Set zero to "
+"disable acceleration control for bridges."
+msgstr ""
+"This is the acceleration your printer will use for bridges. Set zero to "
+"disable acceleration control for bridges."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:84
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:178
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:578
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:686
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:954
+msgid "mm/s\\u00B2"
+msgstr "mm/s\\u00B2"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:90
+msgid "Bridging angle"
+msgstr "Bridging angle"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:91
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:251
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:492
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:506
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:544
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:683
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:693
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:711
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:729
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:748
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1265
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1282
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:347
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:348
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:664
+msgid "Infill"
+msgstr "Infill"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:92
+msgid ""
+"Bridging angle override. If left to zero, the bridging angle will be "
+"calculated automatically. Otherwise the provided angle will be used for all "
+"bridges. Use 180\\u00B0 for zero angle."
+msgstr ""
+"Bridging angle override. If left to zero, the bridging angle will be "
+"calculated automatically. Otherwise the provided angle will be used for all "
+"bridges. Use 180\\u00B0 for zero angle."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:95
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:496
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1172
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1183
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1403
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1559
+msgid "\\u00B0"
+msgstr "\\u00B0"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:101
+msgid "Bridges fan speed"
+msgstr "Bridges fan speed"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:102
+msgid "This fan speed is enforced during all bridges and overhangs."
+msgstr "This fan speed is enforced during all bridges and overhangs."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:103
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:508
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:791
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:852
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1062
+msgid "%"
+msgstr "%"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:110
+msgid "Bridge flow ratio"
+msgstr "Bridge flow ratio"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:111
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:212
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:738
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1735
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:343
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:357
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:450
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:453
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:830
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1112
+msgid "Advanced"
+msgstr "Advanced"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:112
+msgid ""
+"This factor affects the amount of plastic for bridging. You can decrease it "
+"slightly to pull the extrudates and prevent sagging, although default "
+"settings are usually good and you should experiment with cooling (use a fan) "
+"before tweaking this."
+msgstr ""
+"This factor affects the amount of plastic for bridging. You can decrease it "
+"slightly to pull the extrudates and prevent sagging, although default "
+"settings are usually good and you should experiment with cooling (use a fan) "
+"before tweaking this."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:121
+msgid "Bridges"
+msgstr "Bridges"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:122
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:282
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:637
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:749
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:981
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1203
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1253
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1304
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1627
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:399
+msgid "Speed"
+msgstr "Speed"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:123
+msgid "Speed for printing bridges."
+msgstr "Speed for printing bridges."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:124
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:640
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:751
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:813
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:870
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:983
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1139
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1148
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1538
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1651
+msgid "mm/s"
+msgstr "mm/s"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:131
+msgid "Brim width"
+msgstr "Brim width"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:132
+msgid ""
+"Horizontal width of the brim that will be printed around each object on the "
+"first layer."
+msgstr ""
+"Horizontal width of the brim that will be printed around each object on the "
+"first layer."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:139
+msgid "Clip multi-part objects"
+msgstr "Clip multi-part objects"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:140
+msgid ""
+"When printing multi-material objects, this settings will make slic3r to clip "
+"the overlapping object parts one by the other (2nd part will be clipped by "
+"the 1st, 3rd part will be clipped by the 1st and 2nd etc)."
+msgstr ""
+"When printing multi-material objects, this settings will make slic3r to clip "
+"the overlapping object parts one by the other (2nd part will be clipped by "
+"the 1st, 3rd part will be clipped by the 1st and 2nd etc)."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:147
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:510
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:868
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1673
+msgid "Compatible printers"
+msgstr "Compatible printers"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:151
+msgid "Compatible printers condition"
+msgstr "Compatible printers condition"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:152
+msgid ""
+"A boolean expression using the configuration values of an active printer "
+"profile. If this expression evaluates to true, this profile is considered "
+"compatible with the active printer profile."
+msgstr ""
+"A boolean expression using the configuration values of an active printer "
+"profile. If this expression evaluates to true, this profile is considered "
+"compatible with the active printer profile."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:158
+msgid "Complete individual objects"
+msgstr "Complete individual objects"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:159
+msgid ""
+"When printing multiple objects or copies, this feature will complete each "
+"object before moving onto next one (and starting it from its bottom layer). "
+"This feature is useful to avoid the risk of ruined prints. Slic3r should "
+"warn and prevent you from extruder collisions, but beware."
+msgstr ""
+"When printing multiple objects or copies, this feature will complete each "
+"object before moving onto next one (and starting it from its bottom layer). "
+"This feature is useful to avoid the risk of ruined prints. Slic3r should "
+"warn and prevent you from extruder collisions, but beware."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:167
+msgid "Enable auto cooling"
+msgstr "Enable auto cooling"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:168
+msgid ""
+"This flag enables the automatic cooling logic that adjusts print speed and "
+"fan speed according to layer printing time."
+msgstr ""
+"This flag enables the automatic cooling logic that adjusts print speed and "
+"fan speed according to layer printing time."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:174
+#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:293
+msgid "Default"
+msgstr "Default"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:175
+msgid ""
+"This is the acceleration your printer will be reset to after the role-"
+"specific acceleration values are used (perimeter/infill). Set zero to "
+"prevent resetting acceleration at all."
+msgstr ""
+"This is the acceleration your printer will be reset to after the role-"
+"specific acceleration values are used (perimeter/infill). Set zero to "
+"prevent resetting acceleration at all."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:184
+msgid "Disable fan for the first"
+msgstr "Disable fan for the first"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:185
+msgid ""
+"You can set this to a positive value to disable fan at all during the first "
+"layers, so that it does not make adhesion worse."
+msgstr ""
+"You can set this to a positive value to disable fan at all during the first "
+"layers, so that it does not make adhesion worse."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:187
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:696
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1035
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1226
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1287
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1439
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1484
+msgid "layers"
+msgstr "layers"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:194
+msgid "Don't support bridges"
+msgstr "Don't support bridges"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:195
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1032
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1382
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1389
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1401
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1411
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1419
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1434
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1455
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1466
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1482
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1491
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1500
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1511
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1527
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1535
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1536
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1545
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1553
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1567
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:375
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:376
+msgid "Support material"
+msgstr "Support material"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:196
+msgid ""
+"Experimental option for preventing support material from being generated "
+"under bridged areas."
+msgstr ""
+"Experimental option for preventing support material from being generated "
+"under bridged areas."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:202
+msgid "Distance between copies"
+msgstr "Distance between copies"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:203
+msgid "Distance used for the auto-arrange feature of the plater."
+msgstr "Distance used for the auto-arrange feature of the plater."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:211
+msgid "Elefant foot compensation"
+msgstr "Elefant foot compensation"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:213
+msgid ""
+"The first layer will be shrunk in the XY plane by the configured value to "
+"compensate for the 1st layer squish aka an Elefant Foot effect."
+msgstr ""
+"The first layer will be shrunk in the XY plane by the configured value to "
+"compensate for the 1st layer squish aka an Elefant Foot effect."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:221
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:231
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:852
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1125
+msgid "End G-code"
+msgstr "End G-code"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:222
+msgid ""
+"This end procedure is inserted at the end of the output file. Note that you "
+"can use placeholder variables for all Slic3r settings."
+msgstr ""
+"This end procedure is inserted at the end of the output file. Note that you "
+"can use placeholder variables for all Slic3r settings."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:232
+msgid ""
+"This end procedure is inserted at the end of the output file, before the "
+"printer end gcode. Note that you can use placeholder variables for all "
+"Slic3r settings. If you have multiple extruders, the gcode is processed in "
+"extruder order."
+msgstr ""
+"This end procedure is inserted at the end of the output file, before the "
+"printer end gcode. Note that you can use placeholder variables for all "
+"Slic3r settings. If you have multiple extruders, the gcode is processed in "
+"extruder order."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:242
+msgid "Ensure vertical shell thickness"
+msgstr "Ensure vertical shell thickness"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:244
+msgid ""
+"Add solid infill near sloping surfaces to guarantee the vertical shell "
+"thickness (top+bottom solid layers)."
+msgstr ""
+"Add solid infill near sloping surfaces to guarantee the vertical shell "
+"thickness (top+bottom solid layers)."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:250
+msgid "Top/bottom fill pattern"
+msgstr "Top/bottom fill pattern"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:252
+msgid ""
+"Fill pattern for top/bottom infill. This only affects the external visible "
+"layer, and not its adjacent solid shells."
+msgstr ""
+"Fill pattern for top/bottom infill. This only affects the external visible "
+"layer, and not its adjacent solid shells."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:271
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:281
+msgid "External perimeters"
+msgstr "External perimeters"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:272
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:381
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:594
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:712
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:969
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1294
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1456
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1616
+msgid "Extrusion Width"
+msgstr "Extrusion width"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:273
+msgid ""
+"Set this to a non-zero value to set a manual extrusion width for external "
+"perimeters. If left zero, default extrusion width will be used if set, "
+"otherwise 1.125 x nozzle diameter will be used. If expressed as percentage "
+"(for example 200%), it will be computed over layer height."
+msgstr ""
+"Set this to a non-zero value to set a manual extrusion width for external "
+"perimeters. If left zero, default extrusion width will be used if set, "
+"otherwise 1.125 x nozzle diameter will be used. If expressed as percentage "
+"(for example 200%), it will be computed over layer height."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:276
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:599
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:717
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:974
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1298
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1460
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1621
+msgid "mm or % (leave 0 for default)"
+msgstr "mm or % (leave 0 for default)"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:283
+msgid ""
+"This separate setting will affect the speed of external perimeters (the "
+"visible ones). If expressed as percentage (for example: 80%) it will be "
+"calculated on the perimeters speed setting above. Set to zero for auto."
+msgstr ""
+"This separate setting will affect the speed of external perimeters (the "
+"visible ones). If expressed as percentage (for example: 80%) it will be "
+"calculated on the perimeters speed setting above. Set to zero for auto."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:286
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:621
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1257
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1308
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1503
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1633
+msgid "mm/s or %"
+msgstr "mm/s or %"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:293
+msgid "External perimeters first"
+msgstr "External perimeters first"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:295
+msgid ""
+"Print contour perimeters from the outermost one to the innermost one instead "
+"of the default inverse order."
+msgstr ""
+"Print contour perimeters from the outermost one to the innermost one instead "
+"of the default inverse order."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:301
+msgid "Extra perimeters if needed"
+msgstr "Extra perimeters if needed"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:303
+#, c-format
+msgid ""
+"Add more perimeters when needed for avoiding gaps in sloping walls. Slic3r "
+"keeps adding perimeters, until more than 70% of the loop immediately above "
+"is supported."
+msgstr ""
+"Add more perimeters when needed for avoiding gaps in sloping walls. Slic3r "
+"keeps adding perimeters, until more than 70% of the loop immediately above "
+"is supported."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:311
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:794
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1231
+msgid "Extruder"
+msgstr "Extruder"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:313
+msgid ""
+"The extruder to use (unless more specific extruder settings are specified). "
+"This value overrides perimeter and infill extruders, but not the support "
+"extruders."
+msgstr ""
+"The extruder to use (unless more specific extruder settings are specified). "
+"This value overrides perimeter and infill extruders, but not the support "
+"extruders."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:324
+msgid "Height"
+msgstr "Height"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:325
+msgid ""
+"Set this to the vertical distance between your nozzle tip and (usually) the "
+"X carriage rods. In other words, this is the height of the clearance "
+"cylinder around your extruder, and it represents the maximum depth the "
+"extruder can peek before colliding with other printed objects."
+msgstr ""
+"Set this to the vertical distance between your nozzle tip and (usually) the "
+"X carriage rods. In other words, this is the height of the clearance "
+"cylinder around your extruder, and it represents the maximum depth the "
+"extruder can peek before colliding with other printed objects."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:335
+msgid "Radius"
+msgstr "Radius"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:336
+msgid ""
+"Set this to the clearance radius around your extruder. If the extruder is "
+"not centered, choose the largest value for safety. This setting is used to "
+"check for collisions and to display the graphical preview in the plater."
+msgstr ""
+"Set this to the clearance radius around your extruder. If the extruder is "
+"not centered, choose the largest value for safety. This setting is used to "
+"check for collisions and to display the graphical preview in the plater."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:346
+msgid "Extruder Color"
+msgstr "Extruder Color"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:347
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:410
+msgid "This is only used in the Slic3r interface as a visual help."
+msgstr "This is only used in the Slic3r interface as a visual help."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:354
+msgid "Extruder offset"
+msgstr "Extruders offset"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:355
+msgid ""
+"If your firmware doesn't handle the extruder displacement you need the G-"
+"code to take it into account. This option lets you specify the displacement "
+"of each extruder with respect to the first one. It expects positive "
+"coordinates (they will be subtracted from the XY coordinate)."
+msgstr ""
+"If your firmware doesn't handle the extruder displacement you need the G-"
+"code to take it into account. This option lets you specify the displacement "
+"of each extruder with respect to the first one. It expects positive "
+"coordinates (they will be subtracted from the XY coordinate)."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:364
+msgid "Extrusion axis"
+msgstr "Extrusion axis"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:365
+msgid ""
+"Use this option to set the axis letter associated to your printer's extruder "
+"(usually E but some printers use A)."
+msgstr ""
+"Use this option to set the axis letter associated to your printer's extruder "
+"(usually E but some printers use A)."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:371
+msgid "Extrusion multiplier"
+msgstr "Extrusion multiplier"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:372
+msgid ""
+"This factor changes the amount of flow proportionally. You may need to tweak "
+"this setting to get nice surface finish and correct single wall widths. "
+"Usual values are between 0.9 and 1.1. If you think you need to change this "
+"more, check filament diameter and your firmware E steps."
+msgstr ""
+"This factor changes the amount of flow proportionally. You may need to tweak "
+"this setting to get nice surface finish and correct single wall widths. "
+"Usual values are between 0.9 and 1.1. If you think you need to change this "
+"more, check filament diameter and your firmware E steps."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:380
+msgid "Default extrusion width"
+msgstr "Default extrusion width"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:382
+msgid ""
+"Set this to a non-zero value to allow a manual extrusion width. If left to "
+"zero, Slic3r derives extrusion widths from the nozzle diameter (see the "
+"tooltips for perimeter extrusion width, infill extrusion width etc). If "
+"expressed as percentage (for example: 230%), it will be computed over layer "
+"height."
+msgstr ""
+"Set this to a non-zero value to allow a manual extrusion width. If left to "
+"zero, Slic3r derives extrusion widths from the nozzle diameter (see the "
+"tooltips for perimeter extrusion width, infill extrusion width etc). If "
+"expressed as percentage (for example: 230%), it will be computed over layer "
+"height."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:386
+msgid "mm or % (leave 0 for auto)"
+msgstr "mm or % (leave 0 for auto)"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:391
+msgid "Keep fan always on"
+msgstr "Keep fan always on"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:392
+msgid ""
+"If this is enabled, fan will never be disabled and will be kept running at "
+"least at its minimum speed. Useful for PLA, harmful for ABS."
+msgstr ""
+"If this is enabled, fan will never be disabled and will be kept running at "
+"least at its minimum speed. Useful for PLA, harmful for ABS."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:398
+msgid "Enable fan if layer print time is below"
+msgstr "Enable fan if layer print time is below"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:399
+msgid ""
+"If layer print time is estimated below this number of seconds, fan will be "
+"enabled and its speed will be calculated by interpolating the minimum and "
+"maximum speeds."
+msgstr ""
+"If layer print time is estimated below this number of seconds, fan will be "
+"enabled and its speed will be calculated by interpolating the minimum and "
+"maximum speeds."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:401
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1244
+msgid "approximate seconds"
+msgstr "approximate seconds"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:409
+msgid "Color"
+msgstr "Color"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:416
+msgid "Filament notes"
+msgstr "Filament notes"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:417
+msgid "You can put your notes regarding the filament here."
+msgstr "You can put your notes regarding the filament here."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:425
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:819
+msgid "Max volumetric speed"
+msgstr "Max volumetric speed"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:426
+msgid ""
+"Maximum volumetric speed allowed for this filament. Limits the maximum "
+"volumetric speed of a print to the minimum of print and filament volumetric "
+"speed. Set to zero for no limit."
+msgstr ""
+"Maximum volumetric speed allowed for this filament. Limits the maximum "
+"volumetric speed of a print to the minimum of print and filament volumetric "
+"speed. Set to zero for no limit."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:429
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:822
+msgid "mm\\u00B3/s"
+msgstr "mm\\u00B3/s"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:436
+msgid ""
+"Enter your filament diameter here. Good precision is required, so use a "
+"caliper and do multiple measurements along the filament, then compute the "
+"average."
+msgstr ""
+"Enter your filament diameter here. Good precision is required, so use a "
+"caliper and do multiple measurements along the filament, then compute the "
+"average."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:444
+msgid "Density"
+msgstr "Density"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:445
+msgid ""
+"Enter your filament density here. This is only for statistical information. "
+"A decent way is to weigh a known length of filament and compute the ratio of "
+"the length to volume. Better is to calculate the volume directly through "
+"displacement."
+msgstr ""
+"Enter your filament density here. This is only for statistical information. "
+"A decent way is to weigh a known length of filament and compute the ratio of "
+"the length to volume. Better is to calculate the volume directly through "
+"displacement."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:448
+msgid "g/cm\\u00B3"
+msgstr "g/cm\\u00B3"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:454
+msgid "Filament type"
+msgstr "Filament type"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:455
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1004
+msgid ""
+"If you want to process the output G-code through custom scripts, just list "
+"their absolute paths here. Separate multiple scripts with a semicolon. "
+"Scripts will be passed the absolute path to the G-code file as the first "
+"argument, and they can access the Slic3r config settings by reading "
+"environment variables."
+msgstr ""
+"If you want to process the output G-code through custom scripts, just list "
+"their absolute paths here. Separate multiple scripts with a semicolon. "
+"Scripts will be passed the absolute path to the G-code file as the first "
+"argument, and they can access the Slic3r config settings by reading "
+"environment variables."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:474
+msgid "Soluble material"
+msgstr "Soluble material"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:475
+msgid "Soluble material is most likely used for a soluble support."
+msgstr "Soluble material is most likely used for a soluble support."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:480
+msgid "Cost"
+msgstr "Cost"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:481
+msgid ""
+"Enter your filament cost per kg here. This is only for statistical "
+"information."
+msgstr ""
+"Enter your filament cost per kg here. This is only for statistical "
+"information."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:482
+msgid "money/kg"
+msgstr "money/kg"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:491
+msgid "Fill angle"
+msgstr "Fill angle"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:493
+msgid ""
+"Default base angle for infill orientation. Cross-hatching will be applied to "
+"this. Bridges will be infilled using the best direction Slic3r can detect, "
+"so this setting does not affect them."
+msgstr ""
+"Default base angle for infill orientation. Cross-hatching will be applied to "
+"this. Bridges will be infilled using the best direction Slic3r can detect, "
+"so this setting does not affect them."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:505
+msgid "Fill density"
+msgstr "Fill density"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:507
+#, c-format
+msgid "Density of internal infill, expressed in the range 0% - 100%."
+msgstr "Density of internal infill, expressed in the range 0% - 100%."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:543
+msgid "Fill pattern"
+msgstr "Fill pattern"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:545
+msgid "Fill pattern for general low-density infill."
+msgstr "Fill pattern for general low-density infill."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:575
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:584
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:593
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:627
+msgid "First layer"
+msgstr "First layers"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:576
+msgid ""
+"This is the acceleration your printer will use for first layer. Set zero to "
+"disable acceleration control for first layer."
+msgstr ""
+"This is the acceleration your printer will use for first layer. Set zero to "
+"disable acceleration control for first layer."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:585
+msgid ""
+"Heated build plate temperature for the first layer. Set this to zero to "
+"disable bed temperature control commands in the output."
+msgstr ""
+"Heated build plate temperature for the first layer. Set this to zero to "
+"disable bed temperature control commands in the output."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:595
+msgid ""
+"Set this to a non-zero value to set a manual extrusion width for first "
+"layer. You can use this to force fatter extrudates for better adhesion. If "
+"expressed as percentage (for example 120%) it will be computed over first "
+"layer height. If set to zero, it will use the default extrusion width."
+msgstr ""
+"Set this to a non-zero value to set a manual extrusion width for first "
+"layer. You can use this to force fatter extrudates for better adhesion. If "
+"expressed as percentage (for example 120%) it will be computed over first "
+"layer height. If set to zero, it will use the default extrusion width."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:605
+msgid "First layer height"
+msgstr "First layer height"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:607
+msgid ""
+"When printing with very low layer heights, you might still want to print a "
+"thicker bottom layer to improve adhesion and tolerance for non perfect build "
+"plates. This can be expressed as an absolute value or as a percentage (for "
+"example: 150%) over the default layer height."
+msgstr ""
+"When printing with very low layer heights, you might still want to print a "
+"thicker bottom layer to improve adhesion and tolerance for non perfect build "
+"plates. This can be expressed as an absolute value or as a percentage (for "
+"example: 150%) over the default layer height."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:611
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:742
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1392
+msgid "mm or %"
+msgstr "mm or %"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:617
+msgid "First layer speed"
+msgstr "First layer speed"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:618
+msgid ""
+"If expressed as absolute value in mm/s, this speed will be applied to all "
+"the print moves of the first layer, regardless of their type. If expressed "
+"as a percentage (for example: 40%) it will scale the default speeds."
+msgstr ""
+"If expressed as absolute value in mm/s, this speed will be applied to all "
+"the print moves of the first layer, regardless of their type. If expressed "
+"as a percentage (for example: 40%) it will scale the default speeds."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:628
+msgid ""
+"Extruder temperature for first layer. If you want to control temperature "
+"manually during print, set this to zero to disable temperature control "
+"commands in the output file."
+msgstr ""
+"Extruder temperature for first layer. If you want to control temperature "
+"manually during print, set this to zero to disable temperature control "
+"commands in the output file."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:636
+msgid "Gap fill"
+msgstr "Gap fill"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:638
+msgid ""
+"Speed for filling small gaps using short zigzag moves. Keep this reasonably "
+"low to avoid too much shaking and resonance issues. Set zero to disable gaps "
+"filling."
+msgstr ""
+"Speed for filling small gaps using short zigzag moves. Keep this reasonably "
+"low to avoid too much shaking and resonance issues. Set zero to disable gaps "
+"filling."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:646
+msgid "Verbose G-code"
+msgstr "Verbose G-code"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:647
+msgid ""
+"Enable this to get a commented G-code file, with each line explained by a "
+"descriptive text. If you print from SD card, the additional weight of the "
+"file could make your firmware slow down."
+msgstr ""
+"Enable this to get a commented G-code file, with each line explained by a "
+"descriptive text. If you print from SD card, the additional weight of the "
+"file could make your firmware slow down."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:654
+msgid "G-code flavor"
+msgstr "G-code flavor"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:655
+msgid ""
+"Some G/M-code commands, including temperature control and others, are not "
+"universal. Set this option to your printer's firmware to get a compatible "
+"output. The \"No extrusion\" flavor prevents Slic3r from exporting any "
+"extrusion value at all."
+msgstr ""
+"Some G/M-code commands, including temperature control and others, are not "
+"universal. Set this option to your printer's firmware to get a compatible "
+"output. The \"No extrusion\" flavor prevents Slic3r from exporting any "
+"extrusion value at all."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:684
+msgid ""
+"This is the acceleration your printer will use for infill. Set zero to "
+"disable acceleration control for infill."
+msgstr ""
+"This is the acceleration your printer will use for infill. Set zero to "
+"disable acceleration control for infill."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:692
+msgid "Combine infill every"
+msgstr "Combine infill every"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:694
+msgid ""
+"This feature allows to combine infill and speed up your print by extruding "
+"thicker infill layers while preserving thin perimeters, thus accuracy."
+msgstr ""
+"This feature allows to combine infill and speed up your print by extruding "
+"thicker infill layers while preserving thin perimeters, thus accuracy."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:698
+msgid "Combine infill every n layers"
+msgstr "Combine infill every n layers"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:703
+msgid "Infill extruder"
+msgstr "Infill extruder"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:705
+msgid "The extruder to use when printing infill."
+msgstr "The extruder to use when printing infill."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:713
+msgid ""
+"Set this to a non-zero value to set a manual extrusion width for infill. If "
+"left zero, default extrusion width will be used if set, otherwise 1.125 x "
+"nozzle diameter will be used. You may want to use fatter extrudates to speed "
+"up the infill and make your parts stronger. If expressed as percentage (for "
+"example 90%) it will be computed over layer height."
+msgstr ""
+"Set this to a non-zero value to set a manual extrusion width for infill. If "
+"left zero, default extrusion width will be used if set, otherwise 1.125 x "
+"nozzle diameter will be used. You may want to use fatter extrudates to speed "
+"up the infill and make your parts stronger. If expressed as percentage (for "
+"example 90%) it will be computed over layer height."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:722
+msgid "Infill before perimeters"
+msgstr "Infill before perimeters"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:723
+msgid ""
+"This option will switch the print order of perimeters and infill, making the "
+"latter first."
+msgstr ""
+"This option will switch the print order of perimeters and infill, making the "
+"latter first."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:728
+msgid "Only infill where needed"
+msgstr "Only infill where needed"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:730
+msgid ""
+"This option will limit infill to the areas actually needed for supporting "
+"ceilings (it will act as internal support material). If enabled, slows down "
+"the G-code generation due to the multiple checks involved."
+msgstr ""
+"This option will limit infill to the areas actually needed for supporting "
+"ceilings (it will act as internal support material). If enabled, slows down "
+"the G-code generation due to the multiple checks involved."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:737
+msgid "Infill/perimeters overlap"
+msgstr "Infill/perimeters overlap"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:739
+msgid ""
+"This setting applies an additional overlap between infill and perimeters for "
+"better bonding. Theoretically this shouldn't be needed, but backlash might "
+"cause gaps. If expressed as percentage (example: 15%) it is calculated over "
+"perimeter extrusion width."
+msgstr ""
+"This setting applies an additional overlap between infill and perimeters for "
+"better bonding. Theoretically this shouldn't be needed, but backlash might "
+"cause gaps. If expressed as percentage (example: 15%) it is calculated over "
+"perimeter extrusion width."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:750
+msgid "Speed for printing the internal fill. Set to zero for auto."
+msgstr "Speed for printing the internal fill. Set to zero for auto."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:759
+msgid "Interface shells"
+msgstr "Interface shells"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:760
+msgid ""
+"Force the generation of solid shells between adjacent materials/volumes. "
+"Useful for multi-extruder prints with translucent materials or manual "
+"soluble support material."
+msgstr ""
+"Force the generation of solid shells between adjacent materials/volumes. "
+"Useful for multi-extruder prints with translucent materials or manual "
+"soluble support material."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:768
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1137
+msgid "After layer change G-code"
+msgstr "After layer change G-code"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:769
+msgid ""
+"This custom code is inserted at every layer change, right after the Z move "
+"and before the extruder moves to the first layer point. Note that you can "
+"use placeholder variables for all Slic3r settings as well as [layer_num] and "
+"[layer_z]."
+msgstr ""
+"This custom code is inserted at every layer change, right after the Z move "
+"and before the extruder moves to the first layer point. Note that you can "
+"use placeholder variables for all Slic3r settings as well as [layer_num] and "
+"[layer_z]."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:779
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:315
+msgid "Layer height"
+msgstr "Layer height"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:781
+msgid ""
+"This setting controls the height (and thus the total number) of the slices/"
+"layers. Thinner layers give better accuracy but take more time to print."
+msgstr ""
+"This setting controls the height (and thus the total number) of the slices/"
+"layers. Thinner layers give better accuracy but take more time to print."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:789
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:798
+msgid "Max"
+msgstr "Max"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:790
+msgid "This setting represents the maximum speed of your fan."
+msgstr "This setting represents the maximum speed of your fan."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:799
+#, c-format
+msgid ""
+"This is the highest printable layer height for this extruder, used to cap "
+"the variable layer height and support layer height. Maximum recommended "
+"layer height is 75% of the extrusion width to achieve reasonable inter-layer "
+"adhesion. If set to 0, layer height is limited to 75% of the nozzle diameter."
+msgstr ""
+"This is the highest printable layer height for this extruder, used to cap "
+"the variable layer height and support layer height. Maximum recommended "
+"layer height is 75% of the extrusion width to achieve reasonable inter-layer "
+"adhesion. If set to 0, layer height is limited to 75% of the nozzle diameter."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:809
+msgid "Max print speed"
+msgstr "Max print speed"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:810
+msgid ""
+"When setting other speed settings to 0 Slic3r will autocalculate the optimal "
+"speed in order to keep constant extruder pressure. This experimental setting "
+"is used to set the highest print speed you want to allow."
+msgstr ""
+"When setting other speed settings to 0 Slic3r will autocalculate the optimal "
+"speed in order to keep constant extruder pressure. This experimental setting "
+"is used to set the highest print speed you want to allow."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:820
+msgid ""
+"This experimental setting is used to set the maximum volumetric speed your "
+"extruder supports."
+msgstr ""
+"This experimental setting is used to set the maximum volumetric speed your "
+"extruder supports."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:828
+msgid "Max volumetric slope positive"
+msgstr "Max volumetric slope positive"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:829
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:840
+msgid ""
+"This experimental setting is used to limit the speed of change in extrusion "
+"rate. A value of 1.8 mm\\u00B3/s\\u00B2 ensures, that a change from the "
+"extrusion rate of 1.8 mm\\u00B3/s (0.45mm extrusion width, 0.2mm extrusion "
+"height, feedrate 20 mm/s) to 5.4 mm\\u00B3/s (feedrate 60 mm/s) will take at "
+"least 2 seconds."
+msgstr ""
+"This experimental setting is used to limit the speed of change in extrusion "
+"rate. A value of 1.8 mm\\u00B3/s\\u00B2 ensures, that a change from the "
+"extrusion rate of 1.8 mm\\u00B3/s (0.45mm extrusion width, 0.2mm extrusion "
+"height, feedrate 20 mm/s) to 5.4 mm\\u00B3/s (feedrate 60 mm/s) will take at "
+"least 2 seconds."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:833
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:844
+msgid "mm\\u00B3/s\\u00B2"
+msgstr "mm\\u00B3/s\\u00B2"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:839
+msgid "Max volumetric slope negative"
+msgstr "Max volumetric slope negative"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:850
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:859
+msgid "Min"
+msgstr "Min"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:851
+msgid "This setting represents the minimum PWM your fan needs to work."
+msgstr "This setting represents the minimum PWM your fan needs to work."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:860
+msgid ""
+"This is the lowest printable layer height for this extruder and limits the "
+"resolution for variable layer height. Typical values are between 0.05 mm and "
+"0.1 mm."
+msgstr ""
+"This is the lowest printable layer height for this extruder and limits the "
+"resolution for variable layer height. Typical values are between 0.05 mm and "
+"0.1 mm."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:868
+msgid "Min print speed"
+msgstr "Min print speed"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:869
+msgid "Slic3r will not scale speed down below this speed."
+msgstr "Slic3r will not scale speed down below this speed."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:876
+msgid "Minimum extrusion length"
+msgstr "Minimum extrusion length"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:877
+msgid ""
+"Generate no less than the number of skirt loops required to consume the "
+"specified amount of filament on the bottom layer. For multi-extruder "
+"machines, this minimum applies to each extruder."
+msgstr ""
+"Generate no less than the number of skirt loops required to consume the "
+"specified amount of filament on the bottom layer. For multi-extruder "
+"machines, this minimum applies to each extruder."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:886
+msgid "Configuration notes"
+msgstr "Configuration notes"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:887
+msgid ""
+"You can put here your personal notes. This text will be added to the G-code "
+"header comments."
+msgstr ""
+"You can put here your personal notes. This text will be added to the G-code "
+"header comments."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:896
+msgid "Nozzle diameter"
+msgstr "Nozzle diameter"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:897
+msgid ""
+"This is the diameter of your extruder nozzle (for example: 0.5, 0.35 etc.)"
+msgstr ""
+"This is the diameter of your extruder nozzle (for example: 0.5, 0.35 etc.)"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:903
+msgid "API Key"
+msgstr "API Key"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:904
+msgid ""
+"Slic3r can upload G-code files to OctoPrint. This field should contain the "
+"API Key required for authentication."
+msgstr ""
+"Slic3r can upload G-code files to OctoPrint. This field should contain the "
+"API Key required for authentication."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:910
+msgid "Host or IP"
+msgstr "Host or IP"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:911
+msgid ""
+"Slic3r can upload G-code files to OctoPrint. This field should contain the "
+"hostname or IP address of the OctoPrint instance."
+msgstr ""
+"Slic3r can upload G-code files to OctoPrint. This field should contain the "
+"hostname or IP address of the OctoPrint instance."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:917
+msgid "Only retract when crossing perimeters"
+msgstr "Only retract when crossing perimeters"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:918
+msgid ""
+"Disables retraction when the travel path does not exceed the upper layer's "
+"perimeters (and thus any ooze will be probably invisible)."
+msgstr ""
+"Disables retraction when the travel path does not exceed the upper layer's "
+"perimeters (and thus any ooze will be probably invisible)."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:924
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1697
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:805
+msgid "Enable"
+msgstr "Enable"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:925
+msgid ""
+"This option will drop the temperature of the inactive extruders to prevent "
+"oozing. It will enable a tall skirt automatically and move extruders outside "
+"such skirt when changing temperatures."
+msgstr ""
+"This option will drop the temperature of the inactive extruders to prevent "
+"oozing. It will enable a tall skirt automatically and move extruders outside "
+"such skirt when changing temperatures."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:932
+msgid "Output filename format"
+msgstr "Output filename format"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:933
+msgid ""
+"You can use all configuration options as variables inside this template. For "
+"example: [layer_height], [fill_density] etc. You can also use [timestamp], "
+"[year], [month], [day], [hour], [minute], [second], [version], "
+"[input_filename], [input_filename_base]."
+msgstr ""
+"You can use all configuration options as variables inside this template. For "
+"example: [layer_height], [fill_density] etc. You can also use [timestamp], "
+"[year], [month], [day], [hour], [minute], [second], [version], "
+"[input_filename], [input_filename_base]."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:942
+msgid "Detect bridging perimeters"
+msgstr "Detect bridging perimeters"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:944
+msgid ""
+"Experimental option to adjust flow for overhangs (bridge flow will be used), "
+"to apply bridge speed to them and enable fan."
+msgstr ""
+"Experimental option to adjust flow for overhangs (bridge flow will be used), "
+"to apply bridge speed to them and enable fan."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:950
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:968
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:980
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:990
+msgid "Perimeters"
+msgstr "Perimeters"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:951
+msgid ""
+"This is the acceleration your printer will use for perimeters. A high value "
+"like 9000 usually gives good results if your hardware is up to the job. Set "
+"zero to disable acceleration control for perimeters."
+msgstr ""
+"This is the acceleration your printer will use for perimeters. A high value "
+"like 9000 usually gives good results if your hardware is up to the job. Set "
+"zero to disable acceleration control for perimeters."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:959
+msgid "Perimeter extruder"
+msgstr "Perimeter extruder"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:961
+msgid ""
+"The extruder to use when printing perimeters and brim. First extruder is 1."
+msgstr ""
+"The extruder to use when printing perimeters and brim. First extruder is 1."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:970
+msgid ""
+"Set this to a non-zero value to set a manual extrusion width for perimeters. "
+"You may want to use thinner extrudates to get more accurate surfaces. If "
+"left zero, default extrusion width will be used if set, otherwise 1.125 x "
+"nozzle diameter will be used. If expressed as percentage (for example 200%) "
+"it will be computed over layer height."
+msgstr ""
+"Set this to a non-zero value to set a manual extrusion width for perimeters. "
+"You may want to use thinner extrudates to get more accurate surfaces. If "
+"left zero, default extrusion width will be used if set, otherwise 1.125 x "
+"nozzle diameter will be used. If expressed as percentage (for example 200%) "
+"it will be computed over layer height."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:982
+msgid ""
+"Speed for perimeters (contours, aka vertical shells). Set to zero for auto."
+msgstr ""
+"Speed for perimeters (contours, aka vertical shells). Set to zero for auto."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:992
+msgid ""
+"This option sets the number of perimeters to generate for each layer. Note "
+"that Slic3r may increase this number automatically when it detects sloping "
+"surfaces which benefit from a higher number of perimeters if the Extra "
+"Perimeters option is enabled."
+msgstr ""
+"This option sets the number of perimeters to generate for each layer. Note "
+"that Slic3r may increase this number automatically when it detects sloping "
+"surfaces which benefit from a higher number of perimeters if the Extra "
+"Perimeters option is enabled."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:996
+msgid "(minimum)"
+msgstr "(minimum)"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1003
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:495
+msgid "Post-processing scripts"
+msgstr "Post-processing scripts"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1016
+msgid "Printer notes"
+msgstr "Printer notes"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1017
+msgid "You can put your notes regarding the printer here."
+msgstr "You can put your notes regarding the printer here."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1031
+msgid "Raft layers"
+msgstr "Raft layers"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1033
+msgid ""
+"The object will be raised by this number of layers, and support material "
+"will be generated under it."
+msgstr ""
+"The object will be raised by this number of layers, and support material "
+"will be generated under it."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1041
+msgid "Resolution"
+msgstr "Resolution"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1042
+msgid ""
+"Minimum detail resolution, used to simplify the input file for speeding up "
+"the slicing job and reducing memory usage. High-resolution models often "
+"carry more detail than printers can render. Set to zero to disable any "
+"simplification and use full resolution from input."
+msgstr ""
+"Minimum detail resolution, used to simplify the input file for speeding up "
+"the slicing job and reducing memory usage. High-resolution models often "
+"carry more detail than printers can render. Set to zero to disable any "
+"simplification and use full resolution from input."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1052
+msgid "Minimum travel after retraction"
+msgstr "Minimum travel after retraction"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1053
+msgid ""
+"Retraction is not triggered when travel moves are shorter than this length."
+msgstr ""
+"Retraction is not triggered when travel moves are shorter than this length."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1059
+msgid "Retract amount before wipe"
+msgstr "Retract amount before wipe"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1060
+msgid ""
+"With bowden extruders, it may be wise to do some amount of quick retract "
+"before doing the wipe movement."
+msgstr ""
+"With bowden extruders, it may be wise to do some amount of quick retract "
+"before doing the wipe movement."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1067
+msgid "Retract on layer change"
+msgstr "Retract on layer change"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1068
+msgid "This flag enforces a retraction whenever a Z move is done."
+msgstr "This flag enforces a retraction whenever a Z move is done."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1073
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1082
+msgid "Length"
+msgstr "Length"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1074
+msgid "Retraction Length"
+msgstr "Retraction Length"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1075
+msgid ""
+"When retraction is triggered, filament is pulled back by the specified "
+"amount (the length is measured on raw filament, before it enters the "
+"extruder)."
+msgstr ""
+"When retraction is triggered, filament is pulled back by the specified "
+"amount (the length is measured on raw filament, before it enters the "
+"extruder)."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1077
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1087
+msgid "mm (zero to disable)"
+msgstr "mm (zero to disable)"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1083
+msgid "Retraction Length (Toolchange)"
+msgstr "Retraction Length (Toolchange)"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1084
+msgid ""
+"When retraction is triggered before changing tool, filament is pulled back "
+"by the specified amount (the length is measured on raw filament, before it "
+"enters the extruder)."
+msgstr ""
+"When retraction is triggered before changing tool, filament is pulled back "
+"by the specified amount (the length is measured on raw filament, before it "
+"enters the extruder)."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1092
+msgid "Lift Z"
+msgstr "Lift Z"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1093
+msgid ""
+"If you set this to a positive value, Z is quickly raised every time a "
+"retraction is triggered. When using multiple extruders, only the setting for "
+"the first extruder will be considered."
+msgstr ""
+"If you set this to a positive value, Z is quickly raised every time a "
+"retraction is triggered. When using multiple extruders, only the setting for "
+"the first extruder will be considered."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1101
+msgid "Above Z"
+msgstr "Above Z"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1102
+msgid "Only lift Z above"
+msgstr "Only lift Z above"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1103
+msgid ""
+"If you set this to a positive value, Z lift will only take place above the "
+"specified absolute Z. You can tune this setting for skipping lift on the "
+"first layers."
+msgstr ""
+"If you set this to a positive value, Z lift will only take place above the "
+"specified absolute Z. You can tune this setting for skipping lift on the "
+"first layers."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1110
+msgid "Below Z"
+msgstr "Below Z"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1111
+msgid "Only lift Z below"
+msgstr "Only lift Z below"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1112
+msgid ""
+"If you set this to a positive value, Z lift will only take place below the "
+"specified absolute Z. You can tune this setting for limiting lift to the "
+"first layers."
+msgstr ""
+"If you set this to a positive value, Z lift will only take place below the "
+"specified absolute Z. You can tune this setting for limiting lift to the "
+"first layers."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1120
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1128
+msgid "Extra length on restart"
+msgstr "Extra length on restart"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1121
+msgid ""
+"When the retraction is compensated after the travel move, the extruder will "
+"push this additional amount of filament. This setting is rarely needed."
+msgstr ""
+"When the retraction is compensated after the travel move, the extruder will "
+"push this additional amount of filament. This setting is rarely needed."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1129
+msgid ""
+"When the retraction is compensated after changing tool, the extruder will "
+"push this additional amount of filament."
+msgstr ""
+"When the retraction is compensated after changing tool, the extruder will "
+"push this additional amount of filament."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1136
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1137
+msgid "Retraction Speed"
+msgstr "Retraction Speed"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1138
+msgid "The speed for retractions (it only applies to the extruder motor)."
+msgstr "The speed for retractions (it only applies to the extruder motor)."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1144
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1145
+msgid "Deretraction Speed"
+msgstr "Deretraction Speed"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1146
+msgid ""
+"The speed for loading of a filament into extruder after retraction (it only "
+"applies to the extruder motor). If left to zero, the retraction speed is "
+"used."
+msgstr ""
+"The speed for loading of a filament into extruder after retraction (it only "
+"applies to the extruder motor). If left to zero, the retraction speed is "
+"used."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1153
+msgid "Seam position"
+msgstr "Seam position"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1155
+msgid "Position of perimeters starting points."
+msgstr "Position of perimeters starting points."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1171
+msgid "Direction"
+msgstr "Direction"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1173
+msgid "Preferred direction of the seam"
+msgstr "Preferred direction of the seam"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1174
+msgid "Seam preferred direction"
+msgstr "Seam preferred direction"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1182
+msgid "Jitter"
+msgstr "Jitter"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1184
+msgid "Seam preferred direction jitter"
+msgstr "Seam preferred direction jitter"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1185
+msgid "Preferred direction of the seam - jitter"
+msgstr "Preferred direction of the seam - jitter"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1195
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:989
+msgid "Serial port"
+msgstr "Serial port"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1196
+msgid "USB/serial port for printer connection."
+msgstr "USB/serial port for printer connection."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1204
+msgid "Serial port speed"
+msgstr "Serial port speed"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1205
+msgid "Speed (baud) of USB/serial port for printer connection."
+msgstr "Speed (baud) of USB/serial port for printer connection."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1214
+msgid "Distance from object"
+msgstr "Distance from object"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1215
+msgid ""
+"Distance between skirt and object(s). Set this to zero to attach the skirt "
+"to the object(s) and get a brim for better adhesion."
+msgstr ""
+"Distance between skirt and object(s). Set this to zero to attach the skirt "
+"to the object(s) and get a brim for better adhesion."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1223
+msgid "Skirt height"
+msgstr "Skirt height"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1224
+msgid ""
+"Height of skirt expressed in layers. Set this to a tall value to use skirt "
+"as a shield against drafts."
+msgstr ""
+"Height of skirt expressed in layers. Set this to a tall value to use skirt "
+"as a shield against drafts."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1231
+msgid "Loops (minimum)"
+msgstr "Loops (minimum)"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1232
+msgid "Skirt Loops"
+msgstr "Skirt Loops"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1233
+msgid ""
+"Number of loops for the skirt. If the Minimum Extrusion Length option is "
+"set, the number of loops might be greater than the one configured here. Set "
+"this to zero to disable skirt completely."
+msgstr ""
+"Number of loops for the skirt. If the Minimum Extrusion Length option is "
+"set, the number of loops might be greater than the one configured here. Set "
+"this to zero to disable skirt completely."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1241
+msgid "Slow down if layer print time is below"
+msgstr "Slow down if layer print time is below"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1242
+msgid ""
+"If layer print time is estimated below this number of seconds, print moves "
+"speed will be scaled down to extend duration to this value."
+msgstr ""
+"If layer print time is estimated below this number of seconds, print moves "
+"speed will be scaled down to extend duration to this value."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1252
+msgid "Small perimeters"
+msgstr "Small perimeters"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1254
+msgid ""
+"This separate setting will affect the speed of perimeters having radius <= "
+"6.5mm (usually holes). If expressed as percentage (for example: 80%) it will "
+"be calculated on the perimeters speed setting above. Set to zero for auto."
+msgstr ""
+"This separate setting will affect the speed of perimeters having radius <= "
+"6.5mm (usually holes). If expressed as percentage (for example: 80%) it will "
+"be calculated on the perimeters speed setting above. Set to zero for auto."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1264
+msgid "Solid infill threshold area"
+msgstr "Solid infill threshold area"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1266
+msgid ""
+"Force solid infill for regions having a smaller area than the specified "
+"threshold."
+msgstr ""
+"Force solid infill for regions having a smaller area than the specified "
+"threshold."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1267
+msgid "mm\\u00B2"
+msgstr "mm\\u00B2"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1273
+msgid "Solid infill extruder"
+msgstr "Solid infill extruder"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1275
+msgid "The extruder to use when printing solid infill."
+msgstr "The extruder to use when printing solid infill."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1281
+msgid "Solid infill every"
+msgstr "Solid infill every"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1283
+msgid ""
+"This feature allows to force a solid layer every given number of layers. "
+"Zero to disable. You can set this to any value (for example 9999); Slic3r "
+"will automatically choose the maximum possible number of layers to combine "
+"according to nozzle diameter and layer height."
+msgstr ""
+"This feature allows to force a solid layer every given number of layers. "
+"Zero to disable. You can set this to any value (for example 9999); Slic3r "
+"will automatically choose the maximum possible number of layers to combine "
+"according to nozzle diameter and layer height."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1293
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1303
+msgid "Solid infill"
+msgstr "Solid infill"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1295
+msgid ""
+"Set this to a non-zero value to set a manual extrusion width for infill for "
+"solid surfaces. If left zero, default extrusion width will be used if set, "
+"otherwise 1.125 x nozzle diameter will be used. If expressed as percentage "
+"(for example 90%) it will be computed over layer height."
+msgstr ""
+"Set this to a non-zero value to set a manual extrusion width for infill for "
+"solid surfaces. If left zero, default extrusion width will be used if set, "
+"otherwise 1.125 x nozzle diameter will be used. If expressed as percentage "
+"(for example 90%) it will be computed over layer height."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1305
+msgid ""
+"Speed for printing solid regions (top/bottom/internal horizontal shells). "
+"This can be expressed as a percentage (for example: 80%) over the default "
+"infill speed above. Set to zero for auto."
+msgstr ""
+"Speed for printing solid regions (top/bottom/internal horizontal shells). "
+"This can be expressed as a percentage (for example: 80%) over the default "
+"infill speed above. Set to zero for auto."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1316
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:331
+msgid "Solid layers"
+msgstr "Solid layers"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1317
+msgid "Number of solid layers to generate on top and bottom surfaces."
+msgstr "Number of solid layers to generate on top and bottom surfaces."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1324
+msgid "Spiral vase"
+msgstr "Spiral vase"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1325
+msgid ""
+"This feature will raise Z gradually while printing a single-walled object in "
+"order to remove any visible seam. This option requires a single perimeter, "
+"no infill, no top solid layers and no support material. You can still set "
+"any number of bottom solid layers as well as skirt/brim loops. It won't work "
+"when printing more than an object."
+msgstr ""
+"This feature will raise Z gradually while printing a single-walled object in "
+"order to remove any visible seam. This option requires a single perimeter, "
+"no infill, no top solid layers and no support material. You can still set "
+"any number of bottom solid layers as well as skirt/brim loops. It won't work "
+"when printing more than an object."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1334
+msgid "Temperature variation"
+msgstr "Temperature variation"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1335
+msgid ""
+"Temperature difference to be applied when an extruder is not active. Enables "
+"a full-height \"sacrificial\" skirt on which the nozzles are periodically "
+"wiped."
+msgstr ""
+"Temperature difference to be applied when an extruder is not active. Enables "
+"a full-height \"sacrificial\" skirt on which the nozzles are periodically "
+"wiped."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1344
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1359
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:846
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1119
+msgid "Start G-code"
+msgstr "Start G-code"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1345
+msgid ""
+"This start procedure is inserted at the beginning, after bed has reached the "
+"target temperature and extruder just started heating, and before extruder "
+"has finished heating. If Slic3r detects M104 or M190 in your custom codes, "
+"such commands will not be prepended automatically so you're free to "
+"customize the order of heating commands and other custom actions. Note that "
+"you can use placeholder variables for all Slic3r settings, so you can put a "
+"\"M109 S[first_layer_temperature]\" command wherever you want."
+msgstr ""
+"This start procedure is inserted at the beginning, after bed has reached the "
+"target temperature and extruder just started heating, and before extruder "
+"has finished heating. If Slic3r detects M104 or M190 in your custom codes, "
+"such commands will not be prepended automatically so you're free to "
+"customize the order of heating commands and other custom actions. Note that "
+"you can use placeholder variables for all Slic3r settings, so you can put a "
+"\"M109 S[first_layer_temperature]\" command wherever you want."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1360
+msgid ""
+"This start procedure is inserted at the beginning, after any printer start "
+"gcode. This is used to override settings for a specific filament. If Slic3r "
+"detects M104, M109, M140 or M190 in your custom codes, such commands will "
+"not be prepended automatically so you're free to customize the order of "
+"heating commands and other custom actions. Note that you can use placeholder "
+"variables for all Slic3r settings, so you can put a \"M109 "
+"S[first_layer_temperature]\" command wherever you want. If you have multiple "
+"extruders, the gcode is processed in extruder order."
+msgstr ""
+"This start procedure is inserted at the beginning, after any printer start "
+"gcode. This is used to override settings for a specific filament. If Slic3r "
+"detects M104, M109, M140 or M190 in your custom codes, such commands will "
+"not be prepended automatically so you're free to customize the order of "
+"heating commands and other custom actions. Note that you can use placeholder "
+"variables for all Slic3r settings, so you can put a \"M109 "
+"S[first_layer_temperature]\" command wherever you want. If you have multiple "
+"extruders, the gcode is processed in extruder order."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1375
+msgid "Single Extruder Multi Material"
+msgstr "Single Extruder Multi Material"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1376
+msgid "The printer multiplexes filaments into a single hot end."
+msgstr "The printer multiplexes filaments into a single hot end."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1381
+msgid "Generate support material"
+msgstr "Generate support material"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1383
+msgid "Enable support material generation."
+msgstr "Enable support material generation."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1388
+msgid "XY separation between an object and its support"
+msgstr "XY separation between an object and its support"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1390
+msgid ""
+"XY separation between an object and its support. If expressed as percentage "
+"(for example 50%), it will be calculated over external perimeter width."
+msgstr ""
+"XY separation between an object and its support. If expressed as percentage "
+"(for example 50%), it will be calculated over external perimeter width."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1400
+msgid "Pattern angle"
+msgstr "Pattern angle"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1402
+msgid ""
+"Use this setting to rotate the support material pattern on the horizontal "
+"plane."
+msgstr ""
+"Use this setting to rotate the support material pattern on the horizontal "
+"plane."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1410
+msgid "Support on build plate only"
+msgstr "Support on build plate only"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1412
+msgid ""
+"Only create support if it lies on a build plate. Don't create support on a "
+"print."
+msgstr ""
+"Only create support if it lies on a build plate. Don't create support on a "
+"print."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1418
+msgid "Contact Z distance"
+msgstr "Contact Z distance"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1420
+msgid ""
+"The vertical distance between object and support material interface. Setting "
+"this to 0 will also prevent Slic3r from using bridge flow and speed for the "
+"first object layer."
+msgstr ""
+"The vertical distance between object and support material interface. Setting "
+"this to 0 will also prevent Slic3r from using bridge flow and speed for the "
+"first object layer."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1433
+msgid "Enforce support for the first"
+msgstr "Enforce support for the first"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1435
+msgid ""
+"Generate support material for the specified number of layers counting from "
+"bottom, regardless of whether normal support material is enabled or not and "
+"regardless of any angle threshold. This is useful for getting more adhesion "
+"of objects having a very thin or poor footprint on the build plate."
+msgstr ""
+"Generate support material for the specified number of layers counting from "
+"bottom, regardless of whether normal support material is enabled or not and "
+"regardless of any angle threshold. This is useful for getting more adhesion "
+"of objects having a very thin or poor footprint on the build plate."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1441
+msgid "Enforce support for the first n layers"
+msgstr "Enforce support for the first n layers"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1446
+msgid "Support material/raft/skirt extruder"
+msgstr "Support material/raft/skirt extruder"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1448
+msgid ""
+"The extruder to use when printing support material, raft and skirt (1+, 0 to "
+"use the current extruder to minimize tool changes)."
+msgstr ""
+"The extruder to use when printing support material, raft and skirt (1+, 0 to "
+"use the current extruder to minimize tool changes)."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1457
+msgid ""
+"Set this to a non-zero value to set a manual extrusion width for support "
+"material. If left zero, default extrusion width will be used if set, "
+"otherwise nozzle diameter will be used. If expressed as percentage (for "
+"example 90%) it will be computed over layer height."
+msgstr ""
+"Set this to a non-zero value to set a manual extrusion width for support "
+"material. If left zero, default extrusion width will be used if set, "
+"otherwise nozzle diameter will be used. If expressed as percentage (for "
+"example 90%) it will be computed over layer height."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1465
+msgid "Interface loops"
+msgstr "Interface loops"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1467
+msgid ""
+"Cover the top contact layer of the supports with loops. Disabled by default."
+msgstr ""
+"Cover the top contact layer of the supports with loops. Disabled by default."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1472
+msgid "Support material/raft interface extruder"
+msgstr "Support material/raft interface extruder"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1474
+msgid ""
+"The extruder to use when printing support material interface (1+, 0 to use "
+"the current extruder to minimize tool changes). This affects raft too."
+msgstr ""
+"The extruder to use when printing support material interface (1+, 0 to use "
+"the current extruder to minimize tool changes). This affects raft too."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1481
+msgid "Interface layers"
+msgstr "Interface layers"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1483
+msgid ""
+"Number of interface layers to insert between the object(s) and support "
+"material."
+msgstr ""
+"Number of interface layers to insert between the object(s) and support "
+"material."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1490
+msgid "Interface pattern spacing"
+msgstr "Interface pattern spacing"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1492
+msgid "Spacing between interface lines. Set zero to get a solid interface."
+msgstr "Spacing between interface lines. Set zero to get a solid interface."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1499
+msgid "Support material interface"
+msgstr "Support material interface"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1501
+msgid ""
+"Speed for printing support material interface layers. If expressed as "
+"percentage (for example 50%) it will be calculated over support material "
+"speed."
+msgstr ""
+"Speed for printing support material interface layers. If expressed as "
+"percentage (for example 50%) it will be calculated over support material "
+"speed."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1510
+msgid "Pattern"
+msgstr "Pattern"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1512
+msgid "Pattern used to generate support material."
+msgstr "Pattern used to generate support material."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1526
+msgid "Pattern spacing"
+msgstr "Pattern spacing"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1528
+msgid "Spacing between support material lines."
+msgstr "Spacing between support material lines."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1537
+msgid "Speed for printing support material."
+msgstr "Speed for printing support material."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1544
+msgid "Synchronize with object layers"
+msgstr "Synchronize with object layers"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1546
+msgid ""
+"Synchronize support layers with the object print layers. This is useful with "
+"multi-material printers, where the extruder switch is expensive."
+msgstr ""
+"Synchronize support layers with the object print layers. This is useful with "
+"multi-material printers, where the extruder switch is expensive."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1552
+msgid "Overhang threshold"
+msgstr "Overhang threshold"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1554
+msgid ""
+"Support material will not be generated for overhangs whose slope angle "
+"(90\\u00B0 = vertical) is above the given threshold. In other words, this "
+"value represent the most horizontal slope (measured from the horizontal "
+"plane) that you can print without support material. Set to zero for "
+"automatic detection (recommended)."
+msgstr ""
+"Support material will not be generated for overhangs whose slope angle "
+"(90\\u00B0 = vertical) is above the given threshold. In other words, this "
+"value represent the most horizontal slope (measured from the horizontal "
+"plane) that you can print without support material. Set to zero for "
+"automatic detection (recommended)."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1566
+msgid "With sheath around the support"
+msgstr "With sheath around the support"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1568
+msgid ""
+"Add a sheath (a single perimeter line) around the base support. This makes "
+"the support more reliable, but also more difficult to remove."
+msgstr ""
+"Add a sheath (a single perimeter line) around the base support. This makes "
+"the support more reliable, but also more difficult to remove."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1575
+msgid ""
+"Extruder temperature for layers after the first one. Set this to zero to "
+"disable temperature control commands in the output."
+msgstr ""
+"Extruder temperature for layers after the first one. Set this to zero to "
+"disable temperature control commands in the output."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1578
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:793
+msgid "Temperature"
+msgstr "Temperature"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1584
+msgid "Detect thin walls"
+msgstr "Detect thin walls"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1586
+msgid ""
+"Detect single-width walls (parts where two extrusions don't fit and we need "
+"to collapse them into a single trace)."
+msgstr ""
+"Detect single-width walls (parts where two extrusions don't fit and we need "
+"to collapse them into a single trace)."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1592
+msgid "Threads"
+msgstr "Threads"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1593
+msgid ""
+"Threads are used to parallelize long-running tasks. Optimal threads number "
+"is slightly above the number of available cores/processors."
+msgstr ""
+"Threads are used to parallelize long-running tasks. Optimal threads number "
+"is slightly above the number of available cores/processors."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1604
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1143
+msgid "Tool change G-code"
+msgstr "Tool change G-code"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1605
+msgid ""
+"This custom code is inserted right before every extruder change. Note that "
+"you can use placeholder variables for all Slic3r settings as well as "
+"[previous_extruder] and [next_extruder]."
+msgstr ""
+"This custom code is inserted right before every extruder change. Note that "
+"you can use placeholder variables for all Slic3r settings as well as "
+"[previous_extruder] and [next_extruder]."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1615
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1626
+msgid "Top solid infill"
+msgstr "Top solid infill"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1617
+msgid ""
+"Set this to a non-zero value to set a manual extrusion width for infill for "
+"top surfaces. You may want to use thinner extrudates to fill all narrow "
+"regions and get a smoother finish. If left zero, default extrusion width "
+"will be used if set, otherwise nozzle diameter will be used. If expressed as "
+"percentage (for example 90%) it will be computed over layer height."
+msgstr ""
+"Set this to a non-zero value to set a manual extrusion width for infill for "
+"top surfaces. You may want to use thinner extrudates to fill all narrow "
+"regions and get a smoother finish. If left zero, default extrusion width "
+"will be used if set, otherwise nozzle diameter will be used. If expressed as "
+"percentage (for example 90%) it will be computed over layer height."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1628
+msgid ""
+"Speed for printing top solid layers (it only applies to the uppermost "
+"external layers and not to their internal solid layers). You may want to "
+"slow down this to get a nicer surface finish. This can be expressed as a "
+"percentage (for example: 80%) over the solid infill speed above. Set to zero "
+"for auto."
+msgstr ""
+"Speed for printing top solid layers (it only applies to the uppermost "
+"external layers and not to their internal solid layers). You may want to "
+"slow down this to get a nicer surface finish. This can be expressed as a "
+"percentage (for example: 80%) over the solid infill speed above. Set to zero "
+"for auto."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1640
+msgid "Top"
+msgstr "Top"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1642
+msgid "Number of solid layers to generate on top surfaces."
+msgstr "Number of solid layers to generate on top surfaces."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1644
+msgid "Top solid layers"
+msgstr "Top solid layers"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1649
+msgid "Travel"
+msgstr "Travel"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1650
+msgid "Speed for travel moves (jumps between distant extrusion points)."
+msgstr "Speed for travel moves (jumps between distant extrusion points)."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1658
+msgid "Use firmware retraction"
+msgstr "Use firmware retraction"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1659
+msgid ""
+"This experimental setting uses G10 and G11 commands to have the firmware "
+"handle the retraction. This is only supported in recent Marlin."
+msgstr ""
+"This experimental setting uses G10 and G11 commands to have the firmware "
+"handle the retraction. This is only supported in recent Marlin."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1665
+msgid "Use relative E distances"
+msgstr "Use relative E distances"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1666
+msgid ""
+"If your firmware requires relative E values, check this, otherwise leave it "
+"unchecked. Most firmwares use absolute values."
+msgstr ""
+"If your firmware requires relative E values, check this, otherwise leave it "
+"unchecked. Most firmwares use absolute values."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1672
+msgid "Use volumetric E"
+msgstr "Use volumetric E"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1673
+msgid ""
+"This experimental setting uses outputs the E values in cubic millimeters "
+"instead of linear millimeters. If your firmware doesn't already know "
+"filament diameter(s), you can put commands like 'M200 D[filament_diameter_0] "
+"T0' in your start G-code in order to turn volumetric mode on and use the "
+"filament diameter associated to the filament selected in Slic3r. This is "
+"only supported in recent Marlin."
+msgstr ""
+"This experimental setting uses outputs the E values in cubic millimeters "
+"instead of linear millimeters. If your firmware doesn't already know "
+"filament diameter(s), you can put commands like 'M200 D[filament_diameter_0] "
+"T0' in your start G-code in order to turn volumetric mode on and use the "
+"filament diameter associated to the filament selected in Slic3r. This is "
+"only supported in recent Marlin."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1683
+msgid "Enable variable layer height feature"
+msgstr "Enable variable layer height feature"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1684
+msgid ""
+"Some printers or printer setups may have difficulties printing with a "
+"variable layer height. Enabled by default."
+msgstr ""
+"Some printers or printer setups may have difficulties printing with a "
+"variable layer height. Enabled by default."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1690
+msgid "Wipe while retracting"
+msgstr "Wipe while retracting"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1691
+msgid ""
+"This flag will move the nozzle while retracting to minimize the possible "
+"blob on leaky extruders."
+msgstr ""
+"This flag will move the nozzle while retracting to minimize the possible "
+"blob on leaky extruders."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1698
+msgid ""
+"Multi material printers may need to prime or purge extruders on tool "
+"changes. Extrude the excess material into the wipe tower."
+msgstr ""
+"Multi material printers may need to prime or purge extruders on tool "
+"changes. Extrude the excess material into the wipe tower."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1704
+msgid "Position X"
+msgstr "Position X"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1705
+msgid "X coordinate of the left front corner of a wipe tower"
+msgstr "X coordinate of the left front corner of a wipe tower"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1711
+msgid "Position Y"
+msgstr "Position Y"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1712
+msgid "Y coordinate of the left front corner of a wipe tower"
+msgstr "Y coordinate of the left front corner of a wipe tower"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1718
+msgid "Width"
+msgstr "Width"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1719
+msgid "Width of a wipe tower"
+msgstr "Width of a wipe tower"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1725
+msgid "Per color change depth"
+msgstr "Per color change depth"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1726
+msgid ""
+"Depth of a wipe color per color change. For N colors, there will be maximum "
+"(N-1) tool switches performed, therefore the total depth of the wipe tower "
+"will be (N-1) times this value."
+msgstr ""
+"Depth of a wipe color per color change. For N colors, there will be maximum "
+"(N-1) tool switches performed, therefore the total depth of the wipe tower "
+"will be (N-1) times this value."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1734
+msgid "XY Size Compensation"
+msgstr "XY Size Compensation"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1736
+msgid ""
+"The object will be grown/shrunk in the XY plane by the configured value "
+"(negative = inwards, positive = outwards). This might be useful for fine-"
+"tuning hole sizes."
+msgstr ""
+"The object will be grown/shrunk in the XY plane by the configured value "
+"(negative = inwards, positive = outwards). This might be useful for fine-"
+"tuning hole sizes."
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1744
+msgid "Z offset"
+msgstr "Z offset"
+
+#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1745
+msgid ""
+"This value will be added (or subtracted) from all the Z coordinates in the "
+"output G-code. It is used to compensate for bad Z endstop position: for "
+"example, if your endstop zero actually leaves the nozzle 0.3mm far from the "
+"print bed, set this to -0.3 (or fix your endstop)."
+msgstr ""
+"This value will be added (or subtracted) from all the Z coordinates in the "
+"output G-code. It is used to compensate for bad Z endstop position: for "
+"example, if your endstop zero actually leaves the nozzle 0.3mm far from the "
+"print bed, set this to -0.3 (or fix your endstop)."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:39
+msgid "Shape"
+msgstr "Shape"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:46
+msgid "Rectangular"
+msgstr "Rectangular"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:62
+msgid "Circular"
+msgstr "Circular"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:75
+msgid "Load shape from STL..."
+msgstr "Load shape from STL..."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:120
+msgid "Settings"
+msgstr "Settings"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:298
+msgid "Choose a file to import bed shape from (STL/OBJ/AMF/PRUSA):"
+msgstr "Choose a file to import bed shape from (STL/OBJ/AMF/PRUSA):"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:315
+msgid "Error! "
+msgstr "Error! "
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:324
+msgid "The selected file contains no geometry."
+msgstr "The selected file contains no geometry."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:328
+msgid ""
+"The selected file contains several disjoint areas. This is not supported."
+msgstr ""
+"The selected file contains several disjoint areas. This is not supported."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.hpp:42
+msgid "Bed Shape"
+msgstr "Bed Shape"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:468
+msgid "Error"
+msgstr "Error"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:473
+msgid "Notice"
+msgstr "Notice"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:50
+msgid "Save current "
+msgstr "Save current "
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:51
+msgid "Delete this preset"
+msgstr "Delete this preset"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:330
+msgid "Horizontal shells"
+msgstr "Horizontal shells"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:336
+msgid "Quality (slower slicing)"
+msgstr "Quality (slower slicing)"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:353
+msgid "Reducing printing time"
+msgstr "Reducing printing time"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:365
+msgid "Skirt and brim"
+msgstr "Skirt and brim"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:381
+msgid "Raft"
+msgstr "Raft"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:412
+msgid "Speed for non-print moves"
+msgstr "Speed for non-print moves"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:415
+msgid "Modifiers"
+msgstr "Modifiers"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:418
+msgid "Acceleration control (advanced)"
+msgstr "Acceleration control (advanced)"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:425
+msgid "Autospeed (advanced)"
+msgstr "Autospeed (advanced)"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:431
+msgid "Multiple Extruders"
+msgstr "Multiple Extruders"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:439
+msgid "Ooze prevention"
+msgstr "Ooze prevention"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:464
+msgid "Overlap"
+msgstr "Overlap"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:467
+msgid "Flow"
+msgstr "Flow"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:470
+msgid "Other"
+msgstr "Other"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:477
+msgid "Output options"
+msgstr "Output options"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:478
+msgid "Sequential printing"
+msgstr "Sequential printing"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:501
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:502
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:858
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:859
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1155
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1156
+msgid "Notes"
+msgstr "Notes"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:508
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:866
+msgid "Dependencies"
+msgstr "Dependencies"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:509
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:867
+msgid "Profile dependencies"
+msgstr "Profile dependencies"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:799
+msgid "Bed"
+msgstr "Bed"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:804
+msgid "Cooling"
+msgstr "Cooling"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:816
+msgid "Fan settings"
+msgstr "Fan settings"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:835
+msgid "Print speed override"
+msgstr "Print speed override"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:845
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1118
+msgid "Custom G-code"
+msgstr "Custom G-code"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:936
+msgid "General"
+msgstr "General"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:937
+msgid "Size and coordinates"
+msgstr "Size and coordinates"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:941
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1642
+msgid "Set"
+msgstr "Set"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:961
+msgid "Capabilities"
+msgstr "Capabilities"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1003
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1071
+msgid "Test"
+msgstr "Test"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1016
+msgid "Connection to printer works correctly."
+msgstr "Connection to printer works correctly."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1016
+msgid "Success!"
+msgstr "Success!"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1019
+msgid "Connection failed."
+msgstr "Connection failed."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1031
+msgid "OctoPrint upload"
+msgstr "OctoPrint upload"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1034
+msgid "Browse"
+msgstr "Browse"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1046
+msgid "Button BROWSE was clicked!"
+msgstr "Button BROWSE was clicked!"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1081
+msgid "Button TEST was clicked!"
+msgstr "Button TEST was clicked!"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1109
+msgid "Firmware"
+msgstr "Firmware"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1191
+msgid "Layer height limits"
+msgstr "Layer height limits"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1196
+msgid "Position (for multi-extruder printers)"
+msgstr "Position (for multi-extruder printers)"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1215
+msgid ""
+"Retraction when tool is disabled (advanced settings for multi-extruder "
+"setups)"
+msgstr ""
+"Retraction when tool is disabled (advanced settings for multi-extruder "
+"setups)"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1219
+msgid "Preview"
+msgstr "Preview"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1310
+msgid ""
+"The Wipe option is not available when using the Firmware Retraction mode.\n"
+"\n"
+"Shall I disable it in order to enable Firmware Retraction?"
+msgstr ""
+"The Wipe option is not available when using the Firmware Retraction mode.\n"
+"\n"
+"Shall I disable it in order to enable Firmware Retraction?"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1558
+msgid "The supplied name is empty. It can't be saved."
+msgstr "The supplied name is empty. It can't be saved."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1569
+msgid "Something is wrong. It can't be saved."
+msgstr "Something is wrong. It can't be saved."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1586
+msgid "remove"
+msgstr "remove"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1586
+msgid "delete"
+msgstr "delete"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1587
+msgid "Are you sure you want to "
+msgstr "Are you sure you want to "
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1587
+msgid " the selected preset?"
+msgstr " the selected preset?"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1588
+msgid "Remove"
+msgstr "Remove"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1588
+msgid "Delete"
+msgstr "Delete"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1589
+msgid " Preset"
+msgstr " Preset"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1641
+msgid "All"
+msgstr "All"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1672
+msgid "Select the printers this profile is compatible with."
+msgstr "Select the printers this profile is compatible with."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1756
+msgid "Save "
+msgstr "Save "
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1756
+msgid " as:"
+msgstr " as:"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1790
+msgid ""
+"The supplied name is not valid; the following characters are not allowed:"
+msgstr ""
+"The supplied name is not valid; the following characters are not allowed:"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1793
+msgid "The supplied name is not available."
+msgstr "The supplied name is not available."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:182
+msgid "Print Settings"
+msgstr "Print Settings"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:202
+msgid "Filament Settings"
+msgstr "Filament Settings"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:248
+msgid "Save preset"
+msgstr "Save preset"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Field.cpp:35
+msgid "default"
+msgstr "default"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:71
+msgid "Custom"
+msgstr "Custom"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:212
+msgid "Array of language names and identifiers should have the same size."
+msgstr "Array of language names and identifiers should have the same size."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:223
+msgid "Select the language"
+msgstr "Select the language"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:223
+msgid "Language"
+msgstr "Language"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:321
+msgid "Change Application Language"
+msgstr "Change Application Language"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:314
+msgid "Layers and perimeters"
+msgstr "Layers and perimeters"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:319
+msgid "Vertical shells"
+msgstr "Vertical shells"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:366
+msgid "Skirt"
+msgstr "Skirt"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:372
+msgid "Brim"
+msgstr "Brim"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:385
+msgid "Options for support material and raft"
+msgstr "Options for support material and raft"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:400
+msgid "Speed for print moves"
+msgstr "Speed for print moves"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:443
+msgid "Wipe tower"
+msgstr "Wipe tower"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:454
+msgid "Extrusion width"
+msgstr "Extrusion width"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:480
+msgid "Extruder clearance (mm)"
+msgstr "Extruder clearance (mm)"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:489
+msgid "Output file"
+msgstr "Output file"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:534
+#, c-format
+msgid ""
+"The Spiral Vase mode requires:\n"
+"- one perimeter\n"
+"- no top solid layers\n"
+"- 0% fill density\n"
+"- no support material\n"
+"- no ensure_vertical_shell_thickness\n"
+"\n"
+"Shall I adjust those settings in order to enable Spiral Vase?"
+msgstr ""
+"The Spiral Vase mode requires:\n"
+"- one perimeter\n"
+"- no top solid layers\n"
+"- 0% fill density\n"
+"- no support material\n"
+"- no ensure_vertical_shell_thickness\n"
+"\n"
+"Shall I adjust those settings in order to enable Spiral Vase?"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:541
+msgid "Spiral Vase"
+msgstr "Spiral Vase"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:560
+msgid ""
+"The Wipe Tower currently supports only:\n"
+"- first layer height 0.2mm\n"
+"- layer height from 0.15mm to 0.35mm\n"
+"\n"
+"Shall I adjust those settings in order to enable the Wipe Tower?"
+msgstr ""
+"The Wipe Tower currently supports only:\n"
+"- first layer height 0.2mm\n"
+"- layer height from 0.15mm to 0.35mm\n"
+"\n"
+"Shall I adjust those settings in order to enable the Wipe Tower?"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:564
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:585
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:602
+msgid "Wipe Tower"
+msgstr "Wipe tower"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:581
+msgid ""
+"The Wipe Tower currently supports the non-soluble supports only\n"
+"if they are printed with the current extruder without triggering a tool "
+"change.\n"
+"(both support_material_extruder and support_material_interface_extruder need "
+"to be set to 0).\n"
+"\n"
+"Shall I adjust those settings in order to enable the Wipe Tower?"
+msgstr ""
+"The Wipe Tower currently supports the non-soluble supports only\n"
+"if they are printed with the current extruder without triggering a tool "
+"change.\n"
+"(both support_material_extruder and support_material_interface_extruder need "
+"to be set to 0).\n"
+"\n"
+"Shall I adjust those settings in order to enable the Wipe Tower?"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:599
+msgid ""
+"For the Wipe Tower to work with the soluble supports, the support layers\n"
+"need to be synchronized with the object layers.\n"
+"\n"
+"Shall I synchronize support layers in order to enable the Wipe Tower?"
+msgstr ""
+"For the Wipe Tower to work with the soluble supports, the support layers\n"
+"need to be synchronized with the object layers.\n"
+"\n"
+"Shall I synchronize support layers in order to enable the Wipe Tower?"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:617
+msgid ""
+"Supports work better, if the following feature is enabled:\n"
+"- Detect bridging perimeters\n"
+"\n"
+"Shall I adjust those settings for supports?"
+msgstr ""
+"Supports work better, if the following feature is enabled:\n"
+"- Detect bridging perimeters\n"
+"\n"
+"Shall I adjust those settings for supports?"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:620
+msgid "Support Generator"
+msgstr "Support Generator"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:662
+msgid "The "
+msgstr "The "
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:662
+#, c-format
+msgid ""
+" infill pattern is not supposed to work at 100% density.\n"
+"\n"
+"Shall I switch to rectilinear fill pattern?"
+msgstr ""
+" infill pattern is not supposed to work at 100% density.\n"
+"\n"
+"Shall I switch to rectilinear fill pattern?"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:785
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:786
+msgid "Filament"
+msgstr "Filament"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:817
+msgid "Fan speed"
+msgstr "Fan speed"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:825
+msgid "Cooling thresholds"
+msgstr "Cooling thresholds"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:831
+msgid "Filament properties"
+msgstr "Filament properties"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:988
+msgid "USB/Serial connection"
+msgstr "USB/Serial connection"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:994
+msgid "Rescan serial ports"
+msgstr "Rescan serial ports"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1149
+msgid "Between objects G-code (for sequential printing)"
+msgstr "Between objects G-code (for sequential printing)"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1185
+msgid "Extruder "
+msgstr "Extruder "
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1199
+msgid "Retraction"
+msgstr "Retraction"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1202
+msgid "Only lift Z"
+msgstr "Only lift Z"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1312
+msgid "Firmware Retraction"
+msgstr "Firmware Retraction"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1467
+msgid "Default "
+msgstr "Default "
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1467
+msgid " preset"
+msgstr " preset"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1468
+msgid " preset\n"
+msgstr " preset\n"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1486
+msgid ""
+"\n"
+"\n"
+"is not compatible with printer\n"
+msgstr ""
+"\n"
+"\n"
+"is not compatible with printer\n"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1486
+msgid ""
+"\n"
+"\n"
+"and it has the following unsaved changes:"
+msgstr ""
+"\n"
+"\n"
+"and it has the following unsaved changes:"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1487
+msgid ""
+"\n"
+"\n"
+"has the following unsaved changes:"
+msgstr ""
+"\n"
+"\n"
+"has the following unsaved changes:"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1489
+msgid ""
+"\n"
+"\n"
+"Discard changes and continue anyway?"
+msgstr ""
+"\n"
+"\n"
+"Discard changes and continue anyway?"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1490
+msgid "Unsaved Changes"
+msgstr "Unsaved Changes"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:228
+msgid "Printer Settings"
+msgstr "Printer Settings"
diff --git a/resources/localization/uk/Slic3rPE.mo b/resources/localization/uk/Slic3rPE.mo
new file mode 100644
index 000000000..40e32c81e
Binary files /dev/null and b/resources/localization/uk/Slic3rPE.mo differ
diff --git a/resources/localization/uk/Slic3rPE_uk.po b/resources/localization/uk/Slic3rPE_uk.po
new file mode 100644
index 000000000..6166632e2
--- /dev/null
+++ b/resources/localization/uk/Slic3rPE_uk.po
@@ -0,0 +1,538 @@
+# This file is distributed under the same license as the Slic3rPE package.
+# Oleksandra Iushchenko <yusanka@gmail.com>, 2018.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: \n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2018-02-07 20:20+0100\n"
+"PO-Revision-Date: 2018-02-08 01:41+0100\n"
+"Last-Translator: Oleksandra Iushchenko <yusanka@gmail.com>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 2.0.6\n"
+"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
+"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
+"Language: uk\n"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:81
+msgid "Default"
+msgstr "За замовчуванням"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:109
+msgid "Shape"
+msgstr "Вигляд (Форма)"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:116
+msgid "Rectangular"
+msgstr "Прямокутний"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:132
+msgid "Circular"
+msgstr "Круговий"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:141
+msgid "Custom"
+msgstr "Користувацький"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:145
+msgid "Load shape from STL..."
+msgstr "Завантажте форму з STL ..."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:190
+msgid "Settings"
+msgstr "Налаштування"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:368
+msgid "Choose a file to import bed shape from (STL/OBJ/AMF/PRUSA):"
+msgstr "Виберіть файл, щоб імпортувати форму подложки з (STL/OBJ/AMF/PRUSA):"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:385
+msgid "Error! "
+msgstr "Помилка! "
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:394
+msgid "The selected file contains no geometry."
+msgstr "Обратний файл не містить геометрії."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:398
+msgid ""
+"The selected file contains several disjoint areas. This is not supported."
+msgstr "Обраний файл містить декілька непересічних областей. Не підтримується."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.hpp:45
+msgid "Bed Shape"
+msgstr "Форма полотна"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:318
+msgid "Error"
+msgstr "Помилка"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp:323
+msgid "Notice"
+msgstr "Зауваження"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:51
+msgid "Save current "
+msgstr "Зберегти поточний "
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:52
+msgid "Delete this preset"
+msgstr "Видалити це налаштування"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:324
+msgid "Layers and perimeters"
+msgstr "Шари та периметри"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:325
+msgid "Layer height"
+msgstr "Висота шару"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:329
+msgid "Vertical shells"
+msgstr "Вертикальні оболонки"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:340
+msgid "Horizontal shells"
+msgstr "Горизонтальні оболонки"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:341
+msgid "Solid layers"
+msgstr "Тверді шари"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:346
+msgid "Quality (slower slicing)"
+msgstr "Якість (повільне нарізання)"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:353
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:367
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:460
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:463
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:839
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1122
+msgid "Advanced"
+msgstr "Розширений"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:357
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:358
+msgid "Infill"
+msgstr "Заповнення"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:363
+msgid "Reducing printing time"
+msgstr "Зниження часу друку"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:375
+msgid "Skirt and brim"
+msgstr "Плінтус та край"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:376
+msgid "Skirt"
+msgstr "Плінтус"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:382
+msgid "Brim"
+msgstr "Край"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:385
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:386
+msgid "Support material"
+msgstr "Опорний матеріал"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:391
+msgid "Raft"
+msgstr "Пліт"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:395
+msgid "Options for support material and raft"
+msgstr "Варіанти для опорного матеріалу та плоту"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:409
+msgid "Speed"
+msgstr "Швидкість"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:410
+msgid "Speed for print moves"
+msgstr "Швидкість друкарських рухів"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:422
+msgid "Speed for non-print moves"
+msgstr "Швидкість недрукарських рухів"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:425
+msgid "Modifiers"
+msgstr "Модифікатори"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:428
+msgid "Acceleration control (advanced)"
+msgstr "Контроль прискорення (розширений)"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:435
+msgid "Autospeed (advanced)"
+msgstr "Автоматична швидкість (розширена)"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:441
+msgid "Multiple Extruders"
+msgstr "Кілька екструдерів"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:442
+msgid "Extruders"
+msgstr "Екструдери"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:449
+msgid "Ooze prevention"
+msgstr "Профілактика ?Ooze?"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:453
+msgid "Wipe tower"
+msgstr "Вежа очищення"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:464
+msgid "Extrusion width"
+msgstr "Ширина екструзії"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:474
+msgid "Overlap"
+msgstr "Перекриття"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:477
+msgid "Flow"
+msgstr "Потік"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:480
+msgid "Other"
+msgstr "Інше"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:487
+msgid "Output options"
+msgstr "Параметри виводу"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:488
+msgid "Sequential printing"
+msgstr "Послідовне друкування"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:499
+msgid "Output file"
+msgstr "Вихідний файл"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:505
+msgid "Post-processing scripts"
+msgstr "Скрипти пост-обробки"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:511
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:512
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:867
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:868
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1165
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1166
+msgid "Notes"
+msgstr "Примітки"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:518
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:875
+msgid "Dependencies"
+msgstr "Залежності"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:519
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:876
+msgid "Profile dependencies"
+msgstr "Залежності профілю"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:794
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:795
+msgid "Filament"
+msgstr "Філаметн"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:802
+msgid "Temperature"
+msgstr "Температура"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:803
+msgid "Extruder"
+msgstr "Екструдер"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:808
+msgid "Bed"
+msgstr "Полотно"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:813
+msgid "Cooling"
+msgstr "Охолодження"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:814
+msgid "Enable"
+msgstr "Увімкнути"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:825
+msgid "Fan settings"
+msgstr "Налаштування вентилятора"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:834
+msgid "Cooling thresholds"
+msgstr "Пороги охолодження"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:840
+msgid "Filament properties"
+msgstr "Властивості філаменту"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:844
+msgid "Print speed override"
+msgstr "Перевизначення швидкості друку"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:854
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1128
+msgid "Custom G-code"
+msgstr "Користувацький G-код"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:855
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1129
+msgid "Start G-code"
+msgstr "Початок G-коду"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:861
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1135
+msgid "End G-code"
+msgstr "Закінчення G-коду"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:945
+msgid "General"
+msgstr "Загальне"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:946
+msgid "Size and coordinates"
+msgstr "Розмір і координати"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:948
+msgid "Bed shape"
+msgstr "Форма полотна"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:950
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1649
+msgid "Set"
+msgstr "Встановити"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:971
+msgid "Capabilities"
+msgstr "Можливості"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:998
+msgid "USB/Serial connection"
+msgstr "USB/послідовне з'єднання"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1004
+msgid "Rescan serial ports"
+msgstr "Сканувати ще раз послідовні порти"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1013
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1081
+msgid "Test"
+msgstr "Перевірити"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1026
+msgid "Connection to printer works correctly."
+msgstr "Підключення до принтера працює коректно."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1026
+msgid "Success!"
+msgstr "Успіх!"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1029
+msgid "Connection failed."
+msgstr "Підключення не вдалося."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1041
+msgid "OctoPrint upload"
+msgstr "Завантаження OctoPrint"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1044
+msgid "Browse"
+msgstr "Переглянути"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1119
+msgid "Firmware"
+msgstr "Прошивка"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1141
+msgid "Before layer change G-code"
+msgstr "G-код перед зміною шару "
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1147
+msgid "After layer change G-code"
+msgstr "G-код після зміни шару"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1153
+msgid "Tool change G-code"
+msgstr "G-код зміни інструменту "
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1159
+msgid "Between objects G-code (for sequential printing)"
+msgstr "G-код між об'єктами (для послідовного друку)"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1195
+msgid "Extruder "
+msgstr "Екструдер "
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1198
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:120
+msgid "Size"
+msgstr "Розмір"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1201
+msgid "Layer height limits"
+msgstr "Межі висоти шару"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1206
+msgid "Position (for multi-extruder printers)"
+msgstr "Позиція (для мульти-екструдерних принтерів)"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1209
+msgid "Retraction"
+msgstr "Утягування/відкликання"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1212
+msgid "Only lift Z"
+msgstr "Межі підняття Z"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1225
+msgid ""
+"Retraction when tool is disabled (advanced settings for multi-extruder "
+"setups)"
+msgstr ""
+"Утягування/відкликання при відключенні інструмента (додаткові налаштування "
+"для налагодження мульти-екструдерів)"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1229
+msgid "Preview"
+msgstr "Попередній перегляд"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1320
+msgid ""
+"The Wipe option is not available when using the Firmware Retraction mode.\n"
+"\n"
+"Shall I disable it in order to enable Firmware Retraction?"
+msgstr ""
+"Параметр «Очистити» недоступний при використанні режиму програмного "
+"утягування/відкликання.\n"
+"\n"
+"Відключити його для увімкнення програмного утягування/відкликання?"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1322
+msgid "Firmware Retraction"
+msgstr "Програмне утягування/відкликання"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1565
+msgid "The supplied name is empty. It can't be saved."
+msgstr "Надане ім'я порожнє. Не вдається зберегти."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1576
+msgid "Something is wrong. It can't be saved."
+msgstr "Щось не так. Не вдається зберегти."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1593
+msgid "remove"
+msgstr "перемістити"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1593
+msgid "delete"
+msgstr "видалити"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1594
+msgid "Are you sure you want to "
+msgstr "Ви впевнені, що хочете "
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1594
+msgid " the selected preset?"
+msgstr "вибране налаштування?"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1595
+msgid "Remove"
+msgstr "Перемістити"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1595
+msgid "Delete"
+msgstr "Видалити"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1596
+msgid " Preset"
+msgstr " Налаштування"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1648
+msgid "All"
+msgstr "Всі"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1679
+msgid "Select the printers this profile is compatible with."
+msgstr "Оберіть принтери, сумісні з цим профілем."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1680
+msgid "Compatible printers"
+msgstr "Сумісні принтери"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1763
+msgid "Save "
+msgstr "Зберегти "
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1763
+msgid " as:"
+msgstr " як:"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1797
+msgid ""
+"The supplied name is not valid; the following characters are not allowed:"
+msgstr "Надане ім'я недійсне; такі символи не допускаються:"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp:1800
+msgid "The supplied name is not available."
+msgstr "Надане ім'я недійсне."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:178
+msgid "Print Settings"
+msgstr "Налаштування друку"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:198
+msgid "Filament Settings"
+msgstr "Налаштування філаменту"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:224
+msgid "Printer Settings"
+msgstr "Налаштування принтеру"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp:244
+msgid "Save preset"
+msgstr "Зберегти налаштування"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\Field.cpp:35
+msgid "default"
+msgstr "за замовчуванням"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:121
+msgid "Size in X and Y of the rectangular plate."
+msgstr "Розмір прямокутної подложки за X та Y."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:127
+msgid "Origin"
+msgstr "Початок координат"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:128
+msgid ""
+"Distance of the 0,0 G-code coordinate from the front left corner of the "
+"rectangle."
+msgstr "Відстань координат 0,0 G-коду від нижнього лівого кута прямокутника."
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:135
+msgid "mm"
+msgstr "мм"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:136
+msgid "Diameter"
+msgstr "Діаметр"
+
+#: c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp:137
+msgid ""
+"Diameter of the print bed. It is assumed that origin (0,0) is located in the "
+"center."
+msgstr ""
+"Діаметр подложки. Передбачається, що початок координат (0,0) знаходиться в "
+"центрі."
diff --git a/resources/profiles/Original Prusa i3 MK2 and MK2S.ini b/resources/profiles/Original Prusa i3 MK2 and MK2S.ini
new file mode 100644
index 000000000..a186c3775
--- /dev/null
+++ b/resources/profiles/Original Prusa i3 MK2 and MK2S.ini	
@@ -0,0 +1,3376 @@
+# generated by Slic3r Prusa Edition 1.39.0 on 2018-01-06 at 15:10:57
+
+[print:0.05mm DETAIL]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 10
+bridge_acceleration = 300
+bridge_angle = 0
+bridge_flow_ratio = 0.7
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders==1
+complete_objects = 0
+default_acceleration = 500
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 20
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 25%
+fill_pattern = cubic
+first_layer_acceleration = 500
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 20
+gcode_comments = 0
+infill_acceleration = 800
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.5
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 30
+interface_shells = 0
+layer_height = 0.05
+max_print_speed = 80
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 300
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 30
+perimeters = 3
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 15
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 30
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 1
+support_material_extrusion_width = 0.3
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 1.5
+support_material_speed = 30
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.45
+top_solid_infill_speed = 20
+top_solid_layers = 15
+travel_speed = 180
+wipe_tower = 0
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.05mm DETAIL 0.25 nozzle]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 10
+bridge_acceleration = 300
+bridge_angle = 0
+bridge_flow_ratio = 0.7
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.25 and num_extruders==1
+complete_objects = 0
+default_acceleration = 500
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0
+external_perimeter_speed = 20
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.28
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 500
+first_layer_extrusion_width = 0.3
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 20
+gcode_comments = 0
+infill_acceleration = 800
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 20
+interface_shells = 0
+layer_height = 0.05
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 300
+perimeter_extruder = 1
+perimeter_extrusion_width = 0
+perimeter_speed = 20
+perimeters = 4
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 10
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0
+solid_infill_speed = 20
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 1
+support_material_extrusion_width = 0.18
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 0
+support_material_interface_spacing = 0.15
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 1
+support_material_speed = 20
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 150%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0
+top_solid_infill_speed = 20
+top_solid_layers = 15
+travel_speed = 200
+wipe_tower = 0
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.05mm DETAIL MK3]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 10
+bridge_acceleration = 300
+bridge_angle = 0
+bridge_flow_ratio = 0.7
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/
+complete_objects = 0
+default_acceleration = 500
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 20
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 25%
+fill_pattern = grid
+first_layer_acceleration = 500
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 20
+gcode_comments = 0
+infill_acceleration = 800
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 30
+interface_shells = 0
+layer_height = 0.05
+max_print_speed = 80
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 300
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 30
+perimeters = 3
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 15
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 30
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 1
+support_material_extrusion_width = 0.3
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 1.5
+support_material_speed = 30
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 20
+top_solid_layers = 15
+travel_speed = 180
+wipe_tower = 0
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.10mm DETAIL]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 7
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.7
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders==1
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 40
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.1
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 50
+perimeters = 3
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 50
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 1
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.45
+top_solid_infill_speed = 40
+top_solid_layers = 9
+travel_speed = 120
+wipe_tower = 0
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.10mm DETAIL 0.25 nozzle]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 7
+bridge_acceleration = 600
+bridge_angle = 0
+bridge_flow_ratio = 0.7
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.25
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.25
+external_perimeter_speed = 20
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.25
+fill_angle = 45
+fill_density = 15%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.25
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 1600
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.25
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 40
+interface_shells = 0
+layer_height = 0.1
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 600
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.25
+perimeter_speed = 25
+perimeters = 4
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 10
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.25
+solid_infill_speed = 40
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 1
+support_material_extrusion_width = 0.18
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 0
+support_material_interface_spacing = 0.15
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 1
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 150%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.25
+top_solid_infill_speed = 30
+top_solid_layers = 9
+travel_speed = 120
+wipe_tower = 0
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.10mm DETAIL MK3]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 4
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 30
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 35
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = grid
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 3500
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 200
+interface_shells = 0
+layer_height = 0.1
+max_print_speed = 250
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 45
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 200
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 0
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 50
+top_solid_layers = 5
+travel_speed = 250
+wipe_tower = 0
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.15mm 100mms Linear Advance]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 4
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.95
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 50
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 100
+interface_shells = 0
+layer_height = 0.15
+max_print_speed = 150
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 60
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 30
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 100
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 0
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 60
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 70
+top_solid_layers = 5
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.15mm OPTIMAL]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 5
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 40
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.15
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 50
+perimeters = 3
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 50
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 1
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.45
+top_solid_infill_speed = 40
+top_solid_layers = 7
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.15mm OPTIMAL 0.25 nozzle]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 5
+bridge_acceleration = 600
+bridge_angle = 0
+bridge_flow_ratio = 0.7
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.25
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.25
+external_perimeter_speed = 20
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.25
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.25
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 1600
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.25
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 40
+interface_shells = 0
+layer_height = 0.15
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 600
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.25
+perimeter_speed = 25
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 10
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.25
+solid_infill_speed = 40
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 1
+support_material_extrusion_width = 0.2
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 0
+support_material_interface_spacing = 0.15
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 1
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 35
+support_material_with_sheath = 0
+support_material_xy_spacing = 150%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.25
+top_solid_infill_speed = 30
+top_solid_layers = 7
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.15mm OPTIMAL 0.6 nozzle]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 5
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.61
+external_perimeter_speed = 40
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.67
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.65
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.75
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.15
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.65
+perimeter_speed = 50
+perimeters = 3
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.65
+solid_infill_speed = 50
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.6
+top_solid_infill_speed = 40
+top_solid_layers = 7
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.15mm OPTIMAL MK3]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 4
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 30
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 35
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = grid
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 3500
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 200
+interface_shells = 0
+layer_height = 0.15
+max_print_speed = 250
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 45
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 200
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 0
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 50
+top_solid_layers = 5
+travel_speed = 250
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.15mm OPTIMAL SOLUBLE FULL]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 5
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 25
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.15
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = Set your solluble extruder in Multiple Extruders > Support material/raft/skirt extruder &  Support material/raft interface extruder
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 1
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 40
+perimeters = 3
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 0
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 40
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 1
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0
+support_material_enforce_layers = 0
+support_material_extruder = 4
+support_material_extrusion_width = 0.45
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 4
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.1
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 1
+support_material_threshold = 80
+support_material_with_sheath = 1
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.45
+top_solid_infill_speed = 30
+top_solid_layers = 7
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 20
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.15mm OPTIMAL SOLUBLE INTERFACE]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 5
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 25
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.15
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = Set your solluble extruder in Multiple Extruders >  Support material/raft interface extruder
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 1
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 40
+perimeters = 3
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 0
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 40
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 1
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.45
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 4
+support_material_interface_layers = 3
+support_material_interface_spacing = 0.1
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 1
+support_material_threshold = 80
+support_material_with_sheath = 0
+support_material_xy_spacing = 120%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.45
+top_solid_infill_speed = 30
+top_solid_layers = 7
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 20
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.20mm 100mms Linear Advance]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 4
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.95
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 50
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 100
+interface_shells = 0
+layer_height = 0.2
+max_print_speed = 150
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 60
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 30
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 100
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 0
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 60
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 70
+top_solid_layers = 5
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.20mm FAST MK3]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 4
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 30
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 35
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = grid
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 3500
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 200
+interface_shells = 0
+layer_height = 0.2
+max_print_speed = 250
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 45
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 200
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 0
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 50
+top_solid_layers = 5
+travel_speed = 250
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.20mm NORMAL]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 4
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.95
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 40
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.2
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 50
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 50
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 0
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 40
+top_solid_layers = 5
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.20mm NORMAL 0.6 nozzle]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 4
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.61
+external_perimeter_speed = 40
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.67
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.65
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.75
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.2
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.65
+perimeter_speed = 50
+perimeters = 3
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.65
+solid_infill_speed = 50
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.6
+top_solid_infill_speed = 40
+top_solid_layers = 5
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.20mm NORMAL SOLUBLE FULL]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 4
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.95
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 30
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.2
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = Set your solluble extruder in Multiple Extruders > Support material/raft/skirt extruder &  Support material/raft interface extruder
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 1
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 40
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 0
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 40
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 1
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0
+support_material_enforce_layers = 0
+support_material_extruder = 4
+support_material_extrusion_width = 0.45
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 4
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.1
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 1
+support_material_threshold = 80
+support_material_with_sheath = 1
+support_material_xy_spacing = 120%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 30
+top_solid_layers = 5
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 20
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.20mm NORMAL SOLUBLE INTERFACE]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 4
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.95
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 30
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.2
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = Set your solluble extruder in Multiple Extruders >  Support material/raft interface extruder
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 1
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 40
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 0
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 40
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 1
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.45
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 4
+support_material_interface_layers = 3
+support_material_interface_spacing = 0.1
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 1
+support_material_threshold = 80
+support_material_with_sheath = 0
+support_material_xy_spacing = 120%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 30
+top_solid_layers = 5
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 20
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.35mm FAST]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 3
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.95
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.6
+external_perimeter_speed = 40
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.7
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.35
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.43
+perimeter_speed = 50
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.7
+solid_infill_speed = 60
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 1
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.43
+top_solid_infill_speed = 50
+top_solid_layers = 4
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.35mm FAST 0.6 nozzle]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 7
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.61
+external_perimeter_speed = 40
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.67
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.65
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.75
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.35
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.65
+perimeter_speed = 50
+perimeters = 3
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.65
+solid_infill_speed = 60
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.6
+top_solid_infill_speed = 50
+top_solid_layers = 9
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.35mm FAST sol full 0.6 nozzle]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 3
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 and num_extruders>1
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.6
+external_perimeter_speed = 30
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.67
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.65
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.75
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.35
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = Set your solluble extruder in Multiple Extruders >  Support material/raft interface extruder
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 1
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.65
+perimeter_speed = 40
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 0
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.65
+solid_infill_speed = 60
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 1
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0
+support_material_enforce_layers = 0
+support_material_extruder = 4
+support_material_extrusion_width = 0.55
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 4
+support_material_interface_layers = 3
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 1
+support_material_threshold = 80
+support_material_with_sheath = 0
+support_material_xy_spacing = 120%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.57
+top_solid_infill_speed = 50
+top_solid_layers = 4
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 20
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.35mm FAST sol int 0.6 nozzle]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 3
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 and num_extruders>1
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.6
+external_perimeter_speed = 30
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.67
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.65
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.75
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.35
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = Set your solluble extruder in Multiple Extruders >  Support material/raft interface extruder
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 1
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.65
+perimeter_speed = 40
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 0
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.65
+solid_infill_speed = 60
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 1
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.55
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 4
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 1
+support_material_threshold = 80
+support_material_with_sheath = 0
+support_material_xy_spacing = 150%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.57
+top_solid_infill_speed = 50
+top_solid_layers = 4
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 20
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[filament:ColorFabb Brass Bronze]
+bed_temperature = 60
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = nozzle_diameter[0]>0.35
+cooling = 1
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1.3
+fan_always_on = 1
+fan_below_layer_time = 100
+filament_colour = #804040
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 60
+first_layer_temperature = 210
+max_fan_speed = 100
+min_fan_speed = 100
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 210
+
+[filament:ColorFabb HT]
+bed_temperature = 105
+bridge_fan_speed = 30
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 10
+filament_colour = #FF8000
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 105
+first_layer_temperature = 270
+max_fan_speed = 20
+min_fan_speed = 10
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
+temperature = 270
+
+[filament:ColorFabb PLA-PHA]
+bed_temperature = 60
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 100
+filament_colour = #FF3232
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 15
+filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty Mladeč PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 60
+first_layer_temperature = 215
+max_fan_speed = 100
+min_fan_speed = 100
+min_print_speed = 15
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 210
+
+[filament:ColorFabb Woodfil]
+bed_temperature = 60
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = nozzle_diameter[0]>0.35
+cooling = 1
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1.2
+fan_always_on = 1
+fan_below_layer_time = 100
+filament_colour = #804040
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 60
+first_layer_temperature = 200
+max_fan_speed = 100
+min_fan_speed = 100
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 200
+
+[filament:ColorFabb XT]
+bed_temperature = 90
+bridge_fan_speed = 50
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 20
+filament_colour = #FF8000
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 90
+first_layer_temperature = 260
+max_fan_speed = 50
+min_fan_speed = 30
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
+temperature = 270
+
+[filament:ColorFabb XT-CF20]
+bed_temperature = 90
+bridge_fan_speed = 50
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1.2
+fan_always_on = 1
+fan_below_layer_time = 20
+filament_colour = #804040
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 1
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PET
+first_layer_bed_temperature = 90
+first_layer_temperature = 260
+max_fan_speed = 50
+min_fan_speed = 30
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 260
+
+[filament:ColorFabb nGen]
+bed_temperature = 85
+bridge_fan_speed = 40
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 10
+filament_colour = #FF8000
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = NGEN
+first_layer_bed_temperature = 85
+first_layer_temperature = 240
+max_fan_speed = 35
+min_fan_speed = 20
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
+temperature = 240
+
+[filament:ColorFabb nGen flex]
+bed_temperature = 85
+bridge_fan_speed = 40
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 10
+filament_colour = #FF8000
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 5
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = FLEX
+first_layer_bed_temperature = 85
+first_layer_temperature = 260
+max_fan_speed = 35
+min_fan_speed = 20
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 260
+
+[filament:E3D Edge]
+bed_temperature = 90
+bridge_fan_speed = 50
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 20
+filament_colour = #FF8000
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty Mladeč PETG"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PET
+first_layer_bed_temperature = 85
+first_layer_temperature = 230
+max_fan_speed = 50
+min_fan_speed = 30
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
+temperature = 240
+
+[filament:E3D PC-ABS]
+bed_temperature = 100
+bridge_fan_speed = 30
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 20
+filament_colour = #3A80CA
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 13
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 100
+first_layer_temperature = 270
+max_fan_speed = 30
+min_fan_speed = 10
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 270
+
+[filament:Fillamentum ABS]
+bed_temperature = 100
+bridge_fan_speed = 30
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 20
+filament_colour = #3A80CA
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 13
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = ABS
+first_layer_bed_temperature = 100
+first_layer_temperature = 240
+max_fan_speed = 30
+min_fan_speed = 10
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 240
+
+[filament:Fillamentum ASA]
+bed_temperature = 100
+bridge_fan_speed = 30
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 20
+filament_colour = #3A80CA
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 13
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 100
+first_layer_temperature = 265
+max_fan_speed = 30
+min_fan_speed = 10
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 265
+
+[filament:Fillamentum CPE HG100 HM100]
+bed_temperature = 90
+bridge_fan_speed = 50
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 20
+filament_colour = #FF8000
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = "CPE HG100 , CPE HM100"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PET
+first_layer_bed_temperature = 90
+first_layer_temperature = 260
+max_fan_speed = 80
+min_fan_speed = 80
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
+temperature = 260
+
+[filament:Fillamentum Timberfil]
+bed_temperature = 60
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = nozzle_diameter[0]>0.35
+cooling = 1
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1.2
+fan_always_on = 1
+fan_below_layer_time = 100
+filament_colour = #804040
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 60
+first_layer_temperature = 190
+max_fan_speed = 100
+min_fan_speed = 100
+min_print_speed = 15
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 190
+
+[filament:Generic ABS]
+bed_temperature = 100
+bridge_fan_speed = 30
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 20
+filament_colour = #3A80CA
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 13
+filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty Mladeč ABS"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = ABS
+first_layer_bed_temperature = 100
+first_layer_temperature = 255
+max_fan_speed = 30
+min_fan_speed = 10
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 255
+
+[filament:Generic PET]
+bed_temperature = 90
+bridge_fan_speed = 50
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 20
+filament_colour = #FF8000
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty Mladeč PETG"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PET
+first_layer_bed_temperature = 85
+first_layer_temperature = 230
+max_fan_speed = 50
+min_fan_speed = 30
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
+temperature = 240
+
+[filament:Generic PLA]
+bed_temperature = 60
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 100
+filament_colour = #FF3232
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 15
+filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty Mladeč PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 60
+first_layer_temperature = 215
+max_fan_speed = 100
+min_fan_speed = 100
+min_print_speed = 15
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 210
+
+[filament:Polymaker PC-Max]
+bed_temperature = 120
+bridge_fan_speed = 30
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 20
+filament_colour = #3A80CA
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 13
+filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty Mladeč ABS"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = ABS
+first_layer_bed_temperature = 120
+first_layer_temperature = 270
+max_fan_speed = 30
+min_fan_speed = 10
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 270
+
+[filament:Primavalue PVA]
+bed_temperature = 60
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 100
+filament_colour = #FFFFD7
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = "List of materials tested with standart PVA print settings for MK2:\n\nPrimaSelect PVA+\nICE FILAMENTS PVA 'NAUGHTY NATURAL'\nVerbatim BVOH"
+filament_settings_id = 
+filament_soluble = 1
+filament_type = PVA
+first_layer_bed_temperature = 60
+first_layer_temperature = 195
+max_fan_speed = 100
+min_fan_speed = 100
+min_print_speed = 15
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 195
+
+[filament:Prusa ABS]
+bed_temperature = 100
+bridge_fan_speed = 30
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 20
+filament_colour = #3A80CA
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 13
+filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty Mladeč ABS"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = ABS
+first_layer_bed_temperature = 100
+first_layer_temperature = 255
+max_fan_speed = 30
+min_fan_speed = 10
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 255
+
+[filament:Prusa HIPS]
+bed_temperature = 100
+bridge_fan_speed = 50
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 0.9
+fan_always_on = 1
+fan_below_layer_time = 10
+filament_colour = #FFFFD7
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 13
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 1
+filament_type = HIPS
+first_layer_bed_temperature = 100
+first_layer_temperature = 220
+max_fan_speed = 20
+min_fan_speed = 20
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 220
+
+[filament:Prusa PET]
+bed_temperature = 90
+bridge_fan_speed = 50
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 20
+filament_colour = #FF8000
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty Mladeč PETG"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PET
+first_layer_bed_temperature = 85
+first_layer_temperature = 230
+max_fan_speed = 50
+min_fan_speed = 30
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
+temperature = 240
+
+[filament:Prusa PLA]
+bed_temperature = 60
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 100
+filament_colour = #FF3232
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 15
+filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty Mladeč PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 60
+first_layer_temperature = 215
+max_fan_speed = 100
+min_fan_speed = 100
+min_print_speed = 15
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 210
+
+[filament:SemiFlex or Flexfill 98A]
+bed_temperature = 50
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = nozzle_diameter[0]>0.35 and num_extruders==1
+cooling = 0
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1.2
+fan_always_on = 0
+fan_below_layer_time = 100
+filament_colour = #00CA0A
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 2.5
+filament_notes = "List of materials tested with FLEX print settings & FLEX material settings for MK2:\n\nFillamentum Flex 98A\nFillamentum Flex 92A\nPlasty Mladeč PP\nPlasty Mladeč TPE32 \nPlasty Mladeč TPE88"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = FLEX
+first_layer_bed_temperature = 50
+first_layer_temperature = 220
+max_fan_speed = 90
+min_fan_speed = 70
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 230
+
+[filament:Taulman Bridge]
+bed_temperature = 50
+bridge_fan_speed = 40
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 20
+filament_colour = #DEE0E6
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 90
+first_layer_temperature = 240
+max_fan_speed = 5
+min_fan_speed = 0
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 250
+
+[filament:Taulman T-Glase]
+bed_temperature = 90
+bridge_fan_speed = 40
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 20
+filament_colour = #FF8000
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PET
+first_layer_bed_temperature = 90
+first_layer_temperature = 240
+max_fan_speed = 5
+min_fan_speed = 0
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 240
+
+[filament:Verbatim BVOH]
+bed_temperature = 60
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 100
+filament_colour = #FFFFD7
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty Mladeč PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH"
+filament_settings_id = 
+filament_soluble = 1
+filament_type = PLA
+first_layer_bed_temperature = 60
+first_layer_temperature = 215
+max_fan_speed = 100
+min_fan_speed = 100
+min_print_speed = 15
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 210
+
+[filament:Verbatim PP]
+bed_temperature = 100
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 2
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 100
+filament_colour = #DEE0E6
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 5
+filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nEsun PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty Mladeč PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nEUMAKERS PLA"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 100
+first_layer_temperature = 220
+max_fan_speed = 100
+min_fan_speed = 100
+min_print_speed = 15
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 220
+
+[printer:Original Prusa i3 MK2]
+bed_shape = 0x0,250x0,250x210,0x210
+before_layer_gcode = ;BEFORE_LAYER_CHANGE\n;[layer_z]\n\n
+between_objects_gcode = 
+deretract_speed = 0
+end_gcode = G4 ; wait\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors
+extruder_colour = #FFFF00
+extruder_offset = 0x0
+gcode_flavor = marlin
+layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z]
+max_layer_height = 0.25
+min_layer_height = 0.07
+nozzle_diameter = 0.4
+octoprint_apikey = 
+octoprint_host = 
+printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\n
+printer_settings_id = 
+retract_before_travel = 1
+retract_before_wipe = 0%
+retract_layer_change = 1
+retract_length = 0.8
+retract_length_toolchange = 3
+retract_lift = 0.6
+retract_lift_above = 0
+retract_lift_below = 199
+retract_restart_extra = 0
+retract_restart_extra_toolchange = 0
+retract_speed = 35
+serial_port = 
+serial_speed = 250000
+single_extruder_multi_material = 0
+start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83  ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0  F1000.0 ; intro line\nG1 X100.0 E12.5  F1000.0 ; intro line\nG92 E0.0
+toolchange_gcode = 
+use_firmware_retraction = 0
+use_relative_e_distances = 1
+use_volumetric_e = 0
+variable_layer_height = 1
+wipe = 1
+z_offset = 0
+
+[printer:Original Prusa i3 MK2 0.25 nozzle]
+bed_shape = 0x0,250x0,250x210,0x210
+before_layer_gcode = ;BEFORE_LAYER_CHANGE\n;[layer_z]\n\n
+between_objects_gcode = 
+deretract_speed = 0
+end_gcode = G4 ; wait\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors
+extruder_colour = #FFFF00
+extruder_offset = 0x0
+gcode_flavor = marlin
+layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z]
+max_layer_height = 0.1
+min_layer_height = 0.05
+nozzle_diameter = 0.25
+octoprint_apikey = 
+octoprint_host = 
+printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\n
+printer_settings_id = 
+retract_before_travel = 1
+retract_before_wipe = 0%
+retract_layer_change = 1
+retract_length = 1
+retract_length_toolchange = 3
+retract_lift = 0.6
+retract_lift_above = 0
+retract_lift_below = 199
+retract_restart_extra = 0
+retract_restart_extra_toolchange = 0
+retract_speed = 50
+serial_port = 
+serial_speed = 250000
+single_extruder_multi_material = 0
+start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83  ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0  F1000.0 ; intro line\nG1 X100.0 E12.5  F1000.0 ; intro line\nG92 E0.0
+toolchange_gcode = 
+use_firmware_retraction = 0
+use_relative_e_distances = 1
+use_volumetric_e = 0
+variable_layer_height = 0
+wipe = 1
+z_offset = 0
+
+[printer:Original Prusa i3 MK2 0.6 nozzle]
+bed_shape = 0x0,250x0,250x210,0x210
+before_layer_gcode = ;BEFORE_LAYER_CHANGE\n;[layer_z]\n\n
+between_objects_gcode = 
+deretract_speed = 0
+end_gcode = G4 ; wait\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors
+extruder_colour = #FFFF00
+extruder_offset = 0x0
+gcode_flavor = marlin
+layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z]
+max_layer_height = 0.35
+min_layer_height = 0.1
+nozzle_diameter = 0.6
+octoprint_apikey = 
+octoprint_host = 
+printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\n
+printer_settings_id = 
+retract_before_travel = 1
+retract_before_wipe = 0%
+retract_layer_change = 1
+retract_length = 0.8
+retract_length_toolchange = 3
+retract_lift = 0.6
+retract_lift_above = 0
+retract_lift_below = 199
+retract_restart_extra = 0
+retract_restart_extra_toolchange = 0
+retract_speed = 35
+serial_port = 
+serial_speed = 250000
+single_extruder_multi_material = 0
+start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83  ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0  F1000.0 ; intro line\nG1 X100.0 E12.5  F1000.0 ; intro line\nG92 E0.0
+toolchange_gcode = 
+use_firmware_retraction = 0
+use_relative_e_distances = 1
+use_volumetric_e = 0
+variable_layer_height = 1
+wipe = 1
+z_offset = 0
+
+[presets]
+print = 0.15mm OPTIMAL
+printer = Original Prusa i3 MK2
+filament = Prusa PLA
diff --git a/resources/profiles/Original Prusa i3 MK3, MK2S, MK2 and MK2S-MMU.ini b/resources/profiles/Original Prusa i3 MK2, MK2S, MK2MM and MK3.ini
similarity index 90%
rename from resources/profiles/Original Prusa i3 MK3, MK2S, MK2 and MK2S-MMU.ini
rename to resources/profiles/Original Prusa i3 MK2, MK2S, MK2MM and MK3.ini
index cb076ac35..64af7d9b2 100644
--- a/resources/profiles/Original Prusa i3 MK3, MK2S, MK2 and MK2S-MMU.ini	
+++ b/resources/profiles/Original Prusa i3 MK2, MK2S, MK2MM and MK3.ini	
@@ -1,4 +1,4 @@
-# generated by Slic3r Prusa Edition 1.38.4 on 2017-12-19 at 17:08:04
+# generated by Slic3r Prusa Edition 1.39.0.29-prusa3d-win64 on 2018-01-22 at 14:53:14
 
 [print:0.05mm DETAIL]
 avoid_crossing_perimeters = 0
@@ -238,7 +238,7 @@ extruder_clearance_radius = 20
 extrusion_width = 0.45
 fill_angle = 45
 fill_density = 25%
-fill_pattern = cubic
+fill_pattern = grid
 first_layer_acceleration = 500
 first_layer_extrusion_width = 0.42
 first_layer_height = 0.2
@@ -248,7 +248,7 @@ gcode_comments = 0
 infill_acceleration = 800
 infill_every_layers = 1
 infill_extruder = 1
-infill_extrusion_width = 0.5
+infill_extrusion_width = 0.45
 infill_first = 0
 infill_only_where_needed = 0
 infill_overlap = 25%
@@ -307,7 +307,7 @@ support_material_with_sheath = 0
 support_material_xy_spacing = 60%
 thin_walls = 0
 threads = 4
-top_infill_extrusion_width = 0.45
+top_infill_extrusion_width = 0.4
 top_solid_infill_speed = 20
 top_solid_layers = 15
 travel_speed = 180
@@ -532,7 +532,7 @@ xy_size_compensation = 0
 
 [print:0.10mm DETAIL MK3]
 avoid_crossing_perimeters = 0
-bottom_solid_layers = 4
+bottom_solid_layers = 7
 bridge_acceleration = 1000
 bridge_angle = 0
 bridge_flow_ratio = 0.8
@@ -548,7 +548,7 @@ elefant_foot_compensation = 0
 ensure_vertical_shell_thickness = 1
 external_fill_pattern = rectilinear
 external_perimeter_extrusion_width = 0.45
-external_perimeter_speed = 40
+external_perimeter_speed = 35
 external_perimeters_first = 0
 extra_perimeters = 0
 extruder_clearance_height = 20
@@ -556,24 +556,24 @@ extruder_clearance_radius = 20
 extrusion_width = 0.45
 fill_angle = 45
 fill_density = 20%
-fill_pattern = cubic
+fill_pattern = grid
 first_layer_acceleration = 1000
 first_layer_extrusion_width = 0.42
 first_layer_height = 0.2
 first_layer_speed = 30
 gap_fill_speed = 40
 gcode_comments = 0
-infill_acceleration = 3500
+infill_acceleration = 1500
 infill_every_layers = 1
 infill_extruder = 1
 infill_extrusion_width = 0.45
 infill_first = 0
 infill_only_where_needed = 0
-infill_overlap = 35%
-infill_speed = 200
+infill_overlap = 25%
+infill_speed = 170
 interface_shells = 0
 layer_height = 0.1
-max_print_speed = 250
+max_print_speed = 170
 max_volumetric_extrusion_rate_slope_negative = 0
 max_volumetric_extrusion_rate_slope_positive = 0
 max_volumetric_speed = 0
@@ -586,7 +586,7 @@ overhangs = 0
 perimeter_acceleration = 800
 perimeter_extruder = 1
 perimeter_extrusion_width = 0.45
-perimeter_speed = 60
+perimeter_speed = 45
 perimeters = 2
 post_process = 
 print_settings_id = 
@@ -601,7 +601,7 @@ solid_infill_below_area = 0
 solid_infill_every_layers = 0
 solid_infill_extruder = 1
 solid_infill_extrusion_width = 0.45
-solid_infill_speed = 200
+solid_infill_speed = 170
 spiral_vase = 0
 standby_temperature_delta = -5
 support_material = 0
@@ -627,8 +627,8 @@ thin_walls = 0
 threads = 4
 top_infill_extrusion_width = 0.4
 top_solid_infill_speed = 50
-top_solid_layers = 5
-travel_speed = 250
+top_solid_layers = 9
+travel_speed = 170
 wipe_tower = 0
 wipe_tower_per_color_wipe = 15
 wipe_tower_width = 60
@@ -1062,7 +1062,7 @@ xy_size_compensation = 0
 
 [print:0.15mm OPTIMAL MK3]
 avoid_crossing_perimeters = 0
-bottom_solid_layers = 4
+bottom_solid_layers = 5
 bridge_acceleration = 1000
 bridge_angle = 0
 bridge_flow_ratio = 0.8
@@ -1078,7 +1078,7 @@ elefant_foot_compensation = 0
 ensure_vertical_shell_thickness = 1
 external_fill_pattern = rectilinear
 external_perimeter_extrusion_width = 0.45
-external_perimeter_speed = 40
+external_perimeter_speed = 35
 external_perimeters_first = 0
 extra_perimeters = 0
 extruder_clearance_height = 20
@@ -1086,24 +1086,24 @@ extruder_clearance_radius = 20
 extrusion_width = 0.45
 fill_angle = 45
 fill_density = 20%
-fill_pattern = cubic
+fill_pattern = grid
 first_layer_acceleration = 1000
 first_layer_extrusion_width = 0.42
 first_layer_height = 0.2
 first_layer_speed = 30
 gap_fill_speed = 40
 gcode_comments = 0
-infill_acceleration = 3500
+infill_acceleration = 1500
 infill_every_layers = 1
 infill_extruder = 1
 infill_extrusion_width = 0.45
 infill_first = 0
 infill_only_where_needed = 0
-infill_overlap = 35%
-infill_speed = 200
+infill_overlap = 25%
+infill_speed = 170
 interface_shells = 0
 layer_height = 0.15
-max_print_speed = 250
+max_print_speed = 170
 max_volumetric_extrusion_rate_slope_negative = 0
 max_volumetric_extrusion_rate_slope_positive = 0
 max_volumetric_speed = 0
@@ -1116,7 +1116,7 @@ overhangs = 0
 perimeter_acceleration = 800
 perimeter_extruder = 1
 perimeter_extrusion_width = 0.45
-perimeter_speed = 60
+perimeter_speed = 45
 perimeters = 2
 post_process = 
 print_settings_id = 
@@ -1131,7 +1131,7 @@ solid_infill_below_area = 0
 solid_infill_every_layers = 0
 solid_infill_extruder = 1
 solid_infill_extrusion_width = 0.45
-solid_infill_speed = 200
+solid_infill_speed = 170
 spiral_vase = 0
 standby_temperature_delta = -5
 support_material = 0
@@ -1157,8 +1157,8 @@ thin_walls = 0
 threads = 4
 top_infill_extrusion_width = 0.4
 top_solid_infill_speed = 50
-top_solid_layers = 5
-travel_speed = 250
+top_solid_layers = 7
+travel_speed = 170
 wipe_tower = 1
 wipe_tower_per_color_wipe = 15
 wipe_tower_width = 60
@@ -1484,6 +1484,112 @@ wipe_tower_x = 180
 wipe_tower_y = 140
 xy_size_compensation = 0
 
+[print:0.20mm FAST MK3]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 4
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 30
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 35
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = grid
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 1500
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 170
+interface_shells = 0
+layer_height = 0.2
+max_print_speed = 170
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 45
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 170
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 0
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 50
+top_solid_layers = 5
+travel_speed = 170
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
 [print:0.20mm NORMAL]
 avoid_crossing_perimeters = 0
 bottom_solid_layers = 4
@@ -1696,112 +1802,6 @@ wipe_tower_x = 180
 wipe_tower_y = 140
 xy_size_compensation = 0
 
-[print:0.20mm NORMAL MK3]
-avoid_crossing_perimeters = 0
-bottom_solid_layers = 4
-bridge_acceleration = 1000
-bridge_angle = 0
-bridge_flow_ratio = 0.8
-bridge_speed = 30
-brim_width = 0
-clip_multipart_objects = 1
-compatible_printers = 
-compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/
-complete_objects = 0
-default_acceleration = 1000
-dont_support_bridges = 1
-elefant_foot_compensation = 0
-ensure_vertical_shell_thickness = 1
-external_fill_pattern = rectilinear
-external_perimeter_extrusion_width = 0.45
-external_perimeter_speed = 40
-external_perimeters_first = 0
-extra_perimeters = 0
-extruder_clearance_height = 20
-extruder_clearance_radius = 20
-extrusion_width = 0.45
-fill_angle = 45
-fill_density = 20%
-fill_pattern = cubic
-first_layer_acceleration = 1000
-first_layer_extrusion_width = 0.42
-first_layer_height = 0.2
-first_layer_speed = 30
-gap_fill_speed = 40
-gcode_comments = 0
-infill_acceleration = 3500
-infill_every_layers = 1
-infill_extruder = 1
-infill_extrusion_width = 0.45
-infill_first = 0
-infill_only_where_needed = 0
-infill_overlap = 35%
-infill_speed = 200
-interface_shells = 0
-layer_height = 0.2
-max_print_speed = 250
-max_volumetric_extrusion_rate_slope_negative = 0
-max_volumetric_extrusion_rate_slope_positive = 0
-max_volumetric_speed = 0
-min_skirt_length = 4
-notes = 
-only_retract_when_crossing_perimeters = 0
-ooze_prevention = 0
-output_filename_format = [input_filename_base].gcode
-overhangs = 0
-perimeter_acceleration = 800
-perimeter_extruder = 1
-perimeter_extrusion_width = 0.45
-perimeter_speed = 60
-perimeters = 2
-post_process = 
-print_settings_id = 
-raft_layers = 0
-resolution = 0
-seam_position = nearest
-skirt_distance = 2
-skirt_height = 3
-skirts = 1
-small_perimeter_speed = 20
-solid_infill_below_area = 0
-solid_infill_every_layers = 0
-solid_infill_extruder = 1
-solid_infill_extrusion_width = 0.45
-solid_infill_speed = 200
-spiral_vase = 0
-standby_temperature_delta = -5
-support_material = 0
-support_material_angle = 0
-support_material_buildplate_only = 0
-support_material_contact_distance = 0.15
-support_material_enforce_layers = 0
-support_material_extruder = 0
-support_material_extrusion_width = 0.35
-support_material_interface_contact_loops = 0
-support_material_interface_extruder = 0
-support_material_interface_layers = 2
-support_material_interface_spacing = 0.2
-support_material_interface_speed = 100%
-support_material_pattern = rectilinear
-support_material_spacing = 2
-support_material_speed = 50
-support_material_synchronize_layers = 0
-support_material_threshold = 45
-support_material_with_sheath = 0
-support_material_xy_spacing = 60%
-thin_walls = 0
-threads = 4
-top_infill_extrusion_width = 0.4
-top_solid_infill_speed = 50
-top_solid_layers = 5
-travel_speed = 250
-wipe_tower = 1
-wipe_tower_per_color_wipe = 15
-wipe_tower_width = 60
-wipe_tower_x = 180
-wipe_tower_y = 140
-xy_size_compensation = 0
-
 [print:0.20mm NORMAL SOLUBLE FULL]
 avoid_crossing_perimeters = 0
 bottom_solid_layers = 4
@@ -2226,112 +2226,6 @@ wipe_tower_x = 180
 wipe_tower_y = 140
 xy_size_compensation = 0
 
-[print:0.35mm FAST MK3]
-avoid_crossing_perimeters = 0
-bottom_solid_layers = 4
-bridge_acceleration = 1000
-bridge_angle = 0
-bridge_flow_ratio = 0.8
-bridge_speed = 30
-brim_width = 0
-clip_multipart_objects = 1
-compatible_printers = 
-compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/
-complete_objects = 0
-default_acceleration = 1000
-dont_support_bridges = 1
-elefant_foot_compensation = 0
-ensure_vertical_shell_thickness = 1
-external_fill_pattern = rectilinear
-external_perimeter_extrusion_width = 0.6
-external_perimeter_speed = 40
-external_perimeters_first = 0
-extra_perimeters = 0
-extruder_clearance_height = 20
-extruder_clearance_radius = 20
-extrusion_width = 0.45
-fill_angle = 45
-fill_density = 20%
-fill_pattern = cubic
-first_layer_acceleration = 1000
-first_layer_extrusion_width = 0.42
-first_layer_height = 0.2
-first_layer_speed = 30
-gap_fill_speed = 40
-gcode_comments = 0
-infill_acceleration = 3500
-infill_every_layers = 1
-infill_extruder = 1
-infill_extrusion_width = 0.7
-infill_first = 0
-infill_only_where_needed = 0
-infill_overlap = 35%
-infill_speed = 200
-interface_shells = 0
-layer_height = 0.35
-max_print_speed = 250
-max_volumetric_extrusion_rate_slope_negative = 0
-max_volumetric_extrusion_rate_slope_positive = 0
-max_volumetric_speed = 0
-min_skirt_length = 4
-notes = 
-only_retract_when_crossing_perimeters = 0
-ooze_prevention = 0
-output_filename_format = [input_filename_base].gcode
-overhangs = 0
-perimeter_acceleration = 800
-perimeter_extruder = 1
-perimeter_extrusion_width = 0.45
-perimeter_speed = 60
-perimeters = 2
-post_process = 
-print_settings_id = 
-raft_layers = 0
-resolution = 0
-seam_position = nearest
-skirt_distance = 2
-skirt_height = 3
-skirts = 1
-small_perimeter_speed = 20
-solid_infill_below_area = 0
-solid_infill_every_layers = 0
-solid_infill_extruder = 1
-solid_infill_extrusion_width = 0.7
-solid_infill_speed = 200
-spiral_vase = 0
-standby_temperature_delta = -5
-support_material = 0
-support_material_angle = 0
-support_material_buildplate_only = 0
-support_material_contact_distance = 0.15
-support_material_enforce_layers = 0
-support_material_extruder = 0
-support_material_extrusion_width = 0.35
-support_material_interface_contact_loops = 0
-support_material_interface_extruder = 0
-support_material_interface_layers = 2
-support_material_interface_spacing = 0.2
-support_material_interface_speed = 100%
-support_material_pattern = rectilinear
-support_material_spacing = 2
-support_material_speed = 50
-support_material_synchronize_layers = 0
-support_material_threshold = 45
-support_material_with_sheath = 0
-support_material_xy_spacing = 60%
-thin_walls = 0
-threads = 4
-top_infill_extrusion_width = 0.45
-top_solid_infill_speed = 50
-top_solid_layers = 4
-travel_speed = 250
-wipe_tower = 1
-wipe_tower_per_color_wipe = 15
-wipe_tower_width = 60
-wipe_tower_x = 180
-wipe_tower_y = 140
-xy_size_compensation = 0
-
 [print:0.35mm FAST sol full 0.6 nozzle]
 avoid_crossing_perimeters = 0
 bottom_solid_layers = 3
@@ -2544,7 +2438,7 @@ wipe_tower_x = 180
 wipe_tower_y = 140
 xy_size_compensation = 0
 
-[filament:ColorFabb Brass Bronze  1.75mm]
+[filament:ColorFabb Brass Bronze]
 bed_temperature = 60
 bridge_fan_speed = 100
 compatible_printers = 
@@ -2567,13 +2461,13 @@ filament_type = PLA
 first_layer_bed_temperature = 60
 first_layer_temperature = 210
 max_fan_speed = 100
-min_fan_speed = 85
+min_fan_speed = 100
 min_print_speed = 5
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
 temperature = 210
 
-[filament:ColorFabb HT 1.75mm]
+[filament:ColorFabb HT]
 bed_temperature = 105
 bridge_fan_speed = 30
 compatible_printers = 
@@ -2598,7 +2492,7 @@ first_layer_temperature = 270
 max_fan_speed = 20
 min_fan_speed = 10
 min_print_speed = 5
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
 temperature = 270
 
@@ -2625,13 +2519,13 @@ filament_type = PLA
 first_layer_bed_temperature = 60
 first_layer_temperature = 215
 max_fan_speed = 100
-min_fan_speed = 85
+min_fan_speed = 100
 min_print_speed = 15
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
 temperature = 210
 
-[filament:ColorFabb Woodfil 1.75mm]
+[filament:ColorFabb Woodfil]
 bed_temperature = 60
 bridge_fan_speed = 100
 compatible_printers = 
@@ -2654,14 +2548,14 @@ filament_type = PLA
 first_layer_bed_temperature = 60
 first_layer_temperature = 200
 max_fan_speed = 100
-min_fan_speed = 85
+min_fan_speed = 100
 min_print_speed = 5
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
 temperature = 200
 
-[filament:ColorFabb XT 1.75mm]
-bed_temperature = 65
+[filament:ColorFabb XT]
+bed_temperature = 90
 bridge_fan_speed = 50
 compatible_printers = 
 compatible_printers_condition = 
@@ -2681,15 +2575,15 @@ filament_settings_id =
 filament_soluble = 0
 filament_type = PLA
 first_layer_bed_temperature = 90
-first_layer_temperature = 240
+first_layer_temperature = 260
 max_fan_speed = 50
 min_fan_speed = 30
 min_print_speed = 5
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
-temperature = 240
+temperature = 270
 
-[filament:ColorFabb XT-CF20 1.75mm]
+[filament:ColorFabb XT-CF20]
 bed_temperature = 90
 bridge_fan_speed = 50
 compatible_printers = 
@@ -2714,11 +2608,11 @@ first_layer_temperature = 260
 max_fan_speed = 50
 min_fan_speed = 30
 min_print_speed = 5
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
 temperature = 260
 
-[filament:ColorFabb nGen 1.75mm]
+[filament:ColorFabb nGen]
 bed_temperature = 85
 bridge_fan_speed = 40
 compatible_printers = 
@@ -2743,7 +2637,7 @@ first_layer_temperature = 240
 max_fan_speed = 35
 min_fan_speed = 20
 min_print_speed = 5
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
 temperature = 240
 
@@ -2772,7 +2666,7 @@ first_layer_temperature = 260
 max_fan_speed = 35
 min_fan_speed = 20
 min_print_speed = 5
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
 temperature = 260
 
@@ -2801,11 +2695,11 @@ first_layer_temperature = 230
 max_fan_speed = 50
 min_fan_speed = 30
 min_print_speed = 5
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
 temperature = 240
 
-[filament:E3D PC-ABS 1.75mm]
+[filament:E3D PC-ABS]
 bed_temperature = 100
 bridge_fan_speed = 30
 compatible_printers = 
@@ -2830,11 +2724,11 @@ first_layer_temperature = 270
 max_fan_speed = 30
 min_fan_speed = 10
 min_print_speed = 5
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
 temperature = 270
 
-[filament:Fillamentum ABS 1.75mm]
+[filament:Fillamentum ABS]
 bed_temperature = 100
 bridge_fan_speed = 30
 compatible_printers = 
@@ -2859,11 +2753,11 @@ first_layer_temperature = 240
 max_fan_speed = 30
 min_fan_speed = 10
 min_print_speed = 5
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
 temperature = 240
 
-[filament:Fillamentum ASA 1.75mm]
+[filament:Fillamentum ASA]
 bed_temperature = 100
 bridge_fan_speed = 30
 compatible_printers = 
@@ -2888,7 +2782,7 @@ first_layer_temperature = 265
 max_fan_speed = 30
 min_fan_speed = 10
 min_print_speed = 5
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
 temperature = 265
 
@@ -2913,13 +2807,13 @@ filament_settings_id =
 filament_soluble = 0
 filament_type = PET
 first_layer_bed_temperature = 90
-first_layer_temperature = 260
-max_fan_speed = 80
-min_fan_speed = 80
+first_layer_temperature = 275
+max_fan_speed = 50
+min_fan_speed = 50
 min_print_speed = 5
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
-temperature = 260
+temperature = 275
 
 [filament:Fillamentum Timberfil]
 bed_temperature = 60
@@ -2944,13 +2838,13 @@ filament_type = PLA
 first_layer_bed_temperature = 60
 first_layer_temperature = 190
 max_fan_speed = 100
-min_fan_speed = 85
+min_fan_speed = 100
 min_print_speed = 15
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
 temperature = 190
 
-[filament:Generic ABS 1.75mm]
+[filament:Generic ABS]
 bed_temperature = 100
 bridge_fan_speed = 30
 compatible_printers = 
@@ -2975,11 +2869,11 @@ first_layer_temperature = 255
 max_fan_speed = 30
 min_fan_speed = 10
 min_print_speed = 5
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
 temperature = 255
 
-[filament:Generic PET 1.75mm]
+[filament:Generic PET]
 bed_temperature = 90
 bridge_fan_speed = 50
 compatible_printers = 
@@ -3004,11 +2898,11 @@ first_layer_temperature = 230
 max_fan_speed = 50
 min_fan_speed = 30
 min_print_speed = 5
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
 temperature = 240
 
-[filament:Generic PLA 1.75mm]
+[filament:Generic PLA]
 bed_temperature = 60
 bridge_fan_speed = 100
 compatible_printers = 
@@ -3031,9 +2925,9 @@ filament_type = PLA
 first_layer_bed_temperature = 60
 first_layer_temperature = 215
 max_fan_speed = 100
-min_fan_speed = 85
+min_fan_speed = 100
 min_print_speed = 15
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
 temperature = 210
 
@@ -3062,7 +2956,7 @@ first_layer_temperature = 270
 max_fan_speed = 30
 min_fan_speed = 10
 min_print_speed = 5
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
 temperature = 270
 
@@ -3089,13 +2983,13 @@ filament_type = PVA
 first_layer_bed_temperature = 60
 first_layer_temperature = 195
 max_fan_speed = 100
-min_fan_speed = 85
+min_fan_speed = 100
 min_print_speed = 15
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
 temperature = 195
 
-[filament:Prusa ABS 1.75mm]
+[filament:Prusa ABS]
 bed_temperature = 100
 bridge_fan_speed = 30
 compatible_printers = 
@@ -3120,11 +3014,11 @@ first_layer_temperature = 255
 max_fan_speed = 30
 min_fan_speed = 10
 min_print_speed = 5
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
 temperature = 255
 
-[filament:Prusa HIPS 1.75mm]
+[filament:Prusa HIPS]
 bed_temperature = 100
 bridge_fan_speed = 50
 compatible_printers = 
@@ -3149,11 +3043,11 @@ first_layer_temperature = 220
 max_fan_speed = 20
 min_fan_speed = 20
 min_print_speed = 5
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
 temperature = 220
 
-[filament:Prusa PET 1.75mm]
+[filament:Prusa PET]
 bed_temperature = 90
 bridge_fan_speed = 50
 compatible_printers = 
@@ -3178,11 +3072,11 @@ first_layer_temperature = 230
 max_fan_speed = 50
 min_fan_speed = 30
 min_print_speed = 5
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
 temperature = 240
 
-[filament:Prusa PLA 1.75mm]
+[filament:Prusa PLA]
 bed_temperature = 60
 bridge_fan_speed = 100
 compatible_printers = 
@@ -3205,9 +3099,9 @@ filament_type = PLA
 first_layer_bed_temperature = 60
 first_layer_temperature = 215
 max_fan_speed = 100
-min_fan_speed = 85
+min_fan_speed = 100
 min_print_speed = 15
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
 temperature = 210
 
@@ -3226,21 +3120,21 @@ filament_colour = #00CA0A
 filament_cost = 0
 filament_density = 0
 filament_diameter = 1.75
-filament_max_volumetric_speed = 2.5
+filament_max_volumetric_speed = 1.5
 filament_notes = "List of materials tested with FLEX print settings & FLEX material settings for MK2:\n\nFillamentum Flex 98A\nFillamentum Flex 92A\nPlasty Mladeč PP\nPlasty Mladeč TPE32 \nPlasty Mladeč TPE88"
 filament_settings_id = 
 filament_soluble = 0
 filament_type = FLEX
 first_layer_bed_temperature = 50
-first_layer_temperature = 220
+first_layer_temperature = 240
 max_fan_speed = 90
 min_fan_speed = 70
 min_print_speed = 5
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
-temperature = 230
+temperature = 240
 
-[filament:Taulman Bridge 1.75mm]
+[filament:Taulman Bridge]
 bed_temperature = 50
 bridge_fan_speed = 40
 compatible_printers = 
@@ -3265,11 +3159,11 @@ first_layer_temperature = 240
 max_fan_speed = 5
 min_fan_speed = 0
 min_print_speed = 5
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
 temperature = 250
 
-[filament:Taulman T-Glase 1.75mm]
+[filament:Taulman T-Glase]
 bed_temperature = 90
 bridge_fan_speed = 40
 compatible_printers = 
@@ -3294,7 +3188,7 @@ first_layer_temperature = 240
 max_fan_speed = 5
 min_fan_speed = 0
 min_print_speed = 5
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
 temperature = 240
 
@@ -3321,9 +3215,9 @@ filament_type = PLA
 first_layer_bed_temperature = 60
 first_layer_temperature = 215
 max_fan_speed = 100
-min_fan_speed = 85
+min_fan_speed = 100
 min_print_speed = 15
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
 temperature = 210
 
@@ -3352,7 +3246,7 @@ first_layer_temperature = 220
 max_fan_speed = 100
 min_fan_speed = 100
 min_print_speed = 15
-slowdown_below_layer_time = 10
+slowdown_below_layer_time = 20
 start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
 temperature = 220
 
@@ -3364,7 +3258,7 @@ deretract_speed = 0
 end_gcode = G4 ; wait\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors
 extruder_colour = #FFFF00
 extruder_offset = 0x0
-gcode_flavor = reprap
+gcode_flavor = marlin
 layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z]
 max_layer_height = 0.25
 min_layer_height = 0.07
@@ -3387,7 +3281,7 @@ retract_speed = 35
 serial_port = 
 serial_speed = 250000
 single_extruder_multi_material = 0
-start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM83  ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0  F1000.0 ; intro line\nG1 X100.0 E12.5  F1000.0 ; intro line\nG92 E0.0
+start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83  ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0  F1000.0 ; intro line\nG1 X100.0 E12.5  F1000.0 ; intro line\nG92 E0.0
 toolchange_gcode = 
 use_firmware_retraction = 0
 use_relative_e_distances = 1
@@ -3404,7 +3298,7 @@ deretract_speed = 0
 end_gcode = G4 ; wait\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors
 extruder_colour = #FFFF00
 extruder_offset = 0x0
-gcode_flavor = reprap
+gcode_flavor = marlin
 layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z]
 max_layer_height = 0.1
 min_layer_height = 0.05
@@ -3427,7 +3321,7 @@ retract_speed = 50
 serial_port = 
 serial_speed = 250000
 single_extruder_multi_material = 0
-start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM83  ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0  F1000.0 ; intro line\nG1 X100.0 E12.5  F1000.0 ; intro line\nG92 E0.0
+start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83  ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0  F1000.0 ; intro line\nG1 X100.0 E12.5  F1000.0 ; intro line\nG92 E0.0
 toolchange_gcode = 
 use_firmware_retraction = 0
 use_relative_e_distances = 1
@@ -3444,7 +3338,7 @@ deretract_speed = 0
 end_gcode = G4 ; wait\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors
 extruder_colour = #FFFF00
 extruder_offset = 0x0
-gcode_flavor = reprap
+gcode_flavor = marlin
 layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z]
 max_layer_height = 0.35
 min_layer_height = 0.1
@@ -3467,7 +3361,7 @@ retract_speed = 35
 serial_port = 
 serial_speed = 250000
 single_extruder_multi_material = 0
-start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM83  ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0  F1000.0 ; intro line\nG1 X100.0 E12.5  F1000.0 ; intro line\nG92 E0.0
+start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83  ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0  F1000.0 ; intro line\nG1 X100.0 E12.5  F1000.0 ; intro line\nG92 E0.0
 toolchange_gcode = 
 use_firmware_retraction = 0
 use_relative_e_distances = 1
@@ -3484,7 +3378,7 @@ deretract_speed = 50
 end_gcode = G1 E-4 F2100.00000\nG91\nG1 Z1 F7200.000\nG90\nG1 X245 Y1\nG1 X240 E4\nG1 F4000\nG1 X190 E2.7  \nG1 F4600\nG1 X110 E2.8\nG1 F5200\nG1 X40 E3  \nG1 E-15.0000 F5000\nG1 E-50.0000 F5400\nG1 E-15.0000 F3000\nG1 E-12.0000 F2000\nG1 F1600\nG1 X0 Y1 E3.0000\nG1 X50 Y1 E-5.0000\nG1 F2000\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-3.0000\nG4 S0\nM107 ; fan off\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nG28 X0  ; home X axis\nM84     ; disable motors\n\n
 extruder_colour = #FFAA55
 extruder_offset = 0x0
-gcode_flavor = reprap
+gcode_flavor = marlin
 layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z]
 max_layer_height = 0.25
 min_layer_height = 0.07
@@ -3494,7 +3388,7 @@ octoprint_host =
 printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN
 printer_settings_id = 
 retract_before_travel = 3
-retract_before_wipe = 0%
+retract_before_wipe = 60%
 retract_layer_change = 0
 retract_length = 4
 retract_length_toolchange = 6
@@ -3507,7 +3401,7 @@ retract_speed = 80
 serial_port = 
 serial_speed = 250000
 single_extruder_multi_material = 1
-start_gcode = M115 U3.1.0 ; tell printer latest fw version\n; Start G-Code sequence START\nT?\nM104 S[first_layer_temperature]\nM140 S[first_layer_bed_temperature]\nM109 S[first_layer_temperature]\nM190 S[first_layer_bed_temperature]\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100\nM92 E140\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0  F1000.0\nG1 X160.0 E20.0  F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\nG92 E0.0
+start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\n; Start G-Code sequence START\nT?\nM104 S[first_layer_temperature]\nM140 S[first_layer_bed_temperature]\nM109 S[first_layer_temperature]\nM190 S[first_layer_bed_temperature]\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100\nM92 E140\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0  F1000.0\nG1 X160.0 E20.0  F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\nG92 E0.0
 toolchange_gcode = 
 use_firmware_retraction = 0
 use_relative_e_distances = 1
@@ -3524,7 +3418,7 @@ deretract_speed = 50
 end_gcode = G1 E-4 F2100.00000\nG91\nG1 Z1 F7200.000\nG90\nG1 X245 Y1\nG1 X240 E4\nG1 F4000\nG1 X190 E2.7  \nG1 F4600\nG1 X110 E2.8\nG1 F5200\nG1 X40 E3  \nG1 E-15.0000 F5000\nG1 E-50.0000 F5400\nG1 E-15.0000 F3000\nG1 E-12.0000 F2000\nG1 F1600\nG1 X0 Y1 E3.0000\nG1 X50 Y1 E-5.0000\nG1 F2000\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-3.0000\nG4 S0\nM107 ; fan off\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nG28 X0  ; home X axis\nM84     ; disable motors\n\n
 extruder_colour = #FFAA55
 extruder_offset = 0x0
-gcode_flavor = reprap
+gcode_flavor = marlin
 layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z]
 max_layer_height = 0.25
 min_layer_height = 0.07
@@ -3534,7 +3428,7 @@ octoprint_host =
 printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN
 printer_settings_id = 
 retract_before_travel = 3
-retract_before_wipe = 0%
+retract_before_wipe = 60%
 retract_layer_change = 0
 retract_length = 4
 retract_length_toolchange = 6
@@ -3547,7 +3441,7 @@ retract_speed = 80
 serial_port = 
 serial_speed = 250000
 single_extruder_multi_material = 1
-start_gcode = M115 U3.1.0 ; tell printer latest fw version\n; Start G-Code sequence START\nT?\nM104 S[first_layer_temperature]\nM140 S[first_layer_bed_temperature]\nM109 S[first_layer_temperature]\nM190 S[first_layer_bed_temperature]\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100\nM92 E140\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0  F1000.0\nG1 X160.0 E20.0  F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\nG92 E0.0
+start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\n; Start G-Code sequence START\nT?\nM104 S[first_layer_temperature]\nM140 S[first_layer_bed_temperature]\nM109 S[first_layer_temperature]\nM190 S[first_layer_bed_temperature]\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100\nM92 E140\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0  F1000.0\nG1 X160.0 E20.0  F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\nG92 E0.0
 toolchange_gcode = 
 use_firmware_retraction = 0
 use_relative_e_distances = 1
@@ -3564,7 +3458,7 @@ deretract_speed = 50,50,50,50
 end_gcode = {if not has_wipe_tower}\n; Pull the filament into the cooling tubes.\nG1 E-4 F2100.00000\nG91\nG1 Z1 F7200.000\nG90\nG1 X245 Y1\nG1 X240 E4\nG1 F4000\nG1 X190 E2.7  \nG1 F4600\nG1 X110 E2.8\nG1 F5200\nG1 X40 E3  \nG1 E-15.0000 F5000\nG1 E-50.0000 F5400\nG1 E-15.0000 F3000\nG1 E-12.0000 F2000\nG1 F1600\nG1 X0 Y1 E3.0000\nG1 X50 Y1 E-5.0000\nG1 F2000\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-3.0000\nG4 S0\n{endif}\nM107 ; fan off\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nG28 X0  ; home X axis\nM84     ; disable motors
 extruder_colour = #FFAA55;#5182DB;#4ECDD3;#FB7259
 extruder_offset = 0x0,0x0,0x0,0x0
-gcode_flavor = reprap
+gcode_flavor = marlin
 layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z]
 max_layer_height = 0.25,0.25,0.25,0.25
 min_layer_height = 0.07,0.07,0.07,0.07
@@ -3587,7 +3481,7 @@ retract_speed = 80,80,80,80
 serial_port = 
 serial_speed = 250000
 single_extruder_multi_material = 1
-start_gcode = M115 U3.1.0 ; tell printer latest fw version\n; Start G-Code sequence START\nT[initial_tool]\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100 ; set max feedrate\nM92 E140 ; E-steps per filament milimeter\n{if not has_wipe_tower}\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0  F1000.0\nG1 X160.0 E20.0  F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\n{endif}\nG92 E0.0
+start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\n; Start G-Code sequence START\nT[initial_tool]\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100 ; set max feedrate\nM92 E140 ; E-steps per filament milimeter\n{if not has_wipe_tower}\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0  F1000.0\nG1 X160.0 E20.0  F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\n{endif}\nG92 E0.0
 toolchange_gcode = 
 use_firmware_retraction = 0
 use_relative_e_distances = 1
@@ -3604,7 +3498,7 @@ deretract_speed = 50,50,50,50
 end_gcode = {if not has_wipe_tower}\nG1 E-4 F2100.00000\nG91\nG1 Z1 F7200.000\nG90\nG1 X245 Y1\nG1 X240 E4\nG1 F4000\nG1 X190 E2.7  \nG1 F4600\nG1 X110 E2.8\nG1 F5200\nG1 X40 E3  \nG1 E-15.0000 F5000\nG1 E-50.0000 F5400\nG1 E-15.0000 F3000\nG1 E-12.0000 F2000\nG1 F1600\nG1 X0 Y1 E3.0000\nG1 X50 Y1 E-5.0000\nG1 F2000\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-3.0000\nG4 S0\n{endif}\nM107 ; fan off\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nG28 X0  ; home X axis\nM84     ; disable motors\n
 extruder_colour = #FFAA55;#5182DB;#4ECDD3;#FB7259
 extruder_offset = 0x0,0x0,0x0,0x0
-gcode_flavor = reprap
+gcode_flavor = marlin
 layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z]
 max_layer_height = 0.25,0.25,0.25,0.25
 min_layer_height = 0.07,0.07,0.07,0.07
@@ -3627,7 +3521,7 @@ retract_speed = 80,80,80,80
 serial_port = 
 serial_speed = 250000
 single_extruder_multi_material = 1
-start_gcode = M115 U3.1.0 ; tell printer latest fw version\n; Start G-Code sequence START\nT[initial_tool]\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100\nM92 E140\n{if not has_wipe_tower}\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0  F1000.0\nG1 X160.0 E20.0  F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\n{endif}\nG92 E0.0
+start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\n; Start G-Code sequence START\nT[initial_tool]\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100\nM92 E140\n{if not has_wipe_tower}\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0  F1000.0\nG1 X160.0 E20.0  F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\n{endif}\nG92 E0.0
 toolchange_gcode = 
 use_firmware_retraction = 0
 use_relative_e_distances = 1
@@ -3641,10 +3535,10 @@ bed_shape = 0x0,250x0,250x210,0x210
 before_layer_gcode = ;BEFORE_LAYER_CHANGE\n;[layer_z]\n\n
 between_objects_gcode = 
 deretract_speed = 0
-end_gcode = G4 ; wait\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors
+end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors
 extruder_colour = #FFFF00
 extruder_offset = 0x0
-gcode_flavor = reprap
+gcode_flavor = marlin
 layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z]
 max_layer_height = 0.25
 min_layer_height = 0.07
@@ -3666,7 +3560,7 @@ retract_speed = 35
 serial_port = 
 serial_speed = 250000
 single_extruder_multi_material = 0
-start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM83  ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0  F1000.0 ; intro line\nG1 X100.0 E12.5  F1000.0 ; intro line\nG92 E0.0
+start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83  ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0  F1000.0 ; intro line\nG1 X100.0 E12.5  F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif}
 toolchange_gcode = 
 use_firmware_retraction = 0
 use_relative_e_distances = 1
@@ -3676,6 +3570,6 @@ wipe = 1
 z_offset = 0
 
 [presets]
-print = 0.15mm 100mms Linear Advance
-printer = Original Prusa i3 MK2
-filament = Prusa PLA 1.75mm
+print = 0.15mm OPTIMAL MK3
+printer = Original Prusa i3 MK3
+filament = Prusa PLA
diff --git a/resources/profiles/Original Prusa i3 MK2MM.ini b/resources/profiles/Original Prusa i3 MK2MM.ini
new file mode 100644
index 000000000..035d15515
--- /dev/null
+++ b/resources/profiles/Original Prusa i3 MK2MM.ini	
@@ -0,0 +1,3419 @@
+# generated by Slic3r Prusa Edition 1.39.0 on 2018-01-06 at 15:12:06
+
+[print:0.05mm DETAIL]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 10
+bridge_acceleration = 300
+bridge_angle = 0
+bridge_flow_ratio = 0.7
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders==1
+complete_objects = 0
+default_acceleration = 500
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 20
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 25%
+fill_pattern = cubic
+first_layer_acceleration = 500
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 20
+gcode_comments = 0
+infill_acceleration = 800
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.5
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 30
+interface_shells = 0
+layer_height = 0.05
+max_print_speed = 80
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 300
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 30
+perimeters = 3
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 15
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 30
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 1
+support_material_extrusion_width = 0.3
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 1.5
+support_material_speed = 30
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.45
+top_solid_infill_speed = 20
+top_solid_layers = 15
+travel_speed = 180
+wipe_tower = 0
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.05mm DETAIL 0.25 nozzle]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 10
+bridge_acceleration = 300
+bridge_angle = 0
+bridge_flow_ratio = 0.7
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.25 and num_extruders==1
+complete_objects = 0
+default_acceleration = 500
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0
+external_perimeter_speed = 20
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.28
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 500
+first_layer_extrusion_width = 0.3
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 20
+gcode_comments = 0
+infill_acceleration = 800
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 20
+interface_shells = 0
+layer_height = 0.05
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 300
+perimeter_extruder = 1
+perimeter_extrusion_width = 0
+perimeter_speed = 20
+perimeters = 4
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 10
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0
+solid_infill_speed = 20
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 1
+support_material_extrusion_width = 0.18
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 0
+support_material_interface_spacing = 0.15
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 1
+support_material_speed = 20
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 150%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0
+top_solid_infill_speed = 20
+top_solid_layers = 15
+travel_speed = 200
+wipe_tower = 0
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.05mm DETAIL MK3]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 10
+bridge_acceleration = 300
+bridge_angle = 0
+bridge_flow_ratio = 0.7
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/
+complete_objects = 0
+default_acceleration = 500
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 20
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 25%
+fill_pattern = grid
+first_layer_acceleration = 500
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 20
+gcode_comments = 0
+infill_acceleration = 800
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 30
+interface_shells = 0
+layer_height = 0.05
+max_print_speed = 80
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 300
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 30
+perimeters = 3
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 15
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 30
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 1
+support_material_extrusion_width = 0.3
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 1.5
+support_material_speed = 30
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 20
+top_solid_layers = 15
+travel_speed = 180
+wipe_tower = 0
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.10mm DETAIL]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 7
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.7
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders==1
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 40
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.1
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 50
+perimeters = 3
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 50
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 1
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.45
+top_solid_infill_speed = 40
+top_solid_layers = 9
+travel_speed = 120
+wipe_tower = 0
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.10mm DETAIL 0.25 nozzle]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 7
+bridge_acceleration = 600
+bridge_angle = 0
+bridge_flow_ratio = 0.7
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.25
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.25
+external_perimeter_speed = 20
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.25
+fill_angle = 45
+fill_density = 15%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.25
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 1600
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.25
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 40
+interface_shells = 0
+layer_height = 0.1
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 600
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.25
+perimeter_speed = 25
+perimeters = 4
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 10
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.25
+solid_infill_speed = 40
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 1
+support_material_extrusion_width = 0.18
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 0
+support_material_interface_spacing = 0.15
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 1
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 150%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.25
+top_solid_infill_speed = 30
+top_solid_layers = 9
+travel_speed = 120
+wipe_tower = 0
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.10mm DETAIL MK3]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 4
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 30
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 35
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = grid
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 3500
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 200
+interface_shells = 0
+layer_height = 0.1
+max_print_speed = 250
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 45
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 200
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 0
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 50
+top_solid_layers = 5
+travel_speed = 250
+wipe_tower = 0
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.15mm 100mms Linear Advance]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 4
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.95
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 50
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 100
+interface_shells = 0
+layer_height = 0.15
+max_print_speed = 150
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 60
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 30
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 100
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 0
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 60
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 70
+top_solid_layers = 5
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.15mm OPTIMAL]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 5
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 40
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.15
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 50
+perimeters = 3
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 50
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 1
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.45
+top_solid_infill_speed = 40
+top_solid_layers = 7
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.15mm OPTIMAL 0.25 nozzle]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 5
+bridge_acceleration = 600
+bridge_angle = 0
+bridge_flow_ratio = 0.7
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.25
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.25
+external_perimeter_speed = 20
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.25
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.25
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 1600
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.25
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 40
+interface_shells = 0
+layer_height = 0.15
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 600
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.25
+perimeter_speed = 25
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 10
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.25
+solid_infill_speed = 40
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 1
+support_material_extrusion_width = 0.2
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 0
+support_material_interface_spacing = 0.15
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 1
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 35
+support_material_with_sheath = 0
+support_material_xy_spacing = 150%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.25
+top_solid_infill_speed = 30
+top_solid_layers = 7
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.15mm OPTIMAL 0.6 nozzle]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 5
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.61
+external_perimeter_speed = 40
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.67
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.65
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.75
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.15
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.65
+perimeter_speed = 50
+perimeters = 3
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.65
+solid_infill_speed = 50
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.6
+top_solid_infill_speed = 40
+top_solid_layers = 7
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.15mm OPTIMAL MK3]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 4
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 30
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 35
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = grid
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 3500
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 200
+interface_shells = 0
+layer_height = 0.15
+max_print_speed = 250
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 45
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 200
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 0
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 50
+top_solid_layers = 5
+travel_speed = 250
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.15mm OPTIMAL SOLUBLE FULL]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 5
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 25
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.15
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = Set your solluble extruder in Multiple Extruders > Support material/raft/skirt extruder &  Support material/raft interface extruder
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 1
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 40
+perimeters = 3
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 0
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 40
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 1
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0
+support_material_enforce_layers = 0
+support_material_extruder = 4
+support_material_extrusion_width = 0.45
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 4
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.1
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 1
+support_material_threshold = 80
+support_material_with_sheath = 1
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.45
+top_solid_infill_speed = 30
+top_solid_layers = 7
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 20
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.15mm OPTIMAL SOLUBLE INTERFACE]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 5
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 25
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.15
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = Set your solluble extruder in Multiple Extruders >  Support material/raft interface extruder
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 1
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 40
+perimeters = 3
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 0
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 40
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 1
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.45
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 4
+support_material_interface_layers = 3
+support_material_interface_spacing = 0.1
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 1
+support_material_threshold = 80
+support_material_with_sheath = 0
+support_material_xy_spacing = 120%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.45
+top_solid_infill_speed = 30
+top_solid_layers = 7
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 20
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.20mm 100mms Linear Advance]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 4
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.95
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 50
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 100
+interface_shells = 0
+layer_height = 0.2
+max_print_speed = 150
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 60
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 30
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 100
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 0
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 60
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 70
+top_solid_layers = 5
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.20mm FAST MK3]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 4
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 30
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 35
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = grid
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 3500
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 200
+interface_shells = 0
+layer_height = 0.2
+max_print_speed = 250
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 45
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 200
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 0
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 50
+top_solid_layers = 5
+travel_speed = 250
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.20mm NORMAL]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 4
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.95
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 40
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.2
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 50
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 50
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 0
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 40
+top_solid_layers = 5
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.20mm NORMAL 0.6 nozzle]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 4
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.61
+external_perimeter_speed = 40
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.67
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.65
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.75
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.2
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.65
+perimeter_speed = 50
+perimeters = 3
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.65
+solid_infill_speed = 50
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.6
+top_solid_infill_speed = 40
+top_solid_layers = 5
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.20mm NORMAL SOLUBLE FULL]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 4
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.95
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 30
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.2
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = Set your solluble extruder in Multiple Extruders > Support material/raft/skirt extruder &  Support material/raft interface extruder
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 1
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 40
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 0
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 40
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 1
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0
+support_material_enforce_layers = 0
+support_material_extruder = 4
+support_material_extrusion_width = 0.45
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 4
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.1
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 1
+support_material_threshold = 80
+support_material_with_sheath = 1
+support_material_xy_spacing = 120%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 30
+top_solid_layers = 5
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 20
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.20mm NORMAL SOLUBLE INTERFACE]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 4
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.95
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 30
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.2
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = Set your solluble extruder in Multiple Extruders >  Support material/raft interface extruder
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 1
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 40
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 0
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 40
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 1
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.45
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 4
+support_material_interface_layers = 3
+support_material_interface_spacing = 0.1
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 1
+support_material_threshold = 80
+support_material_with_sheath = 0
+support_material_xy_spacing = 120%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 30
+top_solid_layers = 5
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 20
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.35mm FAST]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 3
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.95
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.6
+external_perimeter_speed = 40
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.7
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.35
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.43
+perimeter_speed = 50
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.7
+solid_infill_speed = 60
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 1
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.43
+top_solid_infill_speed = 50
+top_solid_layers = 4
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.35mm FAST 0.6 nozzle]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 7
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.61
+external_perimeter_speed = 40
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.67
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.65
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.75
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.35
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.65
+perimeter_speed = 50
+perimeters = 3
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.65
+solid_infill_speed = 60
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.6
+top_solid_infill_speed = 50
+top_solid_layers = 9
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.35mm FAST sol full 0.6 nozzle]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 3
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 and num_extruders>1
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.6
+external_perimeter_speed = 30
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.67
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.65
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.75
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.35
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = Set your solluble extruder in Multiple Extruders >  Support material/raft interface extruder
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 1
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.65
+perimeter_speed = 40
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 0
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.65
+solid_infill_speed = 60
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 1
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0
+support_material_enforce_layers = 0
+support_material_extruder = 4
+support_material_extrusion_width = 0.55
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 4
+support_material_interface_layers = 3
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 1
+support_material_threshold = 80
+support_material_with_sheath = 0
+support_material_xy_spacing = 120%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.57
+top_solid_infill_speed = 50
+top_solid_layers = 4
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 20
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.35mm FAST sol int 0.6 nozzle]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 3
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 and num_extruders>1
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.6
+external_perimeter_speed = 30
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.67
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.65
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.75
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.35
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = Set your solluble extruder in Multiple Extruders >  Support material/raft interface extruder
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 1
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.65
+perimeter_speed = 40
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 0
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.65
+solid_infill_speed = 60
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 1
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.55
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 4
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 1
+support_material_threshold = 80
+support_material_with_sheath = 0
+support_material_xy_spacing = 150%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.57
+top_solid_infill_speed = 50
+top_solid_layers = 4
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 20
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[filament:ColorFabb Brass Bronze]
+bed_temperature = 60
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = nozzle_diameter[0]>0.35
+cooling = 1
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1.3
+fan_always_on = 1
+fan_below_layer_time = 100
+filament_colour = #804040
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 60
+first_layer_temperature = 210
+max_fan_speed = 100
+min_fan_speed = 100
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 210
+
+[filament:ColorFabb HT]
+bed_temperature = 105
+bridge_fan_speed = 30
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 10
+filament_colour = #FF8000
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 105
+first_layer_temperature = 270
+max_fan_speed = 20
+min_fan_speed = 10
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
+temperature = 270
+
+[filament:ColorFabb PLA-PHA]
+bed_temperature = 60
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 100
+filament_colour = #FF3232
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 15
+filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty Mladeč PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 60
+first_layer_temperature = 215
+max_fan_speed = 100
+min_fan_speed = 100
+min_print_speed = 15
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 210
+
+[filament:ColorFabb Woodfil]
+bed_temperature = 60
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = nozzle_diameter[0]>0.35
+cooling = 1
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1.2
+fan_always_on = 1
+fan_below_layer_time = 100
+filament_colour = #804040
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 60
+first_layer_temperature = 200
+max_fan_speed = 100
+min_fan_speed = 100
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 200
+
+[filament:ColorFabb XT]
+bed_temperature = 90
+bridge_fan_speed = 50
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 20
+filament_colour = #FF8000
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 90
+first_layer_temperature = 260
+max_fan_speed = 50
+min_fan_speed = 30
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
+temperature = 270
+
+[filament:ColorFabb XT-CF20]
+bed_temperature = 90
+bridge_fan_speed = 50
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1.2
+fan_always_on = 1
+fan_below_layer_time = 20
+filament_colour = #804040
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 1
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PET
+first_layer_bed_temperature = 90
+first_layer_temperature = 260
+max_fan_speed = 50
+min_fan_speed = 30
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 260
+
+[filament:ColorFabb nGen]
+bed_temperature = 85
+bridge_fan_speed = 40
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 10
+filament_colour = #FF8000
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = NGEN
+first_layer_bed_temperature = 85
+first_layer_temperature = 240
+max_fan_speed = 35
+min_fan_speed = 20
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
+temperature = 240
+
+[filament:ColorFabb nGen flex]
+bed_temperature = 85
+bridge_fan_speed = 40
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 10
+filament_colour = #FF8000
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 5
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = FLEX
+first_layer_bed_temperature = 85
+first_layer_temperature = 260
+max_fan_speed = 35
+min_fan_speed = 20
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 260
+
+[filament:E3D Edge]
+bed_temperature = 90
+bridge_fan_speed = 50
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 20
+filament_colour = #FF8000
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty Mladeč PETG"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PET
+first_layer_bed_temperature = 85
+first_layer_temperature = 230
+max_fan_speed = 50
+min_fan_speed = 30
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
+temperature = 240
+
+[filament:E3D PC-ABS]
+bed_temperature = 100
+bridge_fan_speed = 30
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 20
+filament_colour = #3A80CA
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 13
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 100
+first_layer_temperature = 270
+max_fan_speed = 30
+min_fan_speed = 10
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 270
+
+[filament:Fillamentum ABS]
+bed_temperature = 100
+bridge_fan_speed = 30
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 20
+filament_colour = #3A80CA
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 13
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = ABS
+first_layer_bed_temperature = 100
+first_layer_temperature = 240
+max_fan_speed = 30
+min_fan_speed = 10
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 240
+
+[filament:Fillamentum ASA]
+bed_temperature = 100
+bridge_fan_speed = 30
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 20
+filament_colour = #3A80CA
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 13
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 100
+first_layer_temperature = 265
+max_fan_speed = 30
+min_fan_speed = 10
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 265
+
+[filament:Fillamentum CPE HG100 HM100]
+bed_temperature = 90
+bridge_fan_speed = 50
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 20
+filament_colour = #FF8000
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = "CPE HG100 , CPE HM100"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PET
+first_layer_bed_temperature = 90
+first_layer_temperature = 260
+max_fan_speed = 80
+min_fan_speed = 80
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
+temperature = 260
+
+[filament:Fillamentum Timberfil]
+bed_temperature = 60
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = nozzle_diameter[0]>0.35
+cooling = 1
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1.2
+fan_always_on = 1
+fan_below_layer_time = 100
+filament_colour = #804040
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 60
+first_layer_temperature = 190
+max_fan_speed = 100
+min_fan_speed = 100
+min_print_speed = 15
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 190
+
+[filament:Generic ABS]
+bed_temperature = 100
+bridge_fan_speed = 30
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 20
+filament_colour = #3A80CA
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 13
+filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty Mladeč ABS"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = ABS
+first_layer_bed_temperature = 100
+first_layer_temperature = 255
+max_fan_speed = 30
+min_fan_speed = 10
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 255
+
+[filament:Generic PET]
+bed_temperature = 90
+bridge_fan_speed = 50
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 20
+filament_colour = #FF8000
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty Mladeč PETG"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PET
+first_layer_bed_temperature = 85
+first_layer_temperature = 230
+max_fan_speed = 50
+min_fan_speed = 30
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
+temperature = 240
+
+[filament:Generic PLA]
+bed_temperature = 60
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 100
+filament_colour = #FF3232
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 15
+filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty Mladeč PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 60
+first_layer_temperature = 215
+max_fan_speed = 100
+min_fan_speed = 100
+min_print_speed = 15
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 210
+
+[filament:Polymaker PC-Max]
+bed_temperature = 120
+bridge_fan_speed = 30
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 20
+filament_colour = #3A80CA
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 13
+filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty Mladeč ABS"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = ABS
+first_layer_bed_temperature = 120
+first_layer_temperature = 270
+max_fan_speed = 30
+min_fan_speed = 10
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 270
+
+[filament:Primavalue PVA]
+bed_temperature = 60
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 100
+filament_colour = #FFFFD7
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = "List of materials tested with standart PVA print settings for MK2:\n\nPrimaSelect PVA+\nICE FILAMENTS PVA 'NAUGHTY NATURAL'\nVerbatim BVOH"
+filament_settings_id = 
+filament_soluble = 1
+filament_type = PVA
+first_layer_bed_temperature = 60
+first_layer_temperature = 195
+max_fan_speed = 100
+min_fan_speed = 100
+min_print_speed = 15
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 195
+
+[filament:Prusa ABS]
+bed_temperature = 100
+bridge_fan_speed = 30
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 20
+filament_colour = #3A80CA
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 13
+filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty Mladeč ABS"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = ABS
+first_layer_bed_temperature = 100
+first_layer_temperature = 255
+max_fan_speed = 30
+min_fan_speed = 10
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 255
+
+[filament:Prusa HIPS]
+bed_temperature = 100
+bridge_fan_speed = 50
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 0.9
+fan_always_on = 1
+fan_below_layer_time = 10
+filament_colour = #FFFFD7
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 13
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 1
+filament_type = HIPS
+first_layer_bed_temperature = 100
+first_layer_temperature = 220
+max_fan_speed = 20
+min_fan_speed = 20
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 220
+
+[filament:Prusa PET]
+bed_temperature = 90
+bridge_fan_speed = 50
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 20
+filament_colour = #FF8000
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty Mladeč PETG"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PET
+first_layer_bed_temperature = 85
+first_layer_temperature = 230
+max_fan_speed = 50
+min_fan_speed = 30
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
+temperature = 240
+
+[filament:Prusa PLA]
+bed_temperature = 60
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 100
+filament_colour = #FF3232
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 15
+filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty Mladeč PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 60
+first_layer_temperature = 215
+max_fan_speed = 100
+min_fan_speed = 100
+min_print_speed = 15
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 210
+
+[filament:SemiFlex or Flexfill 98A]
+bed_temperature = 50
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = nozzle_diameter[0]>0.35 and num_extruders==1
+cooling = 0
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1.2
+fan_always_on = 0
+fan_below_layer_time = 100
+filament_colour = #00CA0A
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 2.5
+filament_notes = "List of materials tested with FLEX print settings & FLEX material settings for MK2:\n\nFillamentum Flex 98A\nFillamentum Flex 92A\nPlasty Mladeč PP\nPlasty Mladeč TPE32 \nPlasty Mladeč TPE88"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = FLEX
+first_layer_bed_temperature = 50
+first_layer_temperature = 220
+max_fan_speed = 90
+min_fan_speed = 70
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 230
+
+[filament:Taulman Bridge]
+bed_temperature = 50
+bridge_fan_speed = 40
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 20
+filament_colour = #DEE0E6
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 90
+first_layer_temperature = 240
+max_fan_speed = 5
+min_fan_speed = 0
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 250
+
+[filament:Taulman T-Glase]
+bed_temperature = 90
+bridge_fan_speed = 40
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 20
+filament_colour = #FF8000
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PET
+first_layer_bed_temperature = 90
+first_layer_temperature = 240
+max_fan_speed = 5
+min_fan_speed = 0
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 240
+
+[filament:Verbatim BVOH]
+bed_temperature = 60
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 100
+filament_colour = #FFFFD7
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty Mladeč PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH"
+filament_settings_id = 
+filament_soluble = 1
+filament_type = PLA
+first_layer_bed_temperature = 60
+first_layer_temperature = 215
+max_fan_speed = 100
+min_fan_speed = 100
+min_print_speed = 15
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 210
+
+[filament:Verbatim PP]
+bed_temperature = 100
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 2
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 100
+filament_colour = #DEE0E6
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 5
+filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nEsun PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty Mladeč PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nEUMAKERS PLA"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 100
+first_layer_temperature = 220
+max_fan_speed = 100
+min_fan_speed = 100
+min_print_speed = 15
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 220
+
+[printer:Original Prusa i3 MK2 MM Single Mode]
+bed_shape = 0x0,250x0,250x210,0x210
+before_layer_gcode = ;BEFORE_LAYER_CHANGE\n;[layer_z]\n\n
+between_objects_gcode = 
+deretract_speed = 50
+end_gcode = G1 E-4 F2100.00000\nG91\nG1 Z1 F7200.000\nG90\nG1 X245 Y1\nG1 X240 E4\nG1 F4000\nG1 X190 E2.7  \nG1 F4600\nG1 X110 E2.8\nG1 F5200\nG1 X40 E3  \nG1 E-15.0000 F5000\nG1 E-50.0000 F5400\nG1 E-15.0000 F3000\nG1 E-12.0000 F2000\nG1 F1600\nG1 X0 Y1 E3.0000\nG1 X50 Y1 E-5.0000\nG1 F2000\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-3.0000\nG4 S0\nM107 ; fan off\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nG28 X0  ; home X axis\nM84     ; disable motors\n\n
+extruder_colour = #FFAA55
+extruder_offset = 0x0
+gcode_flavor = marlin
+layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z]
+max_layer_height = 0.25
+min_layer_height = 0.07
+nozzle_diameter = 0.4
+octoprint_apikey = 
+octoprint_host = 
+printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN
+printer_settings_id = 
+retract_before_travel = 3
+retract_before_wipe = 60%
+retract_layer_change = 0
+retract_length = 4
+retract_length_toolchange = 6
+retract_lift = 0.6
+retract_lift_above = 0
+retract_lift_below = 199
+retract_restart_extra = 0
+retract_restart_extra_toolchange = 0
+retract_speed = 80
+serial_port = 
+serial_speed = 250000
+single_extruder_multi_material = 1
+start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\n; Start G-Code sequence START\nT?\nM104 S[first_layer_temperature]\nM140 S[first_layer_bed_temperature]\nM109 S[first_layer_temperature]\nM190 S[first_layer_bed_temperature]\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100\nM92 E140\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0  F1000.0\nG1 X160.0 E20.0  F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\nG92 E0.0
+toolchange_gcode = 
+use_firmware_retraction = 0
+use_relative_e_distances = 1
+use_volumetric_e = 0
+variable_layer_height = 1
+wipe = 1
+z_offset = 0
+
+[printer:Original Prusa i3 MK2 MM Single Mode 0.6 nozzle]
+bed_shape = 0x0,250x0,250x210,0x210
+before_layer_gcode = ;BEFORE_LAYER_CHANGE\n;[layer_z]\n\n
+between_objects_gcode = 
+deretract_speed = 50
+end_gcode = G1 E-4 F2100.00000\nG91\nG1 Z1 F7200.000\nG90\nG1 X245 Y1\nG1 X240 E4\nG1 F4000\nG1 X190 E2.7  \nG1 F4600\nG1 X110 E2.8\nG1 F5200\nG1 X40 E3  \nG1 E-15.0000 F5000\nG1 E-50.0000 F5400\nG1 E-15.0000 F3000\nG1 E-12.0000 F2000\nG1 F1600\nG1 X0 Y1 E3.0000\nG1 X50 Y1 E-5.0000\nG1 F2000\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-3.0000\nG4 S0\nM107 ; fan off\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nG28 X0  ; home X axis\nM84     ; disable motors\n\n
+extruder_colour = #FFAA55
+extruder_offset = 0x0
+gcode_flavor = marlin
+layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z]
+max_layer_height = 0.25
+min_layer_height = 0.07
+nozzle_diameter = 0.6
+octoprint_apikey = 
+octoprint_host = 
+printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN
+printer_settings_id = 
+retract_before_travel = 3
+retract_before_wipe = 60%
+retract_layer_change = 0
+retract_length = 4
+retract_length_toolchange = 6
+retract_lift = 0.6
+retract_lift_above = 0
+retract_lift_below = 199
+retract_restart_extra = 0
+retract_restart_extra_toolchange = 0
+retract_speed = 80
+serial_port = 
+serial_speed = 250000
+single_extruder_multi_material = 1
+start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\n; Start G-Code sequence START\nT?\nM104 S[first_layer_temperature]\nM140 S[first_layer_bed_temperature]\nM109 S[first_layer_temperature]\nM190 S[first_layer_bed_temperature]\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100\nM92 E140\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0  F1000.0\nG1 X160.0 E20.0  F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\nG92 E0.0
+toolchange_gcode = 
+use_firmware_retraction = 0
+use_relative_e_distances = 1
+use_volumetric_e = 0
+variable_layer_height = 1
+wipe = 1
+z_offset = 0
+
+[printer:Original Prusa i3 MK2 MultiMaterial]
+bed_shape = 0x0,250x0,250x210,0x210
+before_layer_gcode = ;BEFORE_LAYER_CHANGE\n;[layer_z]\n\n
+between_objects_gcode = 
+deretract_speed = 50,50,50,50
+end_gcode = {if not has_wipe_tower}\n; Pull the filament into the cooling tubes.\nG1 E-4 F2100.00000\nG91\nG1 Z1 F7200.000\nG90\nG1 X245 Y1\nG1 X240 E4\nG1 F4000\nG1 X190 E2.7  \nG1 F4600\nG1 X110 E2.8\nG1 F5200\nG1 X40 E3  \nG1 E-15.0000 F5000\nG1 E-50.0000 F5400\nG1 E-15.0000 F3000\nG1 E-12.0000 F2000\nG1 F1600\nG1 X0 Y1 E3.0000\nG1 X50 Y1 E-5.0000\nG1 F2000\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-3.0000\nG4 S0\n{endif}\nM107 ; fan off\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nG28 X0  ; home X axis\nM84     ; disable motors
+extruder_colour = #FFAA55;#5182DB;#4ECDD3;#FB7259
+extruder_offset = 0x0,0x0,0x0,0x0
+gcode_flavor = marlin
+layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z]
+max_layer_height = 0.25,0.25,0.25,0.25
+min_layer_height = 0.07,0.07,0.07,0.07
+nozzle_diameter = 0.4,0.4,0.4,0.4
+octoprint_apikey = 
+octoprint_host = 
+printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN
+printer_settings_id = 
+retract_before_travel = 3,3,3,3
+retract_before_wipe = 60%,60%,60%,60%
+retract_layer_change = 0,0,0,0
+retract_length = 4,4,4,4
+retract_length_toolchange = 4,4,4,4
+retract_lift = 0.6,0.6,0.6,0.6
+retract_lift_above = 0,0,0,0
+retract_lift_below = 199,199,199,199
+retract_restart_extra = 0,0,0,0
+retract_restart_extra_toolchange = 0,0,0,0
+retract_speed = 80,80,80,80
+serial_port = 
+serial_speed = 250000
+single_extruder_multi_material = 1
+start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\n; Start G-Code sequence START\nT[initial_tool]\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100 ; set max feedrate\nM92 E140 ; E-steps per filament milimeter\n{if not has_wipe_tower}\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0  F1000.0\nG1 X160.0 E20.0  F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\n{endif}\nG92 E0.0
+toolchange_gcode = 
+use_firmware_retraction = 0
+use_relative_e_distances = 1
+use_volumetric_e = 0
+variable_layer_height = 0
+wipe = 1,1,1,1
+z_offset = 0
+
+[printer:Original Prusa i3 MK2 MultiMaterial 0.6 nozzle]
+bed_shape = 0x0,250x0,250x210,0x210
+before_layer_gcode = ;BEFORE_LAYER_CHANGE\n;[layer_z]\n\n
+between_objects_gcode = 
+deretract_speed = 50,50,50,50
+end_gcode = {if not has_wipe_tower}\nG1 E-4 F2100.00000\nG91\nG1 Z1 F7200.000\nG90\nG1 X245 Y1\nG1 X240 E4\nG1 F4000\nG1 X190 E2.7  \nG1 F4600\nG1 X110 E2.8\nG1 F5200\nG1 X40 E3  \nG1 E-15.0000 F5000\nG1 E-50.0000 F5400\nG1 E-15.0000 F3000\nG1 E-12.0000 F2000\nG1 F1600\nG1 X0 Y1 E3.0000\nG1 X50 Y1 E-5.0000\nG1 F2000\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-5.0000\nG1 F2400\nG1 X0 Y1 E5.0000\nG1 X50 Y1 E-3.0000\nG4 S0\n{endif}\nM107 ; fan off\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nG28 X0  ; home X axis\nM84     ; disable motors\n
+extruder_colour = #FFAA55;#5182DB;#4ECDD3;#FB7259
+extruder_offset = 0x0,0x0,0x0,0x0
+gcode_flavor = marlin
+layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z]
+max_layer_height = 0.25,0.25,0.25,0.25
+min_layer_height = 0.07,0.07,0.07,0.07
+nozzle_diameter = 0.6,0.6,0.6,0.6
+octoprint_apikey = 
+octoprint_host = 
+printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK2\nPRINTER_HAS_BOWDEN
+printer_settings_id = 
+retract_before_travel = 3,3,3,3
+retract_before_wipe = 60%,60%,60%,60%
+retract_layer_change = 0,0,0,0
+retract_length = 4,4,4,4
+retract_length_toolchange = 4,4,4,4
+retract_lift = 0.6,0.6,0.6,0.6
+retract_lift_above = 0,0,0,0
+retract_lift_below = 199,199,199,199
+retract_restart_extra = 0,0,0,0
+retract_restart_extra_toolchange = 0,0,0,0
+retract_speed = 80,80,80,80
+serial_port = 
+serial_speed = 250000
+single_extruder_multi_material = 1
+start_gcode = M115 U3.1.0 ; tell printer latest fw version\nM201 X9000 Y9000 Z500 E10000 ; sets maximum accelerations, mm/sec^2\nM203 X500 Y500 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1500 T1500 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.2 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\n; Start G-Code sequence START\nT[initial_tool]\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG21 ; set units to millimeters\nG90 ; use absolute coordinates\nM83 ; use relative distances for extrusion\nG28 W\nG80\nG92 E0.0\nM203 E100\nM92 E140\n{if not has_wipe_tower}\nG1 Z0.250 F7200.000\nG1 X50.0 E80.0  F1000.0\nG1 X160.0 E20.0  F1000.0\nG1 Z0.200 F7200.000\nG1 X220.0 E13 F1000.0\nG1 X240.0 E0 F1000.0\nG1 E-4 F1000.0\n{endif}\nG92 E0.0
+toolchange_gcode = 
+use_firmware_retraction = 0
+use_relative_e_distances = 1
+use_volumetric_e = 0
+variable_layer_height = 0
+wipe = 1,1,1,1
+z_offset = 0
+
+[presets]
+print = 0.15mm OPTIMAL
+printer = Original Prusa i3 MK2 MultiMaterial
+filament = Prusa PLA
+filament_1 = Prusa PLA
+filament_2 = Prusa PLA
+filament_3 = Prusa PLA
diff --git a/resources/profiles/Original Prusa i3 MK3.ini b/resources/profiles/Original Prusa i3 MK3.ini
new file mode 100644
index 000000000..b53006b0f
--- /dev/null
+++ b/resources/profiles/Original Prusa i3 MK3.ini	
@@ -0,0 +1,3295 @@
+# generated by Slic3r Prusa Edition 1.39.0 on 2018-02-02 at 10:48:46
+
+[print:0.05mm DETAIL]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 10
+bridge_acceleration = 300
+bridge_angle = 0
+bridge_flow_ratio = 0.7
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders==1
+complete_objects = 0
+default_acceleration = 500
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 20
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 25%
+fill_pattern = cubic
+first_layer_acceleration = 500
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 20
+gcode_comments = 0
+infill_acceleration = 800
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.5
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 30
+interface_shells = 0
+layer_height = 0.05
+max_print_speed = 80
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 300
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 30
+perimeters = 3
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 15
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 30
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 1
+support_material_extrusion_width = 0.3
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 1.5
+support_material_speed = 30
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.45
+top_solid_infill_speed = 20
+top_solid_layers = 15
+travel_speed = 180
+wipe_tower = 0
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.05mm DETAIL 0.25 nozzle]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 10
+bridge_acceleration = 300
+bridge_angle = 0
+bridge_flow_ratio = 0.7
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.25 and num_extruders==1
+complete_objects = 0
+default_acceleration = 500
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0
+external_perimeter_speed = 20
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.28
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 500
+first_layer_extrusion_width = 0.3
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 20
+gcode_comments = 0
+infill_acceleration = 800
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 20
+interface_shells = 0
+layer_height = 0.05
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 300
+perimeter_extruder = 1
+perimeter_extrusion_width = 0
+perimeter_speed = 20
+perimeters = 4
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 10
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0
+solid_infill_speed = 20
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 1
+support_material_extrusion_width = 0.18
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 0
+support_material_interface_spacing = 0.15
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 1
+support_material_speed = 20
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 150%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0
+top_solid_infill_speed = 20
+top_solid_layers = 15
+travel_speed = 200
+wipe_tower = 0
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.05mm DETAIL MK3]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 10
+bridge_acceleration = 300
+bridge_angle = 0
+bridge_flow_ratio = 0.7
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/
+complete_objects = 0
+default_acceleration = 500
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 20
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 25%
+fill_pattern = grid
+first_layer_acceleration = 500
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 20
+gcode_comments = 0
+infill_acceleration = 800
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 30
+interface_shells = 0
+layer_height = 0.05
+max_print_speed = 80
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 300
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 30
+perimeters = 3
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 15
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 30
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 1
+support_material_extrusion_width = 0.3
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 1.5
+support_material_speed = 30
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 20
+top_solid_layers = 15
+travel_speed = 180
+wipe_tower = 0
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.10mm DETAIL]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 7
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.7
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders==1
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 40
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.1
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 50
+perimeters = 3
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 50
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 1
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.45
+top_solid_infill_speed = 40
+top_solid_layers = 9
+travel_speed = 120
+wipe_tower = 0
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.10mm DETAIL 0.25 nozzle]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 7
+bridge_acceleration = 600
+bridge_angle = 0
+bridge_flow_ratio = 0.7
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.25
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.25
+external_perimeter_speed = 20
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.25
+fill_angle = 45
+fill_density = 15%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.25
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 1600
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.25
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 40
+interface_shells = 0
+layer_height = 0.1
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 600
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.25
+perimeter_speed = 25
+perimeters = 4
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 10
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.25
+solid_infill_speed = 40
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 1
+support_material_extrusion_width = 0.18
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 0
+support_material_interface_spacing = 0.15
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 1
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 150%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.25
+top_solid_infill_speed = 30
+top_solid_layers = 9
+travel_speed = 120
+wipe_tower = 0
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.10mm DETAIL MK3]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 7
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 30
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 35
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = grid
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 1500
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 170
+interface_shells = 0
+layer_height = 0.1
+max_print_speed = 170
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 45
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 170
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 0
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 50
+top_solid_layers = 9
+travel_speed = 170
+wipe_tower = 0
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.15mm 100mms Linear Advance]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 4
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.95
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 50
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 100
+interface_shells = 0
+layer_height = 0.15
+max_print_speed = 150
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 60
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 30
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 100
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 0
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 60
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 70
+top_solid_layers = 5
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.15mm OPTIMAL]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 5
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 40
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.15
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 50
+perimeters = 3
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 50
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 1
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.45
+top_solid_infill_speed = 40
+top_solid_layers = 7
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.15mm OPTIMAL 0.25 nozzle]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 5
+bridge_acceleration = 600
+bridge_angle = 0
+bridge_flow_ratio = 0.7
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.25
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.25
+external_perimeter_speed = 20
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.25
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.25
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 1600
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.25
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 40
+interface_shells = 0
+layer_height = 0.15
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 600
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.25
+perimeter_speed = 25
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 10
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.25
+solid_infill_speed = 40
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 1
+support_material_extrusion_width = 0.2
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 0
+support_material_interface_spacing = 0.15
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 1
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 35
+support_material_with_sheath = 0
+support_material_xy_spacing = 150%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.25
+top_solid_infill_speed = 30
+top_solid_layers = 7
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.15mm OPTIMAL 0.6 nozzle]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 5
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.61
+external_perimeter_speed = 40
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.67
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.65
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.75
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.15
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.65
+perimeter_speed = 50
+perimeters = 3
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.65
+solid_infill_speed = 50
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.6
+top_solid_infill_speed = 40
+top_solid_layers = 7
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.15mm OPTIMAL MK3]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 5
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 30
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 35
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = grid
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 1500
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 170
+interface_shells = 0
+layer_height = 0.15
+max_print_speed = 170
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 45
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 170
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 0
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 50
+top_solid_layers = 7
+travel_speed = 170
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.15mm OPTIMAL SOLUBLE FULL]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 5
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 25
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.15
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = Set your solluble extruder in Multiple Extruders > Support material/raft/skirt extruder &  Support material/raft interface extruder
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 1
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 40
+perimeters = 3
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 0
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 40
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 1
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0
+support_material_enforce_layers = 0
+support_material_extruder = 4
+support_material_extrusion_width = 0.45
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 4
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.1
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 1
+support_material_threshold = 80
+support_material_with_sheath = 1
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.45
+top_solid_infill_speed = 30
+top_solid_layers = 7
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 20
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.15mm OPTIMAL SOLUBLE INTERFACE]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 5
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 25
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.15
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = Set your solluble extruder in Multiple Extruders >  Support material/raft interface extruder
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 1
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 40
+perimeters = 3
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 0
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 40
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 1
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.45
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 4
+support_material_interface_layers = 3
+support_material_interface_spacing = 0.1
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 1
+support_material_threshold = 80
+support_material_with_sheath = 0
+support_material_xy_spacing = 120%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.45
+top_solid_infill_speed = 30
+top_solid_layers = 7
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 20
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.20mm 100mms Linear Advance]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 4
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.95
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 50
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 100
+interface_shells = 0
+layer_height = 0.2
+max_print_speed = 150
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 60
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 30
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 100
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 0
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 60
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 70
+top_solid_layers = 5
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.20mm FAST MK3]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 4
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 30
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK3.*/
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 35
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = grid
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 1500
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 170
+interface_shells = 0
+layer_height = 0.2
+max_print_speed = 170
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 45
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 170
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 0
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 50
+top_solid_layers = 5
+travel_speed = 170
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.20mm NORMAL]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 4
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.95
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 40
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.2
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 50
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 50
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 0
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 40
+top_solid_layers = 5
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.20mm NORMAL 0.6 nozzle]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 4
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.61
+external_perimeter_speed = 40
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.67
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.65
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.75
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.2
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.65
+perimeter_speed = 50
+perimeters = 3
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.65
+solid_infill_speed = 50
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.6
+top_solid_infill_speed = 40
+top_solid_layers = 5
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.20mm NORMAL SOLUBLE FULL]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 4
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.95
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 30
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.2
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = Set your solluble extruder in Multiple Extruders > Support material/raft/skirt extruder &  Support material/raft interface extruder
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 1
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 40
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 0
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 40
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 1
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0
+support_material_enforce_layers = 0
+support_material_extruder = 4
+support_material_extrusion_width = 0.45
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 4
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.1
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 1
+support_material_threshold = 80
+support_material_with_sheath = 1
+support_material_xy_spacing = 120%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 30
+top_solid_layers = 5
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 20
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.20mm NORMAL SOLUBLE INTERFACE]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 4
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.95
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4 and num_extruders>1
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.45
+external_perimeter_speed = 30
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.45
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.2
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = Set your solluble extruder in Multiple Extruders >  Support material/raft interface extruder
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 1
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.45
+perimeter_speed = 40
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 0
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.45
+solid_infill_speed = 40
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 1
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.45
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 4
+support_material_interface_layers = 3
+support_material_interface_spacing = 0.1
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 1
+support_material_threshold = 80
+support_material_with_sheath = 0
+support_material_xy_spacing = 120%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.4
+top_solid_infill_speed = 30
+top_solid_layers = 5
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 20
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.35mm FAST]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 3
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.95
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.4
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.6
+external_perimeter_speed = 40
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.45
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.42
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.7
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.35
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.43
+perimeter_speed = 50
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.7
+solid_infill_speed = 60
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 1
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.43
+top_solid_infill_speed = 50
+top_solid_layers = 4
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.35mm FAST 0.6 nozzle]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 7
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.61
+external_perimeter_speed = 40
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.67
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.65
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.75
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.35
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = 
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 0
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.65
+perimeter_speed = 50
+perimeters = 3
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 1
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.65
+solid_infill_speed = 60
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 0
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0.15
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.35
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 1
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 0
+support_material_threshold = 45
+support_material_with_sheath = 0
+support_material_xy_spacing = 60%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.6
+top_solid_infill_speed = 50
+top_solid_layers = 9
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 15
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.35mm FAST sol full 0.6 nozzle]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 3
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 and num_extruders>1
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.6
+external_perimeter_speed = 30
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.67
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.65
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.75
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.35
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = Set your solluble extruder in Multiple Extruders >  Support material/raft interface extruder
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 1
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.65
+perimeter_speed = 40
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 0
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.65
+solid_infill_speed = 60
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 1
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0
+support_material_enforce_layers = 0
+support_material_extruder = 4
+support_material_extrusion_width = 0.55
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 4
+support_material_interface_layers = 3
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 1
+support_material_threshold = 80
+support_material_with_sheath = 0
+support_material_xy_spacing = 120%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.57
+top_solid_infill_speed = 50
+top_solid_layers = 4
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 20
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[print:0.35mm FAST sol int 0.6 nozzle]
+avoid_crossing_perimeters = 0
+bottom_solid_layers = 3
+bridge_acceleration = 1000
+bridge_angle = 0
+bridge_flow_ratio = 0.8
+bridge_speed = 20
+brim_width = 0
+clip_multipart_objects = 1
+compatible_printers = 
+compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 and num_extruders>1
+complete_objects = 0
+default_acceleration = 1000
+dont_support_bridges = 1
+elefant_foot_compensation = 0
+ensure_vertical_shell_thickness = 1
+external_fill_pattern = rectilinear
+external_perimeter_extrusion_width = 0.6
+external_perimeter_speed = 30
+external_perimeters_first = 0
+extra_perimeters = 0
+extruder_clearance_height = 20
+extruder_clearance_radius = 20
+extrusion_width = 0.67
+fill_angle = 45
+fill_density = 20%
+fill_pattern = cubic
+first_layer_acceleration = 1000
+first_layer_extrusion_width = 0.65
+first_layer_height = 0.2
+first_layer_speed = 30
+gap_fill_speed = 40
+gcode_comments = 0
+infill_acceleration = 2000
+infill_every_layers = 1
+infill_extruder = 1
+infill_extrusion_width = 0.75
+infill_first = 0
+infill_only_where_needed = 0
+infill_overlap = 25%
+infill_speed = 60
+interface_shells = 0
+layer_height = 0.35
+max_print_speed = 100
+max_volumetric_extrusion_rate_slope_negative = 0
+max_volumetric_extrusion_rate_slope_positive = 0
+max_volumetric_speed = 0
+min_skirt_length = 4
+notes = Set your solluble extruder in Multiple Extruders >  Support material/raft interface extruder
+only_retract_when_crossing_perimeters = 0
+ooze_prevention = 0
+output_filename_format = [input_filename_base].gcode
+overhangs = 1
+perimeter_acceleration = 800
+perimeter_extruder = 1
+perimeter_extrusion_width = 0.65
+perimeter_speed = 40
+perimeters = 2
+post_process = 
+print_settings_id = 
+raft_layers = 0
+resolution = 0
+seam_position = nearest
+skirt_distance = 2
+skirt_height = 3
+skirts = 0
+small_perimeter_speed = 20
+solid_infill_below_area = 0
+solid_infill_every_layers = 0
+solid_infill_extruder = 1
+solid_infill_extrusion_width = 0.65
+solid_infill_speed = 60
+spiral_vase = 0
+standby_temperature_delta = -5
+support_material = 1
+support_material_angle = 0
+support_material_buildplate_only = 0
+support_material_contact_distance = 0
+support_material_enforce_layers = 0
+support_material_extruder = 0
+support_material_extrusion_width = 0.55
+support_material_interface_contact_loops = 0
+support_material_interface_extruder = 4
+support_material_interface_layers = 2
+support_material_interface_spacing = 0.2
+support_material_interface_speed = 100%
+support_material_pattern = rectilinear
+support_material_spacing = 2
+support_material_speed = 50
+support_material_synchronize_layers = 1
+support_material_threshold = 80
+support_material_with_sheath = 0
+support_material_xy_spacing = 150%
+thin_walls = 0
+threads = 4
+top_infill_extrusion_width = 0.57
+top_solid_infill_speed = 50
+top_solid_layers = 4
+travel_speed = 120
+wipe_tower = 1
+wipe_tower_per_color_wipe = 20
+wipe_tower_width = 60
+wipe_tower_x = 180
+wipe_tower_y = 140
+xy_size_compensation = 0
+
+[filament:ColorFabb Brass Bronze]
+bed_temperature = 60
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = nozzle_diameter[0]>0.35
+cooling = 1
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1.3
+fan_always_on = 1
+fan_below_layer_time = 100
+filament_colour = #804040
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 60
+first_layer_temperature = 210
+max_fan_speed = 100
+min_fan_speed = 100
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 210
+
+[filament:ColorFabb HT]
+bed_temperature = 105
+bridge_fan_speed = 30
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 10
+filament_colour = #FF8000
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 105
+first_layer_temperature = 270
+max_fan_speed = 20
+min_fan_speed = 10
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
+temperature = 270
+
+[filament:ColorFabb PLA-PHA]
+bed_temperature = 60
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 100
+filament_colour = #FF3232
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 15
+filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty Mladeč PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 60
+first_layer_temperature = 215
+max_fan_speed = 100
+min_fan_speed = 100
+min_print_speed = 15
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 210
+
+[filament:ColorFabb Woodfil]
+bed_temperature = 60
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = nozzle_diameter[0]>0.35
+cooling = 1
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1.2
+fan_always_on = 1
+fan_below_layer_time = 100
+filament_colour = #804040
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 60
+first_layer_temperature = 200
+max_fan_speed = 100
+min_fan_speed = 100
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 200
+
+[filament:ColorFabb XT]
+bed_temperature = 90
+bridge_fan_speed = 50
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 20
+filament_colour = #FF8000
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 90
+first_layer_temperature = 260
+max_fan_speed = 50
+min_fan_speed = 30
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
+temperature = 270
+
+[filament:ColorFabb XT-CF20]
+bed_temperature = 90
+bridge_fan_speed = 50
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1.2
+fan_always_on = 1
+fan_below_layer_time = 20
+filament_colour = #804040
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 1
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PET
+first_layer_bed_temperature = 90
+first_layer_temperature = 260
+max_fan_speed = 50
+min_fan_speed = 30
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 260
+
+[filament:ColorFabb nGen]
+bed_temperature = 85
+bridge_fan_speed = 40
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 10
+filament_colour = #FF8000
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = NGEN
+first_layer_bed_temperature = 85
+first_layer_temperature = 240
+max_fan_speed = 35
+min_fan_speed = 20
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
+temperature = 240
+
+[filament:ColorFabb nGen flex]
+bed_temperature = 85
+bridge_fan_speed = 40
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 10
+filament_colour = #FF8000
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 5
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = FLEX
+first_layer_bed_temperature = 85
+first_layer_temperature = 260
+max_fan_speed = 35
+min_fan_speed = 20
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 260
+
+[filament:E3D Edge]
+bed_temperature = 90
+bridge_fan_speed = 50
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 20
+filament_colour = #FF8000
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty Mladeč PETG"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PET
+first_layer_bed_temperature = 85
+first_layer_temperature = 230
+max_fan_speed = 50
+min_fan_speed = 30
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
+temperature = 240
+
+[filament:E3D PC-ABS]
+bed_temperature = 100
+bridge_fan_speed = 30
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 20
+filament_colour = #3A80CA
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 13
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 100
+first_layer_temperature = 270
+max_fan_speed = 30
+min_fan_speed = 10
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 270
+
+[filament:Fillamentum ABS]
+bed_temperature = 100
+bridge_fan_speed = 30
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 20
+filament_colour = #3A80CA
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 13
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = ABS
+first_layer_bed_temperature = 100
+first_layer_temperature = 240
+max_fan_speed = 30
+min_fan_speed = 10
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 240
+
+[filament:Fillamentum ASA]
+bed_temperature = 100
+bridge_fan_speed = 30
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 20
+filament_colour = #3A80CA
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 13
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 100
+first_layer_temperature = 265
+max_fan_speed = 30
+min_fan_speed = 10
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 265
+
+[filament:Fillamentum CPE HG100 HM100]
+bed_temperature = 90
+bridge_fan_speed = 50
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 20
+filament_colour = #FF8000
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = "CPE HG100 , CPE HM100"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PET
+first_layer_bed_temperature = 90
+first_layer_temperature = 275
+max_fan_speed = 50
+min_fan_speed = 50
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
+temperature = 275
+
+[filament:Fillamentum Timberfil]
+bed_temperature = 60
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = nozzle_diameter[0]>0.35
+cooling = 1
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1.2
+fan_always_on = 1
+fan_below_layer_time = 100
+filament_colour = #804040
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 60
+first_layer_temperature = 190
+max_fan_speed = 100
+min_fan_speed = 100
+min_print_speed = 15
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 190
+
+[filament:Generic ABS]
+bed_temperature = 100
+bridge_fan_speed = 30
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 20
+filament_colour = #3A80CA
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 13
+filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty Mladeč ABS"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = ABS
+first_layer_bed_temperature = 100
+first_layer_temperature = 255
+max_fan_speed = 30
+min_fan_speed = 10
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 255
+
+[filament:Generic PET]
+bed_temperature = 90
+bridge_fan_speed = 50
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 20
+filament_colour = #FF8000
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty Mladeč PETG"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PET
+first_layer_bed_temperature = 85
+first_layer_temperature = 230
+max_fan_speed = 50
+min_fan_speed = 30
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
+temperature = 240
+
+[filament:Generic PLA]
+bed_temperature = 60
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 100
+filament_colour = #FF3232
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 15
+filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty Mladeč PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 60
+first_layer_temperature = 215
+max_fan_speed = 100
+min_fan_speed = 100
+min_print_speed = 15
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 210
+
+[filament:Polymaker PC-Max]
+bed_temperature = 120
+bridge_fan_speed = 30
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 20
+filament_colour = #3A80CA
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 13
+filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty Mladeč ABS"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = ABS
+first_layer_bed_temperature = 120
+first_layer_temperature = 270
+max_fan_speed = 30
+min_fan_speed = 10
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 270
+
+[filament:Primavalue PVA]
+bed_temperature = 60
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 100
+filament_colour = #FFFFD7
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = "List of materials tested with standart PVA print settings for MK2:\n\nPrimaSelect PVA+\nICE FILAMENTS PVA 'NAUGHTY NATURAL'\nVerbatim BVOH"
+filament_settings_id = 
+filament_soluble = 1
+filament_type = PVA
+first_layer_bed_temperature = 60
+first_layer_temperature = 195
+max_fan_speed = 100
+min_fan_speed = 100
+min_print_speed = 15
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 195
+
+[filament:Prusa ABS]
+bed_temperature = 100
+bridge_fan_speed = 30
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 20
+filament_colour = #3A80CA
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 13
+filament_notes = "List of materials tested with standart ABS print settings for MK2:\n\nEsun ABS\nFil-A-Gehr ABS\nHatchboxABS\nPlasty Mladeč ABS"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = ABS
+first_layer_bed_temperature = 100
+first_layer_temperature = 255
+max_fan_speed = 30
+min_fan_speed = 10
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 255
+
+[filament:Prusa HIPS]
+bed_temperature = 100
+bridge_fan_speed = 50
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 0.9
+fan_always_on = 1
+fan_below_layer_time = 10
+filament_colour = #FFFFD7
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 13
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 1
+filament_type = HIPS
+first_layer_bed_temperature = 100
+first_layer_temperature = 220
+max_fan_speed = 20
+min_fan_speed = 20
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 220
+
+[filament:Prusa PET]
+bed_temperature = 90
+bridge_fan_speed = 50
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 20
+filament_colour = #FF8000
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = "List of manufacturers tested with standart PET print settings for MK2:\n\nE3D Edge\nFillamentum CPE GH100\nPlasty Mladeč PETG"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PET
+first_layer_bed_temperature = 85
+first_layer_temperature = 230
+max_fan_speed = 50
+min_fan_speed = 30
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}45{endif}; Filament gcode"
+temperature = 240
+
+[filament:Prusa PLA]
+bed_temperature = 60
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 100
+filament_colour = #FF3232
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 15
+filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty Mladeč PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 60
+first_layer_temperature = 215
+max_fan_speed = 100
+min_fan_speed = 100
+min_print_speed = 15
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 210
+
+[filament:SemiFlex or Flexfill 98A]
+bed_temperature = 50
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = nozzle_diameter[0]>0.35 and num_extruders==1
+cooling = 0
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1.2
+fan_always_on = 0
+fan_below_layer_time = 100
+filament_colour = #00CA0A
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 1.5
+filament_notes = "List of materials tested with FLEX print settings & FLEX material settings for MK2:\n\nFillamentum Flex 98A\nFillamentum Flex 92A\nPlasty Mladeč PP\nPlasty Mladeč TPE32 \nPlasty Mladeč TPE88"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = FLEX
+first_layer_bed_temperature = 50
+first_layer_temperature = 240
+max_fan_speed = 90
+min_fan_speed = 70
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 240
+
+[filament:Taulman Bridge]
+bed_temperature = 50
+bridge_fan_speed = 40
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 20
+filament_colour = #DEE0E6
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 90
+first_layer_temperature = 240
+max_fan_speed = 5
+min_fan_speed = 0
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 250
+
+[filament:Taulman T-Glase]
+bed_temperature = 90
+bridge_fan_speed = 40
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 3
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 20
+filament_colour = #FF8000
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = ""
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PET
+first_layer_bed_temperature = 90
+first_layer_temperature = 240
+max_fan_speed = 5
+min_fan_speed = 0
+min_print_speed = 5
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}30{endif}; Filament gcode"
+temperature = 240
+
+[filament:Verbatim BVOH]
+bed_temperature = 60
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 0
+disable_fan_first_layers = 1
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 0
+fan_below_layer_time = 100
+filament_colour = #FFFFD7
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 10
+filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nDas Filament\nEsun PLA\nEUMAKERS PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty Mladeč PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nVerbatim PLA\nVerbatim BVOH"
+filament_settings_id = 
+filament_soluble = 1
+filament_type = PLA
+first_layer_bed_temperature = 60
+first_layer_temperature = 215
+max_fan_speed = 100
+min_fan_speed = 100
+min_print_speed = 15
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 210
+
+[filament:Verbatim PP]
+bed_temperature = 100
+bridge_fan_speed = 100
+compatible_printers = 
+compatible_printers_condition = 
+cooling = 1
+disable_fan_first_layers = 2
+end_filament_gcode = "; Filament-specific end gcode"
+extrusion_multiplier = 1
+fan_always_on = 1
+fan_below_layer_time = 100
+filament_colour = #DEE0E6
+filament_cost = 0
+filament_density = 0
+filament_diameter = 1.75
+filament_max_volumetric_speed = 5
+filament_notes = "List of materials tested with standart PLA print settings for MK2:\n\nEsun PLA\nFiberlogy HD-PLA\nFillamentum PLA\nFloreon3D\nHatchbox PLA\nPlasty Mladeč PLA\nPrimavalue PLA\nProto pasta Matte Fiber\nEUMAKERS PLA"
+filament_settings_id = 
+filament_soluble = 0
+filament_type = PLA
+first_layer_bed_temperature = 100
+first_layer_temperature = 220
+max_fan_speed = 100
+min_fan_speed = 100
+min_print_speed = 15
+slowdown_below_layer_time = 20
+start_filament_gcode = "M900 K{if printer_notes=~/.*PRINTER_HAS_BOWDEN.*/}200{else}10{endif}; Filament gcode"
+temperature = 220
+
+[printer:Original Prusa i3 MK3]
+bed_shape = 0x0,250x0,250x210,0x210
+before_layer_gcode = ;BEFORE_LAYER_CHANGE\n;[layer_z]\n\n
+between_objects_gcode = 
+deretract_speed = 0
+end_gcode = G4 ; wait\nM221 S100\nM104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\nG1 X0 Y200; home X axis\nM84 ; disable motors
+extruder_colour = #FFFF00
+extruder_offset = 0x0
+gcode_flavor = marlin
+layer_gcode = ;AFTER_LAYER_CHANGE\n;[layer_z]
+max_layer_height = 0.25
+min_layer_height = 0.07
+nozzle_diameter = 0.4
+octoprint_apikey = 
+octoprint_host = 
+printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_MK3\n
+retract_before_travel = 1
+retract_before_wipe = 0%
+retract_layer_change = 1
+retract_length = 0.8
+retract_length_toolchange = 3
+retract_lift = 0.6
+retract_lift_above = 0
+retract_lift_below = 209
+retract_restart_extra = 0
+retract_restart_extra_toolchange = 0
+retract_speed = 35
+serial_port = 
+serial_speed = 250000
+single_extruder_multi_material = 0
+start_gcode = M115 U3.1.1-RC5 ; tell printer latest fw version\nM201 X1000 Y1000 Z200 E5000 ; sets maximum accelerations, mm/sec^2\nM203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec\nM204 S1250 T1250 ; sets acceleration (S) and retract acceleration (T)\nM205 X10 Y10 Z0.4 E2.5 ; sets the jerk limits, mm/sec\nM205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec\nM83  ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0  F1000.0 ; intro line\nG1 X100.0 E12.5  F1000.0 ; intro line\nG92 E0.0\nM221 S{if layer_height==0.05}100{else}95{endif}
+toolchange_gcode = 
+use_firmware_retraction = 0
+use_relative_e_distances = 1
+use_volumetric_e = 0
+variable_layer_height = 1
+wipe = 1
+z_offset = 0
+
+[presets]
+print = 0.15mm OPTIMAL MK3
+printer = Original Prusa i3 MK3
+filament = Prusa PLA
diff --git a/t/custom_gcode.t b/t/custom_gcode.t
index 5d3602483..bafcd4610 100644
--- a/t/custom_gcode.t
+++ b/t/custom_gcode.t
@@ -1,4 +1,4 @@
-use Test::More tests => 71;
+use Test::More tests => 77;
 use strict;
 use warnings;
 
@@ -87,12 +87,18 @@ use Slic3r::Test;
     is $parser->evaluate_boolean_expression('(12 == 12) and not (13 == 14)'),                1, 'boolean expression parser: (12 == 12) and not (13 == 14)';
     is $parser->evaluate_boolean_expression('(12 == 12) ? (1 - 1 == 0) : (2 * 2 == 3)'),     1, 'boolean expression parser: ternary true';
     is $parser->evaluate_boolean_expression('(12 == 21/2) ? (1 - 1 == 0) : (2 * 2 == 3)'),   0, 'boolean expression parser: ternary false';
-    is $parser->evaluate_boolean_expression('(12 == 13) ? (1 - 1 == 3) : (2 * 2 == 4)"'),    1, 'boolean expression parser: ternary false';
-    is $parser->evaluate_boolean_expression('(12 == 2 * 6) ? (1 - 1 == 3) : (2 * 2 == 4)"'), 0, 'boolean expression parser: ternary true';
+    is $parser->evaluate_boolean_expression('(12 == 13) ? (1 - 1 == 3) : (2 * 2 == 4)'),     1, 'boolean expression parser: ternary false';
+    is $parser->evaluate_boolean_expression('(12 == 2 * 6) ? (1 - 1 == 3) : (2 * 2 == 4)'),  0, 'boolean expression parser: ternary true';
     is $parser->evaluate_boolean_expression('12 < 3'), 0, 'boolean expression parser: lower than - false';
     is $parser->evaluate_boolean_expression('12 < 22'), 1, 'boolean expression parser: lower than - true';
-    is $parser->evaluate_boolean_expression('12 > 3'), 1, 'boolean expression parser: lower than - true';
-    is $parser->evaluate_boolean_expression('12 > 22'), 0, 'boolean expression parser: lower than - false';
+    is $parser->evaluate_boolean_expression('12 > 3'), 1, 'boolean expression parser: greater than - true';
+    is $parser->evaluate_boolean_expression('12 > 22'), 0, 'boolean expression parser: greater than - false';
+    is $parser->evaluate_boolean_expression('12 <= 3'), 0, 'boolean expression parser: lower than or equal- false';
+    is $parser->evaluate_boolean_expression('12 <= 22'), 1, 'boolean expression parser: lower than or equal - true';
+    is $parser->evaluate_boolean_expression('12 >= 3'), 1, 'boolean expression parser: greater than or equal - true';
+    is $parser->evaluate_boolean_expression('12 >= 22'), 0, 'boolean expression parser: greater than or equal - false';
+    is $parser->evaluate_boolean_expression('12 <= 12'), 1, 'boolean expression parser: lower than or equal (same values) - true';
+    is $parser->evaluate_boolean_expression('12 >= 12'), 1, 'boolean expression parser: greater than or equal (same values) - true';
 
     is $parser->evaluate_boolean_expression('printer_notes=~/.*PRINTER_VENDOR_PRUSA3D.*/ and printer_notes=~/.*PRINTER_MODEL_MK2.*/ and nozzle_diameter[0]==0.6 and num_extruders>1'), 1, 'complex expression';
     is $parser->evaluate_boolean_expression('printer_notes=~/.*PRINTER_VEwerfNDOR_PRUSA3D.*/ or printer_notes=~/.*PRINTertER_MODEL_MK2.*/ or (nozzle_diameter[0]==0.6 and num_extruders>1)'), 1, 'complex expression2';
diff --git a/utils/post-processing/flowrate.pl b/utils/post-processing/flowrate.pl
index 7aeef24dc..f29d2312d 100755
--- a/utils/post-processing/flowrate.pl
+++ b/utils/post-processing/flowrate.pl
@@ -25,7 +25,7 @@ while (<>) {
                 my $mm_per_mm   = $e_length / $dist;  # dE/dXY
                 my $mm3_per_mm  = ($filament_diameter[$T] ** 2) * PI/4 * $mm_per_mm;
                 my $vol_speed   = $F/60 * $mm3_per_mm;
-                my $comment = sprintf ' ; dXY = %.3fmm ; dE = %.5fmm ; dE/XY = %.5fmm/mm; volspeed = %.5fmm^3/sec',
+                my $comment = sprintf ' ; dXY = %.3fmm ; dE = %.5fmm ; dE/XY = %.5fmm/mm; volspeed = %.5fmm\x{00B3}/sec',
                     $dist, $e_length, $mm_per_mm, $vol_speed;
                 s/(\R+)/$comment$1/;
             }
diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt
index 2f8eb14c5..41bf9de26 100644
--- a/xs/CMakeLists.txt
+++ b/xs/CMakeLists.txt
@@ -74,6 +74,8 @@ add_library(libslic3r STATIC
     ${LIBDIR}/libslic3r/Fill/FillRectilinear3.hpp
     ${LIBDIR}/libslic3r/Flow.cpp
     ${LIBDIR}/libslic3r/Flow.hpp
+    ${LIBDIR}/libslic3r/Format/3mf.cpp
+    ${LIBDIR}/libslic3r/Format/3mf.hpp
     ${LIBDIR}/libslic3r/Format/AMF.cpp
     ${LIBDIR}/libslic3r/Format/AMF.hpp
     ${LIBDIR}/libslic3r/Format/OBJ.cpp
@@ -90,6 +92,8 @@ add_library(libslic3r STATIC
     ${LIBDIR}/libslic3r/GCode/CoolingBuffer.hpp
     ${LIBDIR}/libslic3r/GCode/PressureEqualizer.cpp
     ${LIBDIR}/libslic3r/GCode/PressureEqualizer.hpp
+    ${LIBDIR}/libslic3r/GCode/PreviewData.cpp
+    ${LIBDIR}/libslic3r/GCode/PreviewData.hpp
     ${LIBDIR}/libslic3r/GCode/PrintExtents.cpp
     ${LIBDIR}/libslic3r/GCode/PrintExtents.hpp
     ${LIBDIR}/libslic3r/GCode/SpiralVase.cpp
@@ -177,6 +181,20 @@ add_library(libslic3r_gui STATIC
     ${LIBDIR}/slic3r/GUI/PresetHints.hpp
     ${LIBDIR}/slic3r/GUI/GUI.cpp
     ${LIBDIR}/slic3r/GUI/GUI.hpp
+    ${LIBDIR}/slic3r/GUI/Tab.cpp
+    ${LIBDIR}/slic3r/GUI/Tab.hpp
+    ${LIBDIR}/slic3r/GUI/TabIface.cpp
+    ${LIBDIR}/slic3r/GUI/TabIface.hpp
+    ${LIBDIR}/slic3r/GUI/Field.cpp
+    ${LIBDIR}/slic3r/GUI/Field.hpp
+    ${LIBDIR}/slic3r/GUI/OptionsGroup.cpp
+    ${LIBDIR}/slic3r/GUI/OptionsGroup.hpp
+    ${LIBDIR}/slic3r/GUI/BedShapeDialog.cpp
+    ${LIBDIR}/slic3r/GUI/BedShapeDialog.hpp
+    ${LIBDIR}/slic3r/GUI/2DBed.cpp
+    ${LIBDIR}/slic3r/GUI/2DBed.hpp
+    ${LIBDIR}/slic3r/GUI/wxExtensions.cpp
+    ${LIBDIR}/slic3r/GUI/wxExtensions.hpp
 )
 
 add_library(admesh STATIC
@@ -189,6 +207,18 @@ add_library(admesh STATIC
     ${LIBDIR}/admesh/util.cpp
 )
 
+add_library(miniz STATIC
+    ${LIBDIR}/miniz/miniz.h
+    ${LIBDIR}/miniz/miniz_common.h
+    ${LIBDIR}/miniz/miniz_tdef.h
+    ${LIBDIR}/miniz/miniz_tinfl.h
+    ${LIBDIR}/miniz/miniz_zip.h
+    ${LIBDIR}/miniz/miniz.cpp
+    ${LIBDIR}/miniz/miniz_tdef.cpp
+    ${LIBDIR}/miniz/miniz_tinfl.cpp
+    ${LIBDIR}/miniz/miniz_zip.cpp
+)
+
 add_library(clipper STATIC 
     ${LIBDIR}/clipper.cpp
     ${LIBDIR}/clipper.hpp
@@ -289,6 +319,7 @@ set(XS_XSP_FILES
     ${XSP_DIR}/GUI_AppConfig.xsp
     ${XSP_DIR}/GUI_3DScene.xsp
     ${XSP_DIR}/GUI_Preset.xsp
+    ${XSP_DIR}/GUI_Tab.xsp
     ${XSP_DIR}/Layer.xsp
     ${XSP_DIR}/Line.xsp
     ${XSP_DIR}/Model.xsp
@@ -348,9 +379,9 @@ if(APPLE)
     # Ignore undefined symbols of the perl interpreter, they will be found in the caller image.
     target_link_libraries(XS "-undefined dynamic_lookup")
 endif()
-target_link_libraries(XS libslic3r libslic3r_gui admesh clipper nowide polypartition poly2tri)
-if(SLIC3R_DEBUG)
-    target_link_libraries(Shiny)
+target_link_libraries(XS libslic3r libslic3r_gui admesh miniz clipper nowide polypartition poly2tri)
+if(SLIC3R_PROFILE)
+    target_link_libraries(XS Shiny)
 endif()
 
 # Add the OpenGL and GLU libraries.
@@ -393,7 +424,7 @@ endif ()
 
 if (SLIC3R_PROFILE)
     message("Slic3r will be built with a Shiny invasive profiler")
-    target_compile_definitions(XS PRIVATE -DSLIC3R_PROFILE)
+    add_definitions(-DSLIC3R_PROFILE)
 endif ()
 
 if (SLIC3R_HAS_BROKEN_CROAK)
@@ -551,8 +582,8 @@ endif()
 # Create a slic3r executable
 add_executable(slic3r ${PROJECT_SOURCE_DIR}/src/slic3r.cpp)
 target_include_directories(XS PRIVATE src src/libslic3r)
-target_link_libraries(slic3r libslic3r libslic3r_gui admesh ${Boost_LIBRARIES} clipper ${EXPAT_LIBRARIES} ${GLEW_LIBRARIES} polypartition poly2tri ${TBB_LIBRARIES} ${wxWidgets_LIBRARIES})
-if(SLIC3R_DEBUG)
+target_link_libraries(slic3r libslic3r libslic3r_gui admesh miniz ${Boost_LIBRARIES} clipper ${EXPAT_LIBRARIES} ${GLEW_LIBRARIES} polypartition poly2tri ${TBB_LIBRARIES} ${wxWidgets_LIBRARIES})
+if(SLIC3R_PROFILE)
     target_link_libraries(Shiny)
 endif()
 if (APPLE)
diff --git a/xs/lib/Slic3r/XS.pm b/xs/lib/Slic3r/XS.pm
index 26c8befe2..47a584343 100644
--- a/xs/lib/Slic3r/XS.pm
+++ b/xs/lib/Slic3r/XS.pm
@@ -283,6 +283,7 @@ for my $class (qw(
         Slic3r::GUI::_3DScene::GLVolume
         Slic3r::GUI::Preset
         Slic3r::GUI::PresetCollection
+        Slic3r::GUI::Tab
         Slic3r::Layer
         Slic3r::Layer::Region
         Slic3r::Layer::Support
diff --git a/xs/src/Shiny/ShinyManager.c b/xs/src/Shiny/ShinyManager.c
index 2cb0df4c2..6b2811851 100644
--- a/xs/src/Shiny/ShinyManager.c
+++ b/xs/src/Shiny/ShinyManager.c
@@ -90,8 +90,8 @@ ShinyNode* _ShinyManager_dummyNodeTable[] = { NULL };
 
 /* primary hash function */
 SHINY_INLINE uint32_t hash_value(void* a_pParent, void* a_pZone) {
-//	uint32_t a = (uint32_t) a_pParent + (uint32_t) a_pZone;
-	uint32_t a = *reinterpret_cast<uint32_t*>(&a_pParent) + *reinterpret_cast<uint32_t*>(&a_pZone);
+	uint32_t a = (uint32_t) a_pParent + (uint32_t) a_pZone;
+//	uint32_t a = *reinterpret_cast<uint32_t*>(&a_pParent) + *reinterpret_cast<uint32_t*>(&a_pZone);
 
 	a = (a+0x7ed55d16) + (a<<12);
 	a = (a^0xc761c23c) ^ (a>>19);
diff --git a/xs/src/admesh/util.cpp b/xs/src/admesh/util.cpp
index b0c31469d..f3bf59b56 100644
--- a/xs/src/admesh/util.cpp
+++ b/xs/src/admesh/util.cpp
@@ -171,12 +171,11 @@ stl_scale(stl_file *stl, float factor) {
 }
 
 static void calculate_normals(stl_file *stl) {
-  long i;
   float normal[3];
 
   if (stl->error) return;
 
-  for(i = 0; i < stl->stats.number_of_facets; i++) {
+  for(uint32_t i = 0; i < stl->stats.number_of_facets; i++) {
     stl_calculate_normal(normal, &stl->facet_start[i]);
     stl_normalize_vector(normal);
     stl->facet_start[i].normal.x = normal[0];
@@ -381,7 +380,6 @@ stl_mirror_xz(stl_file *stl) {
 }
 
 static float get_volume(stl_file *stl) {
-  long i;
   stl_vertex p0;
   stl_vertex p;
   stl_normal n;
@@ -396,7 +394,7 @@ static float get_volume(stl_file *stl) {
   p0.y = stl->facet_start[0].vertex[0].y;
   p0.z = stl->facet_start[0].vertex[0].z;
 
-  for(i = 0; i < stl->stats.number_of_facets; i++) {
+  for(uint32_t i = 0; i < stl->stats.number_of_facets; i++) {
     p.x = stl->facet_start[i].vertex[0].x - p0.x;
     p.y = stl->facet_start[i].vertex[0].y - p0.y;
     p.z = stl->facet_start[i].vertex[0].z - p0.z;
diff --git a/xs/src/clipper.cpp b/xs/src/clipper.cpp
index 5c63a6afe..e865288fb 100644
--- a/xs/src/clipper.cpp
+++ b/xs/src/clipper.cpp
@@ -561,7 +561,7 @@ inline void RangeTest(const IntPoint& Pt, bool& useFullRange)
   if (useFullRange)
   {
     if (Pt.X > hiRange || Pt.Y > hiRange || -Pt.X > hiRange || -Pt.Y > hiRange) 
-      throw "Coordinate outside allowed range";
+      throw clipperException("Coordinate outside allowed range");
   }
   else if (Pt.X > loRange|| Pt.Y > loRange || -Pt.X > loRange || -Pt.Y > loRange) 
   {
@@ -2386,8 +2386,8 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge)
 
 void Clipper::UpdateEdgeIntoAEL(TEdge *&e)
 {
-  if( !e->NextInLML ) throw
-    clipperException("UpdateEdgeIntoAEL: invalid call");
+  if( !e->NextInLML ) 
+    throw clipperException("UpdateEdgeIntoAEL: invalid call");
 
   e->NextInLML->OutIdx = e->OutIdx;
   TEdge* AelPrev = e->PrevInAEL;
diff --git a/xs/src/libslic3r/BoundingBox.cpp b/xs/src/libslic3r/BoundingBox.cpp
index 46a43ca69..91ba88d84 100644
--- a/xs/src/libslic3r/BoundingBox.cpp
+++ b/xs/src/libslic3r/BoundingBox.cpp
@@ -4,38 +4,9 @@
 
 namespace Slic3r {
 
-template <class PointClass>
-BoundingBoxBase<PointClass>::BoundingBoxBase(const std::vector<PointClass> &points)
-{
-    if (points.empty()) 
-        CONFESS("Empty point set supplied to BoundingBoxBase constructor");
-    typename std::vector<PointClass>::const_iterator it = points.begin();
-    this->min.x = this->max.x = it->x;
-    this->min.y = this->max.y = it->y;
-    for (++it; it != points.end(); ++it) {
-        this->min.x = std::min(it->x, this->min.x);
-        this->min.y = std::min(it->y, this->min.y);
-        this->max.x = std::max(it->x, this->max.x);
-        this->max.y = std::max(it->y, this->max.y);
-    }
-    this->defined = true;
-}
 template BoundingBoxBase<Point>::BoundingBoxBase(const std::vector<Point> &points);
 template BoundingBoxBase<Pointf>::BoundingBoxBase(const std::vector<Pointf> &points);
 
-template <class PointClass>
-BoundingBox3Base<PointClass>::BoundingBox3Base(const std::vector<PointClass> &points)
-    : BoundingBoxBase<PointClass>(points)
-{
-    if (points.empty())
-        CONFESS("Empty point set supplied to BoundingBox3Base constructor");
-    typename std::vector<PointClass>::const_iterator it = points.begin();
-    this->min.z = this->max.z = it->z;
-    for (++it; it != points.end(); ++it) {
-        this->min.z = std::min(it->z, this->min.z);
-        this->max.z = std::max(it->z, this->max.z);
-    }
-}
 template BoundingBox3Base<Pointf3>::BoundingBox3Base(const std::vector<Pointf3> &points);
 
 BoundingBox::BoundingBox(const Lines &lines)
diff --git a/xs/src/libslic3r/BoundingBox.hpp b/xs/src/libslic3r/BoundingBox.hpp
index 90179d3f9..a7334308c 100644
--- a/xs/src/libslic3r/BoundingBox.hpp
+++ b/xs/src/libslic3r/BoundingBox.hpp
@@ -23,7 +23,23 @@ public:
     BoundingBoxBase() : defined(false) {};
     BoundingBoxBase(const PointClass &pmin, const PointClass &pmax) : 
         min(pmin), max(pmax), defined(pmin.x < pmax.x && pmin.y < pmax.y) {}
-    BoundingBoxBase(const std::vector<PointClass> &points);
+    BoundingBoxBase(const std::vector<PointClass>& points)
+    {
+        if (points.empty())
+            CONFESS("Empty point set supplied to BoundingBoxBase constructor");
+
+        typename std::vector<PointClass>::const_iterator it = points.begin();
+        this->min.x = this->max.x = it->x;
+        this->min.y = this->max.y = it->y;
+        for (++it; it != points.end(); ++it)
+        {
+            this->min.x = std::min(it->x, this->min.x);
+            this->min.y = std::min(it->y, this->min.y);
+            this->max.x = std::max(it->x, this->max.x);
+            this->max.y = std::max(it->y, this->max.y);
+        }
+        this->defined = (this->min.x < this->max.x) && (this->min.y < this->max.y);
+    }
     void merge(const PointClass &point);
     void merge(const std::vector<PointClass> &points);
     void merge(const BoundingBoxBase<PointClass> &bb);
@@ -54,7 +70,21 @@ public:
     BoundingBox3Base(const PointClass &pmin, const PointClass &pmax) : 
         BoundingBoxBase<PointClass>(pmin, pmax) 
         { if (pmin.z >= pmax.z) BoundingBoxBase<PointClass>::defined = false; }
-    BoundingBox3Base(const std::vector<PointClass> &points);
+    BoundingBox3Base(const std::vector<PointClass>& points)
+        : BoundingBoxBase<PointClass>(points)
+    {
+        if (points.empty())
+            CONFESS("Empty point set supplied to BoundingBox3Base constructor");
+
+        typename std::vector<PointClass>::const_iterator it = points.begin();
+        this->min.z = this->max.z = it->z;
+        for (++it; it != points.end(); ++it)
+        {
+            this->min.z = std::min(it->z, this->min.z);
+            this->max.z = std::max(it->z, this->max.z);
+        }
+        this->defined &= (this->min.z < this->max.z);
+    }
     void merge(const PointClass &point);
     void merge(const std::vector<PointClass> &points);
     void merge(const BoundingBox3Base<PointClass> &bb);
@@ -92,7 +122,7 @@ class BoundingBox3  : public BoundingBox3Base<Point3>
 public:
     BoundingBox3() : BoundingBox3Base<Point3>() {};
     BoundingBox3(const Point3 &pmin, const Point3 &pmax) : BoundingBox3Base<Point3>(pmin, pmax) {};
-    BoundingBox3(const std::vector<Point3> &points) : BoundingBox3Base<Point3>(points) {};
+    BoundingBox3(const Points3& points) : BoundingBox3Base<Point3>(points) {};
 };
 
 class BoundingBoxf : public BoundingBoxBase<Pointf> 
diff --git a/xs/src/libslic3r/Config.cpp b/xs/src/libslic3r/Config.cpp
index 728ed608b..1a0b8fb4a 100644
--- a/xs/src/libslic3r/Config.cpp
+++ b/xs/src/libslic3r/Config.cpp
@@ -18,10 +18,6 @@
 #include <boost/property_tree/ini_parser.hpp>
 #include <string.h>
 
-#if defined(_WIN32) && !defined(setenv) && defined(_putenv_s)
-#define setenv(k, v, o) _putenv_s(k, v)
-#endif
-
 namespace Slic3r {
 
 std::string escape_string_cstyle(const std::string &str)
@@ -309,7 +305,6 @@ double ConfigBase::get_abs_value(const t_config_option_key &opt_key, double rati
 
 void ConfigBase::setenv_()
 {
-#ifdef setenv
     t_config_option_keys opt_keys = this->keys();
     for (t_config_option_keys::const_iterator it = opt_keys.begin(); it != opt_keys.end(); ++it) {
         // prepend the SLIC3R_ prefix
@@ -322,15 +317,14 @@ void ConfigBase::setenv_()
         for (size_t i = 0; i < envname.size(); ++i)
             envname[i] = (envname[i] <= 'z' && envname[i] >= 'a') ? envname[i]-('a'-'A') : envname[i];
         
-        setenv(envname.c_str(), this->serialize(*it).c_str(), 1);
+        boost::nowide::setenv(envname.c_str(), this->serialize(*it).c_str(), 1);
     }
-#endif
 }
 
 void ConfigBase::load(const std::string &file)
 {
     if (boost::iends_with(file, ".gcode") || boost::iends_with(file, ".g"))
-        this->load_from_gcode(file);
+        this->load_from_gcode_file(file);
     else
         this->load_from_ini(file);
 }
@@ -355,10 +349,10 @@ void ConfigBase::load(const boost::property_tree::ptree &tree)
     }
 }
 
-// Load the config keys from the tail of a G-code.
-void ConfigBase::load_from_gcode(const std::string &file)
+// Load the config keys from the tail of a G-code file.
+void ConfigBase::load_from_gcode_file(const std::string &file)
 {
-    // 1) Read a 64k block from the end of the G-code.
+    // Read a 64k block from the end of the G-code.
 	boost::nowide::ifstream ifs(file);
 	{
 		const char slic3r_gcode_header[] = "; generated by Slic3r ";
@@ -371,30 +365,39 @@ void ConfigBase::load_from_gcode(const std::string &file)
 	auto file_length = ifs.tellg();
 	auto data_length = std::min<std::fstream::streampos>(65535, file_length);
 	ifs.seekg(file_length - data_length, ifs.beg);
-	std::vector<char> data(size_t(data_length) + 1, 0);
-	ifs.read(data.data(), data_length);
+    std::vector<char> data(size_t(data_length) + 1, 0);
+    ifs.read(data.data(), data_length);
     ifs.close();
 
-    // 2) Walk line by line in reverse until a non-configuration key appears.
-    char *data_start = data.data();
+    load_from_gcode_string(data.data());
+}
+
+// Load the config keys from the given string.
+void ConfigBase::load_from_gcode_string(const char* str)
+{
+    if (str == nullptr)
+        return;
+
+    // Walk line by line in reverse until a non-configuration key appears.
+    char *data_start = const_cast<char*>(str);
     // boost::nowide::ifstream seems to cook the text data somehow, so less then the 64k of characters may be retrieved.
-	char *end = data_start + strlen(data.data());
+    char *end = data_start + strlen(str);
     size_t num_key_value_pairs = 0;
     for (;;) {
         // Extract next line.
-        for (-- end; end > data_start && (*end == '\r' || *end == '\n'); -- end);
+        for (--end; end > data_start && (*end == '\r' || *end == '\n'); --end);
         if (end == data_start)
             break;
         char *start = end;
-        *(++ end) = 0;
-        for (; start > data_start && *start != '\r' && *start != '\n'; -- start);
+        *(++end) = 0;
+        for (; start > data_start && *start != '\r' && *start != '\n'; --start);
         if (start == data_start)
             break;
         // Extracted a line from start to end. Extract the key = value pair.
-        if (end - (++ start) < 10 || start[0] != ';' || start[1] != ' ')
+        if (end - (++start) < 10 || start[0] != ';' || start[1] != ' ')
             break;
         char *key = start + 2;
-        if (! (*key >= 'a' && *key <= 'z') || (*key >= 'A' && *key <= 'Z'))
+        if (!(*key >= 'a' && *key <= 'z') || (*key >= 'A' && *key <= 'Z'))
             // A key must start with a letter.
             break;
         char *sep = strchr(key, '=');
@@ -408,8 +411,8 @@ void ConfigBase::load_from_gcode(const std::string &file)
             break;
         *key_end = 0;
         // The key may contain letters, digits and underscores.
-        for (char *c = key; c != key_end; ++ c)
-            if (! ((*c >= 'a' && *c <= 'z') || (*c >= 'A' && *c <= 'Z') || (*c >= '0' && *c <= '9') || *c == '_')) {
+        for (char *c = key; c != key_end; ++c)
+            if (!((*c >= 'a' && *c <= 'z') || (*c >= 'A' && *c <= 'Z') || (*c >= '0' && *c <= '9') || *c == '_')) {
                 key = nullptr;
                 break;
             }
@@ -417,8 +420,9 @@ void ConfigBase::load_from_gcode(const std::string &file)
             break;
         try {
             this->set_deserialize(key, value);
-            ++ num_key_value_pairs;
-        } catch (UnknownOptionException & /* e */) {
+            ++num_key_value_pairs;
+        }
+        catch (UnknownOptionException & /* e */) {
             // ignore
         }
         end = start;
diff --git a/xs/src/libslic3r/Config.hpp b/xs/src/libslic3r/Config.hpp
index c203f3be2..3dccedbf0 100644
--- a/xs/src/libslic3r/Config.hpp
+++ b/xs/src/libslic3r/Config.hpp
@@ -582,6 +582,13 @@ public:
     ConfigOptionType            type()  const override { return static_type(); }
     ConfigOption*               clone() const override { return new ConfigOptionFloatOrPercent(*this); }
     ConfigOptionFloatOrPercent& operator=(const ConfigOption *opt) { this->set(opt); return *this; }
+    bool                        operator==(const ConfigOption &rhs) const override
+    {
+        if (rhs.type() != this->type())
+            throw std::runtime_error("ConfigOptionFloatOrPercent: Comparing incompatible types");
+        assert(dynamic_cast<const ConfigOptionFloatOrPercent*>(&rhs));
+        return *this == *static_cast<const ConfigOptionFloatOrPercent*>(&rhs);
+    }
     bool                        operator==(const ConfigOptionFloatOrPercent &rhs) const 
         { return this->value == rhs.value && this->percent == rhs.percent; }
     double                      get_abs_value(double ratio_over) const 
@@ -1049,7 +1056,8 @@ public:
     void setenv_();
     void load(const std::string &file);
     void load_from_ini(const std::string &file);
-    void load_from_gcode(const std::string &file);
+    void load_from_gcode_file(const std::string &file);
+    void load_from_gcode_string(const char* str);
     void load(const boost::property_tree::ptree &tree);
     void save(const std::string &file) const;
 
@@ -1161,6 +1169,8 @@ public:
     const ConfigDef*        def() const override { return nullptr; };
     template<class T> T*    opt(const t_config_option_key &opt_key, bool create = false)
         { return dynamic_cast<T*>(this->option(opt_key, create)); }
+    template<class T> const T* opt(const t_config_option_key &opt_key) const
+        { return dynamic_cast<const T*>(this->option(opt_key)); }
     // Overrides ConfigBase::optptr(). Find ando/or create a ConfigOption instance for a given name.
     ConfigOption*           optptr(const t_config_option_key &opt_key, bool create = false) override;
     // Overrides ConfigBase::keys(). Collect names of all configuration values maintained by this configuration store.
diff --git a/xs/src/libslic3r/ExtrusionEntity.hpp b/xs/src/libslic3r/ExtrusionEntity.hpp
index 6e5b123dc..f5e243419 100644
--- a/xs/src/libslic3r/ExtrusionEntity.hpp
+++ b/xs/src/libslic3r/ExtrusionEntity.hpp
@@ -25,6 +25,7 @@ enum ExtrusionRole {
     erSkirt,
     erSupportMaterial,
     erSupportMaterialInterface,
+    erWipeTower,
     // Extrusion role for a collection with multiple extrusion roles.
     erMixed,
 };
@@ -104,15 +105,19 @@ public:
     float width;
     // Height of the extrusion, used for visualization purposed.
     float height;
-    
-    ExtrusionPath(ExtrusionRole role) : mm3_per_mm(-1), width(-1), height(-1), m_role(role) {};
-    ExtrusionPath(ExtrusionRole role, double mm3_per_mm, float width, float height) : mm3_per_mm(mm3_per_mm), width(width), height(height), m_role(role) {};
-    ExtrusionPath(const ExtrusionPath &rhs) : polyline(rhs.polyline), mm3_per_mm(rhs.mm3_per_mm), width(rhs.width), height(rhs.height), m_role(rhs.m_role) {}
-    ExtrusionPath(ExtrusionPath &&rhs) : polyline(std::move(rhs.polyline)), mm3_per_mm(rhs.mm3_per_mm), width(rhs.width), height(rhs.height), m_role(rhs.m_role) {}
-//    ExtrusionPath(ExtrusionRole role, const Flow &flow) : m_role(role), mm3_per_mm(flow.mm3_per_mm()), width(flow.width), height(flow.height) {};
+    // Feedrate of the extrusion, used for visualization purposed.
+    float feedrate;
+    // Id of the extruder, used for visualization purposed.
+    unsigned int extruder_id;
 
-    ExtrusionPath& operator=(const ExtrusionPath &rhs) { this->m_role = rhs.m_role; this->mm3_per_mm = rhs.mm3_per_mm; this->width = rhs.width; this->height = rhs.height; this->polyline = rhs.polyline; return *this; }
-    ExtrusionPath& operator=(ExtrusionPath &&rhs) { this->m_role = rhs.m_role; this->mm3_per_mm = rhs.mm3_per_mm; this->width = rhs.width; this->height = rhs.height; this->polyline = std::move(rhs.polyline); return *this; }
+    ExtrusionPath(ExtrusionRole role) : mm3_per_mm(-1), width(-1), height(-1), feedrate(0.0f), extruder_id(0), m_role(role) {};
+    ExtrusionPath(ExtrusionRole role, double mm3_per_mm, float width, float height) : mm3_per_mm(mm3_per_mm), width(width), height(height), feedrate(0.0f), extruder_id(0), m_role(role) {};
+    ExtrusionPath(const ExtrusionPath &rhs) : polyline(rhs.polyline), mm3_per_mm(rhs.mm3_per_mm), width(rhs.width), height(rhs.height), feedrate(rhs.feedrate), extruder_id(rhs.extruder_id), m_role(rhs.m_role) {}
+    ExtrusionPath(ExtrusionPath &&rhs) : polyline(std::move(rhs.polyline)), mm3_per_mm(rhs.mm3_per_mm), width(rhs.width), height(rhs.height), feedrate(rhs.feedrate), extruder_id(rhs.extruder_id), m_role(rhs.m_role) {}
+//    ExtrusionPath(ExtrusionRole role, const Flow &flow) : m_role(role), mm3_per_mm(flow.mm3_per_mm()), width(flow.width), height(flow.height), feedrate(0.0f), extruder_id(0) {};
+
+    ExtrusionPath& operator=(const ExtrusionPath &rhs) { this->m_role = rhs.m_role; this->mm3_per_mm = rhs.mm3_per_mm; this->width = rhs.width; this->height = rhs.height; this->feedrate = rhs.feedrate, this->extruder_id = rhs.extruder_id, this->polyline = rhs.polyline; return *this; }
+    ExtrusionPath& operator=(ExtrusionPath &&rhs) { this->m_role = rhs.m_role; this->mm3_per_mm = rhs.mm3_per_mm; this->width = rhs.width; this->height = rhs.height; this->feedrate = rhs.feedrate, this->extruder_id = rhs.extruder_id, this->polyline = std::move(rhs.polyline); return *this; }
 
     ExtrusionPath* clone() const { return new ExtrusionPath (*this); }
     void reverse() { this->polyline.reverse(); }
diff --git a/xs/src/libslic3r/Format/3mf.cpp b/xs/src/libslic3r/Format/3mf.cpp
new file mode 100644
index 000000000..029debf72
--- /dev/null
+++ b/xs/src/libslic3r/Format/3mf.cpp
@@ -0,0 +1,1396 @@
+#include "../libslic3r.h"
+#include "../Model.hpp"
+#include "../Utils.hpp"
+#include "../GCode.hpp"
+#include "../slic3r/GUI/PresetBundle.hpp"
+
+#include "3mf.hpp"
+
+#include <boost/algorithm/string/classification.hpp>
+#include <boost/algorithm/string/split.hpp>
+#include <boost/algorithm/string/predicate.hpp>
+#include <boost/filesystem/operations.hpp>
+#include <boost/nowide/fstream.hpp>
+
+#include <expat.h>
+#include <Eigen/Dense>
+#include <miniz/miniz_zip.h>
+
+const std::string MODEL_FOLDER = "3D/";
+const std::string MODEL_EXTENSION = ".model";
+const std::string MODEL_FILE = "3D/3dmodel.model"; // << this is the only format of the string which works with CURA
+const std::string CONTENT_TYPES_FILE = "[Content_Types].xml";
+const std::string RELATIONSHIPS_FILE = "_rels/.rels";
+const std::string CONFIG_FILE = "Metadata/Slic3r_PE.config";
+
+const char* MODEL_TAG = "model";
+const char* RESOURCES_TAG = "resources";
+const char* OBJECT_TAG = "object";
+const char* MESH_TAG = "mesh";
+const char* VERTICES_TAG = "vertices";
+const char* VERTEX_TAG = "vertex";
+const char* TRIANGLES_TAG = "triangles";
+const char* TRIANGLE_TAG = "triangle";
+const char* COMPONENTS_TAG = "components";
+const char* COMPONENT_TAG = "component";
+const char* BUILD_TAG = "build";
+const char* ITEM_TAG = "item";
+
+const char* UNIT_ATTR = "unit";
+const char* NAME_ATTR = "name";
+const char* TYPE_ATTR = "type";
+const char* ID_ATTR = "id";
+const char* X_ATTR = "x";
+const char* Y_ATTR = "y";
+const char* Z_ATTR = "z";
+const char* V1_ATTR = "v1";
+const char* V2_ATTR = "v2";
+const char* V3_ATTR = "v3";
+const char* OBJECTID_ATTR = "objectid";
+const char* TRANSFORM_ATTR = "transform";
+
+const unsigned int VALID_OBJECT_TYPES_COUNT = 1;
+const char* VALID_OBJECT_TYPES[] =
+{
+    "model"
+};
+
+const unsigned int INVALID_OBJECT_TYPES_COUNT = 4;
+const char* INVALID_OBJECT_TYPES[] =
+{
+    "solidsupport",
+    "support",
+    "surface",
+    "other"
+};
+
+typedef Eigen::Matrix<float, 4, 4, Eigen::RowMajor> Matrix4x4;
+
+const char* get_attribute_value_charptr(const char** attributes, unsigned int attributes_size, const char* attribute_key)
+{
+    if ((attributes == nullptr) || (attributes_size == 0) || (attributes_size % 2 != 0) || (attribute_key == nullptr))
+        return nullptr;
+
+    for (unsigned int a = 0; a < attributes_size; a += 2)
+    {
+        if (::strcmp(attributes[a], attribute_key) == 0)
+            return attributes[a + 1];
+    }
+
+    return nullptr;
+}
+
+std::string get_attribute_value_string(const char** attributes, unsigned int attributes_size, const char* attribute_key)
+{
+    const char* text = get_attribute_value_charptr(attributes, attributes_size, attribute_key);
+    return (text != nullptr) ? text : "";
+}
+
+float get_attribute_value_float(const char** attributes, unsigned int attributes_size, const char* attribute_key)
+{
+    const char* text = get_attribute_value_charptr(attributes, attributes_size, attribute_key);
+    return (text != nullptr) ? (float)::atof(text) : 0.0f;
+}
+
+int get_attribute_value_int(const char** attributes, unsigned int attributes_size, const char* attribute_key)
+{
+    const char* text = get_attribute_value_charptr(attributes, attributes_size, attribute_key);
+    return (text != nullptr) ? ::atoi(text) : 0;
+}
+
+Matrix4x4 get_matrix_from_string(const std::string& mat_str)
+{
+    if (mat_str.empty())
+        // empty string means default identity matrix
+        return Matrix4x4::Identity();
+
+    std::vector<std::string> mat_elements_str;
+    boost::split(mat_elements_str, mat_str, boost::is_any_of(" "), boost::token_compress_on);
+
+    unsigned int size = (unsigned int)mat_elements_str.size();
+    if (size != 12)
+        // invalid data, return identity matrix
+        return Matrix4x4::Identity();
+
+    Matrix4x4 ret = Matrix4x4::Identity();
+    unsigned int i = 0;
+    // matrices are stored into 3mf files as 4x3
+    // we need to transpose them
+    for (unsigned int c = 0; c < 4; ++c)
+    {
+        for (unsigned int r = 0; r < 3; ++r)
+        {
+            ret(r, c) = (float)::atof(mat_elements_str[i++].c_str());
+        }
+    }
+    return ret;
+}
+
+float get_unit_factor(const std::string& unit)
+{
+    const char* text = unit.c_str();
+
+    if (::strcmp(text, "micron") == 0)
+        return 0.001f;
+    else if (::strcmp(text, "centimeter") == 0)
+        return 10.0f;
+    else if (::strcmp(text, "inch") == 0)
+        return 25.4f;
+    else if (::strcmp(text, "foot") == 0)
+        return 304.8f;
+    else if (::strcmp(text, "meter") == 0)
+        return 1000.0f;
+    else
+        // default "millimeters" (see specification)
+        return 1.0f;
+}
+
+bool is_valid_object_type(const std::string& type)
+{
+    // if the type is empty defaults to "model" (see specification)
+    if (type.empty())
+        return true;
+
+    for (unsigned int i = 0; i < VALID_OBJECT_TYPES_COUNT; ++i)
+    {
+        if (::strcmp(type.c_str(), VALID_OBJECT_TYPES[i]) == 0)
+            return true;
+    }
+
+    return false;
+}
+
+namespace Slic3r {
+
+    // Base class with error messages management
+    class _3MF_Base
+    {
+        std::vector<std::string> m_errors;
+
+    protected:
+        void add_error(const std::string& error) { m_errors.push_back(error); }
+        void clear_errors() { m_errors.clear(); }
+
+    public:
+        void log_errors()
+        {
+            for (const std::string& error : m_errors)
+            {
+                printf("%s\n", error.c_str());
+            }
+        }
+    };
+
+    class _3MF_Importer : public _3MF_Base
+    {
+        struct Component
+        {
+            int object_id;
+            Matrix4x4 matrix;
+
+            explicit Component(int object_id);
+            Component(int object_id, const Matrix4x4& matrix);
+        };
+
+        typedef std::vector<Component> ComponentsList;
+
+        struct CurrentObject
+        {
+            struct Geometry
+            {
+                std::vector<float> vertices;
+                std::vector<unsigned int> triangles;
+
+                bool empty();
+                void reset();
+            };
+
+            int id;
+            Geometry geometry;
+            ModelObject* object;
+            TriangleMesh mesh;
+            ComponentsList components;
+
+            CurrentObject();
+
+            void reset();
+        };
+
+        struct Instance
+        {
+            ModelInstance* instance;
+            Matrix4x4 matrix;
+
+            Instance(ModelInstance* instance, const Matrix4x4& matrix);
+        };
+
+        typedef std::map<int, ModelObject*> IdToModelObjectMap;
+        typedef std::map<int, ComponentsList> IdToAliasesMap;
+        typedef std::vector<Instance> InstancesList;
+
+        XML_Parser m_xml_parser;
+        Model* m_model;
+        float m_unit_factor;
+        CurrentObject m_curr_object;
+        IdToModelObjectMap m_objects;
+        IdToAliasesMap m_objects_aliases;
+        InstancesList m_instances;
+
+    public:
+        _3MF_Importer();
+        ~_3MF_Importer();
+
+        bool load_model_from_file(const std::string& filename, Model& model, PresetBundle& bundle);
+
+    private:
+        void _destroy_xml_parser();
+        void _stop_xml_parser();
+
+        bool _load_model_from_file(const std::string& filename, Model& model, PresetBundle& bundle);
+        bool _extract_model_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat);
+        bool _extract_config_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat, PresetBundle& bundle, const std::string& archive_filename);
+
+        void _handle_start_xml_element(const char* name, const char** attributes);
+        void _handle_end_xml_element(const char* name);
+
+        bool _handle_start_model(const char** attributes, unsigned int num_attributes);
+        bool _handle_end_model();
+
+        bool _handle_start_resources(const char** attributes, unsigned int num_attributes);
+        bool _handle_end_resources();
+
+        bool _handle_start_object(const char** attributes, unsigned int num_attributes);
+        bool _handle_end_object();
+
+        bool _handle_start_mesh(const char** attributes, unsigned int num_attributes);
+        bool _handle_end_mesh();
+
+        bool _handle_start_vertices(const char** attributes, unsigned int num_attributes);
+        bool _handle_end_vertices();
+
+        bool _handle_start_vertex(const char** attributes, unsigned int num_attributes);
+        bool _handle_end_vertex();
+
+        bool _handle_start_triangles(const char** attributes, unsigned int num_attributes);
+        bool _handle_end_triangles();
+
+        bool _handle_start_triangle(const char** attributes, unsigned int num_attributes);
+        bool _handle_end_triangle();
+
+        bool _handle_start_components(const char** attributes, unsigned int num_attributes);
+        bool _handle_end_components();
+
+        bool _handle_start_component(const char** attributes, unsigned int num_attributes);
+        bool _handle_end_component();
+
+        bool _handle_start_build(const char** attributes, unsigned int num_attributes);
+        bool _handle_end_build();
+
+        bool _handle_start_item(const char** attributes, unsigned int num_attributes);
+        bool _handle_end_item();
+
+        bool _create_object_instance(int object_id, const Matrix4x4& matrix, unsigned int recur_counter);
+
+        void _apply_transform(ModelObject& object, const Matrix4x4& matrix);
+        void _apply_transform(ModelInstance& instance, const Matrix4x4& matrix);
+
+        static void XMLCALL _handle_start_xml_element(void* userData, const char* name, const char** attributes);
+        static void XMLCALL _handle_end_xml_element(void* userData, const char* name);
+    };
+
+    _3MF_Importer::Component::Component(int object_id)
+        : object_id(object_id)
+        , matrix(Matrix4x4::Identity())
+    {
+    }
+
+    _3MF_Importer::Component::Component(int object_id, const Matrix4x4& matrix)
+        : object_id(object_id)
+        , matrix(matrix)
+    {
+    }
+
+    bool _3MF_Importer::CurrentObject::Geometry::empty()
+    {
+        return vertices.empty() || triangles.empty();
+    }
+
+    void _3MF_Importer::CurrentObject::Geometry::reset()
+    {
+        vertices.clear();
+        triangles.clear();
+    }
+
+    _3MF_Importer::CurrentObject::CurrentObject()
+    {
+        reset();
+    }
+
+    void _3MF_Importer::CurrentObject::reset()
+    {
+        id = -1;
+        geometry.reset();
+        object = nullptr;
+        mesh = TriangleMesh();
+        components.clear();
+    }
+
+    _3MF_Importer::Instance::Instance(ModelInstance* instance, const Matrix4x4& matrix)
+        : instance(instance)
+        , matrix(matrix)
+    {
+    }
+
+    _3MF_Importer::_3MF_Importer()
+        : m_xml_parser(nullptr)
+        , m_model(nullptr)   
+        , m_unit_factor(1.0f)
+    {
+    }
+
+    _3MF_Importer::~_3MF_Importer()
+    {
+        _destroy_xml_parser();
+    }
+
+    bool _3MF_Importer::load_model_from_file(const std::string& filename, Model& model, PresetBundle& bundle)
+    {
+        m_model = &model;
+        m_unit_factor = 1.0f;
+        m_curr_object.reset();
+        m_objects.clear();
+        m_objects_aliases.clear();
+        m_instances.clear();
+        clear_errors();
+
+        return _load_model_from_file(filename, model, bundle);
+    }
+
+    void _3MF_Importer::_destroy_xml_parser()
+    {
+        if (m_xml_parser != nullptr)
+        {
+            XML_ParserFree(m_xml_parser);
+            m_xml_parser = nullptr;
+        }
+    }
+
+    void _3MF_Importer::_stop_xml_parser()
+    {
+        if (m_xml_parser != nullptr)
+            XML_StopParser(m_xml_parser, false);
+    }
+
+    bool _3MF_Importer::_load_model_from_file(const std::string& filename, Model& model, PresetBundle& bundle)
+    {
+        mz_zip_archive archive;
+        mz_zip_zero_struct(&archive);
+       
+        mz_bool res = mz_zip_reader_init_file(&archive, filename.c_str(), 0);
+        if (res == 0)
+        {
+            add_error("Unable to open the file");
+            return false;
+        }
+
+        mz_uint num_entries = mz_zip_reader_get_num_files(&archive);
+
+        mz_zip_archive_file_stat stat;
+        for (mz_uint i = 0; i < num_entries; ++i)
+        {
+            if (mz_zip_reader_file_stat(&archive, i, &stat))
+            {
+                std::string name(stat.m_filename);
+                std::replace(name.begin(), name.end(), '\\', '/');
+
+                if (boost::algorithm::istarts_with(name, MODEL_FOLDER) && boost::algorithm::iends_with(name, MODEL_EXTENSION))
+                {
+                    // valid model name -> extract model
+                    if (!_extract_model_from_archive(archive, stat))
+                    {
+                        mz_zip_reader_end(&archive);
+                        add_error("Archive does not contain a valid model");
+                        return false;
+                    }
+                }
+                else if (boost::algorithm::iequals(name, CONFIG_FILE))
+                {
+                    // extract slic3r config file
+                    if (!_extract_config_from_archive(archive, stat, bundle, filename))
+                    {
+                        mz_zip_reader_end(&archive);
+                        add_error("Archive does not contain a valid config");
+                        return false;
+                    }
+                }
+            }
+        }
+
+        mz_zip_reader_end(&archive);
+        return true;
+    }
+
+    bool _3MF_Importer::_extract_model_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat)
+    {
+        if (stat.m_uncomp_size == 0)
+        {
+            add_error("Found invalid size");
+            return false;
+        }
+
+        _destroy_xml_parser();
+
+        m_xml_parser = XML_ParserCreate(nullptr);
+        if (m_xml_parser == nullptr)
+        {
+            add_error("Unable to create parser");
+            return false;
+        }
+
+        XML_SetUserData(m_xml_parser, (void*)this);
+        XML_SetElementHandler(m_xml_parser, _3MF_Importer::_handle_start_xml_element, _3MF_Importer::_handle_end_xml_element);
+
+        void* parser_buffer = XML_GetBuffer(m_xml_parser, (int)stat.m_uncomp_size);
+        if (parser_buffer == nullptr)
+        {
+            add_error("Unable to create buffer");
+            return false;
+        }
+
+        mz_bool res = mz_zip_reader_extract_file_to_mem(&archive, stat.m_filename, parser_buffer, (size_t)stat.m_uncomp_size, 0);
+        if (res == 0)
+        {
+            add_error("Error while reading model data to buffer");
+            return false;
+        }
+
+        if (!XML_ParseBuffer(m_xml_parser, (int)stat.m_uncomp_size, 1))
+        {
+            char error_buf[1024];
+            ::sprintf(error_buf, "Error (%s) while parsing xml file at line %d", XML_ErrorString(XML_GetErrorCode(m_xml_parser)), XML_GetCurrentLineNumber(m_xml_parser));
+            add_error(error_buf);
+            return false;
+        }
+
+        return true;
+    }
+
+    bool _3MF_Importer::_extract_config_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat, PresetBundle& bundle, const std::string& archive_filename)
+    {
+        if (stat.m_uncomp_size > 0)
+        {
+            std::vector<char> buffer((size_t)stat.m_uncomp_size + 1, 0);
+            mz_bool res = mz_zip_reader_extract_file_to_mem(&archive, stat.m_filename, (void*)buffer.data(), (size_t)stat.m_uncomp_size, 0);
+            if (res == 0)
+            {
+                add_error("Error while reading config data to buffer");
+                return false;
+            }
+
+            buffer.back() = '\0';
+            bundle.load_config_string(buffer.data(), archive_filename.c_str());
+        }
+
+        return true;
+    }
+
+    void _3MF_Importer::_handle_start_xml_element(const char* name, const char** attributes)
+    {
+        if (m_xml_parser == nullptr)
+            return;
+
+        bool res = true;
+        unsigned int num_attributes = (unsigned int)XML_GetSpecifiedAttributeCount(m_xml_parser);
+
+        if (::strcmp(MODEL_TAG, name) == 0)
+            res = _handle_start_model(attributes, num_attributes);
+        else if (::strcmp(RESOURCES_TAG, name) == 0)
+            res = _handle_start_resources(attributes, num_attributes);
+        else if (::strcmp(OBJECT_TAG, name) == 0)
+            res = _handle_start_object(attributes, num_attributes);
+        else if (::strcmp(MESH_TAG, name) == 0)
+            res = _handle_start_mesh(attributes, num_attributes);
+        else if (::strcmp(VERTICES_TAG, name) == 0)
+            res = _handle_start_vertices(attributes, num_attributes);
+        else if (::strcmp(VERTEX_TAG, name) == 0)
+            res = _handle_start_vertex(attributes, num_attributes);
+        else if (::strcmp(TRIANGLES_TAG, name) == 0)
+            res = _handle_start_triangles(attributes, num_attributes);
+        else if (::strcmp(TRIANGLE_TAG, name) == 0)
+            res = _handle_start_triangle(attributes, num_attributes);
+        else if (::strcmp(COMPONENTS_TAG, name) == 0)
+            res = _handle_start_components(attributes, num_attributes);
+        else if (::strcmp(COMPONENT_TAG, name) == 0)
+            res = _handle_start_component(attributes, num_attributes);
+        else if (::strcmp(BUILD_TAG, name) == 0)
+            res = _handle_start_build(attributes, num_attributes);
+        else if (::strcmp(ITEM_TAG, name) == 0)
+            res = _handle_start_item(attributes, num_attributes);
+
+        if (!res)
+            _stop_xml_parser();
+    }
+
+    void _3MF_Importer::_handle_end_xml_element(const char* name)
+    {
+        if (m_xml_parser == nullptr)
+            return;
+
+        bool res = true;
+
+        if (::strcmp(MODEL_TAG, name) == 0)
+            res = _handle_end_model();
+        else if (::strcmp(RESOURCES_TAG, name) == 0)
+            res = _handle_end_resources();
+        else if (::strcmp(OBJECT_TAG, name) == 0)
+            res = _handle_end_object();
+        else if (::strcmp(MESH_TAG, name) == 0)
+            res = _handle_end_mesh();
+        else if (::strcmp(VERTICES_TAG, name) == 0)
+            res = _handle_end_vertices();
+        else if (::strcmp(VERTEX_TAG, name) == 0)
+            res = _handle_end_vertex();
+        else if (::strcmp(TRIANGLES_TAG, name) == 0)
+            res = _handle_end_triangles();
+        else if (::strcmp(TRIANGLE_TAG, name) == 0)
+            res = _handle_end_triangle();
+        else if (::strcmp(COMPONENTS_TAG, name) == 0)
+            res = _handle_end_components();
+        else if (::strcmp(COMPONENT_TAG, name) == 0)
+            res = _handle_end_component();
+        else if (::strcmp(BUILD_TAG, name) == 0)
+            res = _handle_end_build();
+        else if (::strcmp(ITEM_TAG, name) == 0)
+            res = _handle_end_item();
+
+        if (!res)
+            _stop_xml_parser();
+    }
+
+    bool _3MF_Importer::_handle_start_model(const char** attributes, unsigned int num_attributes)
+    {
+        m_unit_factor = get_unit_factor(get_attribute_value_string(attributes, num_attributes, UNIT_ATTR));
+        return true;
+    }
+
+    bool _3MF_Importer::_handle_end_model()
+    {
+        // deletes all non-built or non-instanced objects
+        for (const IdToModelObjectMap::value_type& object : m_objects)
+        {
+            if ((object.second != nullptr) && (object.second->instances.size() == 0))
+                m_model->delete_object(object.second);
+        }
+
+        // applies instances' matrices
+        for (Instance& instance : m_instances)
+        {
+            if (instance.instance != nullptr)
+            {
+                ModelObject* object = instance.instance->get_object();
+                if (object != nullptr)
+                {
+                    if (object->instances.size() == 1)
+                    {
+                        // single instance -> apply the matrix to object geometry
+                        _apply_transform(*object, instance.matrix);
+                    }
+                    else
+                    {
+                        // multiple instances -> apply the matrix to the instance
+                        _apply_transform(*instance.instance, instance.matrix);
+                    }
+                }
+            }
+        }
+
+        return true;
+    }
+
+    bool _3MF_Importer::_handle_start_resources(const char** attributes, unsigned int num_attributes)
+    {
+        // do nothing
+        return true;
+    }
+
+    bool _3MF_Importer::_handle_end_resources()
+    {
+        // do nothing
+        return true;
+    }
+
+    bool _3MF_Importer::_handle_start_object(const char** attributes, unsigned int num_attributes)
+    {
+        // reset current data
+        m_curr_object.reset();
+
+        if (is_valid_object_type(get_attribute_value_string(attributes, num_attributes, TYPE_ATTR)))
+        {
+            // create new object (it may be removed later if no instances are generated from it)
+            m_curr_object.object = m_model->add_object();
+            if (m_curr_object.object == nullptr)
+            {
+                add_error("Unable to create object");
+                return false;
+            }
+
+            // set object data
+            m_curr_object.object->name = get_attribute_value_string(attributes, num_attributes, NAME_ATTR);
+            m_curr_object.id = get_attribute_value_int(attributes, num_attributes, ID_ATTR);
+        }
+
+        return true;
+    }
+
+    bool _3MF_Importer::_handle_end_object()
+    {
+        if (m_curr_object.object != nullptr)
+        {
+            if (m_curr_object.geometry.empty())
+            {
+                // no geometry defined
+                // remove the object from the model
+                m_model->delete_object(m_curr_object.object);
+
+                if (m_curr_object.components.empty())
+                {
+                    // no components defined -> invalid object, delete it
+                    IdToModelObjectMap::iterator object_item = m_objects.find(m_curr_object.id);
+                    if (object_item != m_objects.end())
+                        m_objects.erase(object_item);
+
+                    IdToAliasesMap::iterator alias_item = m_objects_aliases.find(m_curr_object.id);
+                    if (alias_item != m_objects_aliases.end())
+                        m_objects_aliases.erase(alias_item);
+                }
+                else
+                    // adds components to aliases
+                    m_objects_aliases.insert(IdToAliasesMap::value_type(m_curr_object.id, m_curr_object.components));
+            }
+            else
+            {
+                // geometry defined, add it to the object
+
+                ModelVolume* volume = m_curr_object.object->add_volume(m_curr_object.mesh);
+                if (volume == nullptr)
+                {
+                    add_error("Unable to add volume");
+                    return false;
+                }
+
+                stl_file& stl = volume->mesh.stl;
+                stl.stats.type = inmemory;
+                stl.stats.number_of_facets = (uint32_t)m_curr_object.geometry.triangles.size() / 3;
+                stl.stats.original_num_facets = (int)stl.stats.number_of_facets;
+                stl_allocate(&stl);
+                for (size_t i = 0; i < m_curr_object.geometry.triangles.size(); /*nothing*/)
+                {
+                    stl_facet& facet = stl.facet_start[i / 3];
+                    for (unsigned int v = 0; v < 3; ++v)
+                    {
+                        ::memcpy((void*)&facet.vertex[v].x, (const void*)&m_curr_object.geometry.vertices[m_curr_object.geometry.triangles[i++] * 3], 3 * sizeof(float));
+                    }
+                }
+                stl_get_size(&stl);
+                volume->mesh.repair();
+
+                // stores the object for later use
+                if (m_objects.find(m_curr_object.id) == m_objects.end())
+                {
+                    m_objects.insert(IdToModelObjectMap::value_type(m_curr_object.id, m_curr_object.object));
+                    m_objects_aliases.insert(IdToAliasesMap::value_type(m_curr_object.id, ComponentsList(1, Component(m_curr_object.id)))); // aliases itself
+                }
+                else
+                {
+                    add_error("Found object with duplicate id");
+                    return false;
+                }
+            }
+        }
+
+        return true;
+    }
+
+    bool _3MF_Importer::_handle_start_mesh(const char** attributes, unsigned int num_attributes)
+    {
+        // reset current geometry
+        m_curr_object.geometry.reset();
+        return true;
+    }
+
+    bool _3MF_Importer::_handle_end_mesh()
+    {
+        // do nothing
+        return true;
+    }
+
+    bool _3MF_Importer::_handle_start_vertices(const char** attributes, unsigned int num_attributes)
+    {
+        // reset current vertices
+        m_curr_object.geometry.vertices.clear();
+        return true;
+    }
+
+    bool _3MF_Importer::_handle_end_vertices()
+    {
+        // do nothing
+        return true;
+    }
+
+    bool _3MF_Importer::_handle_start_vertex(const char** attributes, unsigned int num_attributes)
+    {
+        // appends the vertex coordinates
+        // missing values are set equal to ZERO
+        m_curr_object.geometry.vertices.push_back(m_unit_factor * get_attribute_value_float(attributes, num_attributes, X_ATTR));
+        m_curr_object.geometry.vertices.push_back(m_unit_factor * get_attribute_value_float(attributes, num_attributes, Y_ATTR));
+        m_curr_object.geometry.vertices.push_back(m_unit_factor * get_attribute_value_float(attributes, num_attributes, Z_ATTR));
+        return true;
+    }
+
+    bool _3MF_Importer::_handle_end_vertex()
+    {
+        // do nothing
+        return true;
+    }
+
+    bool _3MF_Importer::_handle_start_triangles(const char** attributes, unsigned int num_attributes)
+    {
+        // reset current triangles
+        m_curr_object.geometry.triangles.clear();
+        return true;
+    }
+
+    bool _3MF_Importer::_handle_end_triangles()
+    {
+        // do nothing
+        return true;
+    }
+
+    bool _3MF_Importer::_handle_start_triangle(const char** attributes, unsigned int num_attributes)
+    {
+        // we are ignoring the following attributes:
+        // p1
+        // p2
+        // p3
+        // pid
+        // see specifications
+
+        // appends the triangle's vertices indices
+        // missing values are set equal to ZERO
+        m_curr_object.geometry.triangles.push_back((unsigned int)get_attribute_value_int(attributes, num_attributes, V1_ATTR));
+        m_curr_object.geometry.triangles.push_back((unsigned int)get_attribute_value_int(attributes, num_attributes, V2_ATTR));
+        m_curr_object.geometry.triangles.push_back((unsigned int)get_attribute_value_int(attributes, num_attributes, V3_ATTR));
+        return true;
+    }
+
+    bool _3MF_Importer::_handle_end_triangle()
+    {
+        // do nothing
+        return true;
+    }
+
+    bool _3MF_Importer::_handle_start_components(const char** attributes, unsigned int num_attributes)
+    {
+        // reset current components
+        m_curr_object.components.clear();
+        return true;
+    }
+
+    bool _3MF_Importer::_handle_end_components()
+    {
+        // do nothing
+        return true;
+    }
+
+    bool _3MF_Importer::_handle_start_component(const char** attributes, unsigned int num_attributes)
+    {
+        int object_id = get_attribute_value_int(attributes, num_attributes, OBJECTID_ATTR);
+        Matrix4x4 matrix = get_matrix_from_string(get_attribute_value_string(attributes, num_attributes, TRANSFORM_ATTR));
+
+        IdToModelObjectMap::iterator object_item = m_objects.find(object_id);
+        if (object_item == m_objects.end())
+        {
+            IdToAliasesMap::iterator alias_item = m_objects_aliases.find(object_id);
+            if (alias_item == m_objects_aliases.end())
+            {
+                add_error("Found component with invalid object id");
+                return false;
+            }
+        }
+
+        m_curr_object.components.emplace_back(object_id, matrix);
+
+        return true;
+    }
+
+    bool _3MF_Importer::_handle_end_component()
+    {
+        // do nothing
+        return true;
+    }
+
+    bool _3MF_Importer::_handle_start_build(const char** attributes, unsigned int num_attributes)
+    {
+        // do nothing
+        return true;
+    }
+
+    bool _3MF_Importer::_handle_end_build()
+    {
+        // do nothing
+        return true;
+    }
+
+    bool _3MF_Importer::_handle_start_item(const char** attributes, unsigned int num_attributes)
+    {
+        // we are ignoring the following attributes
+        // thumbnail
+        // partnumber
+        // pid
+        // pindex
+        // see specifications
+
+        int object_id = get_attribute_value_int(attributes, num_attributes, OBJECTID_ATTR);
+        Matrix4x4 matrix = get_matrix_from_string(get_attribute_value_string(attributes, num_attributes, TRANSFORM_ATTR));
+
+        return _create_object_instance(object_id, matrix, 1);
+    }
+
+    bool _3MF_Importer::_handle_end_item()
+    {
+        // do nothing
+        return true;
+    }
+
+    bool _3MF_Importer::_create_object_instance(int object_id, const Matrix4x4& matrix, unsigned int recur_counter)
+    {
+        static const unsigned int MAX_RECURSIONS = 10;
+
+        // escape from circular aliasing
+        if (recur_counter > MAX_RECURSIONS)
+        {
+            add_error("Too many recursions");
+            return false;
+        }
+
+        IdToAliasesMap::iterator it = m_objects_aliases.find(object_id);
+        if (it == m_objects_aliases.end())
+        {
+            add_error("Found item with invalid object id");
+            return false;
+        }
+
+        if ((it->second.size() == 1) && (it->second[0].object_id == object_id))
+        {
+            // aliasing to itself
+
+            IdToModelObjectMap::iterator object_item = m_objects.find(object_id);
+            if ((object_item == m_objects.end()) || (object_item->second == nullptr))
+            {
+                add_error("Found invalid object");
+                return false;
+            }
+            else
+            {
+                ModelInstance* instance = object_item->second->add_instance();
+                if (instance == nullptr)
+                {
+                    add_error("Unable to add object instance");
+                    return false;
+                }
+
+                m_instances.emplace_back(instance, matrix);
+            }
+        }
+        else
+        {
+            // recursively process nested components
+            for (const Component& component : it->second)
+            {
+                if (!_create_object_instance(component.object_id, matrix * component.matrix, recur_counter + 1))
+                    return false;
+            }
+        }
+
+        return true;
+    }
+
+    void _3MF_Importer::_apply_transform(ModelObject& object, const Matrix4x4& matrix)
+    {
+        float matrix3x4[12] = { matrix(0, 0), matrix(0, 1), matrix(0, 2), matrix(0, 3),
+                                matrix(1, 0), matrix(1, 1), matrix(1, 2), matrix(1, 3),
+                                matrix(2, 0), matrix(2, 1), matrix(2, 2), matrix(2, 3) };
+
+        object.transform(matrix3x4);
+    }
+
+    void _3MF_Importer::_apply_transform(ModelInstance& instance, const Matrix4x4& matrix)
+    {
+        // slic3r ModelInstance cannot be transformed using a matrix
+        // we extract from the given matrix only the values currently used
+
+        // translation
+        double offset_x = (double)matrix(0, 3);
+        double offset_y = (double)matrix(1, 3);
+        double offset_z = (double)matrix(2, 3);
+
+        // scale
+        double sx = ::sqrt(sqr((double)matrix(0, 0)) + sqr((double)matrix(1, 0)) + sqr((double)matrix(2, 0)));
+        double sy = ::sqrt(sqr((double)matrix(0, 1)) + sqr((double)matrix(1, 1)) + sqr((double)matrix(2, 1)));
+        double sz = ::sqrt(sqr((double)matrix(0, 2)) + sqr((double)matrix(1, 2)) + sqr((double)matrix(2, 2)));
+
+        // invalid scale value, return
+        if ((sx == 0.0) || (sy == 0.0) || (sz == 0.0))
+            return;
+
+        // non-uniform scale value, return
+        if ((std::abs(sx - sy) > 0.00001) || (std::abs(sx - sz) > 0.00001))
+            return;
+
+        // rotations (extracted using quaternion)
+        double inv_sx = 1.0 / sx;
+        double inv_sy = 1.0 / sy;
+        double inv_sz = 1.0 / sz;
+        
+        Eigen::Matrix<double, 3, 3, Eigen::RowMajor> m3x3;
+        m3x3 << (double)matrix(0, 0) * inv_sx, (double)matrix(0, 1) * inv_sy, (double)matrix(0, 2) * inv_sz,
+                (double)matrix(1, 0) * inv_sx, (double)matrix(1, 1) * inv_sy, (double)matrix(1, 2) * inv_sz,
+                (double)matrix(2, 0) * inv_sx, (double)matrix(2, 1) * inv_sy, (double)matrix(2, 2) * inv_sz;
+
+        double qw = 0.5 * ::sqrt(std::max(0.0, 1.0 + m3x3(0, 0) + m3x3(1, 1) + m3x3(2, 2)));
+        double qx = 0.5 * ::sqrt(std::max(0.0, 1.0 + m3x3(0, 0) - m3x3(1, 1) - m3x3(2, 2)));
+        double qy = 0.5 * ::sqrt(std::max(0.0, 1.0 - m3x3(0, 0) + m3x3(1, 1) - m3x3(2, 2)));
+        double qz = 0.5 * ::sqrt(std::max(0.0, 1.0 - m3x3(0, 0) - m3x3(1, 1) + m3x3(2, 2)));
+
+        double q_magnitude = ::sqrt(sqr(qw) + sqr(qx) + sqr(qy) + sqr(qz));
+
+        // invalid length, return
+        if (q_magnitude == 0.0)
+            return;
+
+        double inv_q_magnitude = 1.0 / q_magnitude;
+
+        qw *= inv_q_magnitude;
+        qx *= inv_q_magnitude;
+        qy *= inv_q_magnitude;
+        qz *= inv_q_magnitude;
+
+        double test = qx * qy + qz * qw;
+        double angle_x, angle_y, angle_z;
+
+        if (test > 0.499)
+        {
+            // singularity at north pole
+            angle_x = 0.0;
+            angle_y = 2.0 * ::atan2(qx, qw);
+            angle_z = 0.5 * PI;
+        }
+        else if (test < -0.499)
+        {
+            // singularity at south pole
+            angle_x = 0.0;
+            angle_y = -2.0 * ::atan2(qx, qw);
+            angle_z = -0.5 * PI;
+        }
+        else
+        {
+            angle_x = ::atan2(2.0 * qx * qw - 2.0 * qy * qz, 1.0 - 2.0 * sqr(qx) - 2.0 * sqr(qz));
+            angle_y = ::atan2(2.0 * qy * qw - 2.0 * qx * qz, 1.0 - 2.0 * sqr(qy) - 2.0 * sqr(qz));
+            angle_z = ::asin(2.0 * qx * qy + 2.0 * qz * qw);
+
+            if (angle_x < 0.0)
+                angle_x += 2.0 * PI;
+
+            if (angle_y < 0.0)
+                angle_y += 2.0 * PI;
+
+            if (angle_z < 0.0)
+                angle_z += 2.0 * PI;
+        }
+
+        instance.offset.x = offset_x;
+        instance.offset.y = offset_y;
+        instance.scaling_factor = sx;
+        instance.rotation = angle_z;
+    }
+
+    void XMLCALL _3MF_Importer::_handle_start_xml_element(void* userData, const char* name, const char** attributes)
+    {
+        _3MF_Importer* importer = (_3MF_Importer*)userData;
+        if (importer != nullptr)
+            importer->_handle_start_xml_element(name, attributes);
+    }
+
+    void XMLCALL _3MF_Importer::_handle_end_xml_element(void* userData, const char* name)
+    {
+        _3MF_Importer* importer = (_3MF_Importer*)userData;
+        if (importer != nullptr)
+            importer->_handle_end_xml_element(name);
+    }
+
+    class _3MF_Exporter : public _3MF_Base
+    {
+        struct BuildItem
+        {
+            unsigned int id;
+            Matrix4x4 matrix;
+
+            BuildItem(unsigned int id, const Matrix4x4& matrix);
+        };
+
+        typedef std::vector<BuildItem> BuildItemsList;
+
+    public:
+        bool save_model_to_file(const std::string& filename, Model& model, const Print& print);
+
+    private:
+        bool _save_model_to_file(const std::string& filename, Model& model, const Print& print);
+        bool _add_content_types_file_to_archive(mz_zip_archive& archive);
+        bool _add_relationships_file_to_archive(mz_zip_archive& archive);
+        bool _add_model_file_to_archive(mz_zip_archive& archive, Model& model);
+        bool _add_object_to_model_stream(std::stringstream& stream, unsigned int& object_id, ModelObject& object, BuildItemsList& build_items);
+        bool _add_mesh_to_object_stream(std::stringstream& stream, ModelObject& object);
+        bool _add_build_to_model_stream(std::stringstream& stream, const BuildItemsList& build_items);
+        bool _add_config_file_to_archive(mz_zip_archive& archive, const Print& print);
+    };
+
+    _3MF_Exporter::BuildItem::BuildItem(unsigned int id, const Matrix4x4& matrix)
+        : id(id)
+        , matrix(matrix)
+    {
+    }
+
+    bool _3MF_Exporter::save_model_to_file(const std::string& filename, Model& model, const Print& print)
+    {
+        clear_errors();
+        return _save_model_to_file(filename, model, print);
+    }
+
+    bool _3MF_Exporter::_save_model_to_file(const std::string& filename, Model& model, const Print& print)
+    {
+        mz_zip_archive archive;
+        mz_zip_zero_struct(&archive);
+
+        mz_bool res = mz_zip_writer_init_file(&archive, filename.c_str(), 0);
+        if (res == 0)
+        {
+            add_error("Unable to open the file");
+            return false;
+        }
+
+        // adds content types file
+        if (!_add_content_types_file_to_archive(archive))
+        {
+            mz_zip_writer_end(&archive);
+            boost::filesystem::remove(filename);
+            return false;
+        }
+
+        // adds relationships file
+        if (!_add_relationships_file_to_archive(archive))
+        {
+            mz_zip_writer_end(&archive);
+            boost::filesystem::remove(filename);
+            return false;
+        }
+
+        // adds model file
+        if (!_add_model_file_to_archive(archive, model))
+        {
+            mz_zip_writer_end(&archive);
+            boost::filesystem::remove(filename);
+            return false;
+        }
+
+        // adds slic3r config file
+        if (!_add_config_file_to_archive(archive, print))
+        {
+            mz_zip_writer_end(&archive);
+            boost::filesystem::remove(filename);
+            return false;
+        }
+
+        if (!mz_zip_writer_finalize_archive(&archive))
+        {
+            mz_zip_writer_end(&archive);
+            boost::filesystem::remove(filename);
+            add_error("Unable to finalize the archive");
+            return false;
+        }
+
+        mz_zip_writer_end(&archive);
+
+        return true;
+    }
+
+    bool _3MF_Exporter::_add_content_types_file_to_archive(mz_zip_archive& archive)
+    {
+        std::stringstream stream;
+        stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+        stream << "<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">\n";
+        stream << " <Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\" />\n";
+        stream << " <Default Extension=\"model\" ContentType=\"application/vnd.ms-package.3dmanufacturing-3dmodel+xml\" />\n";
+        stream << "</Types>";
+
+        std::string out = stream.str();
+
+        if (!mz_zip_writer_add_mem(&archive, CONTENT_TYPES_FILE.c_str(), (const void*)out.data(), out.length(), MZ_DEFAULT_COMPRESSION))
+        {
+            add_error("Unable to add content types file to archive");
+            return false;
+        }
+
+        return true;
+    }
+
+    bool _3MF_Exporter::_add_relationships_file_to_archive(mz_zip_archive& archive)
+    {
+        std::stringstream stream;
+        stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+        stream << "<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">\n";
+        stream << " <Relationship Target=\"/" << MODEL_FILE << "\" Id=\"rel-1\" Type=\"http://schemas.microsoft.com/3dmanufacturing/2013/01/3dmodel\" />\n";
+        stream << "</Relationships>";
+
+        std::string out = stream.str();
+
+        if (!mz_zip_writer_add_mem(&archive, RELATIONSHIPS_FILE.c_str(), (const void*)out.data(), out.length(), MZ_DEFAULT_COMPRESSION))
+        {
+            add_error("Unable to add relationships file to archive");
+            return false;
+        }
+
+        return true;
+    }
+
+    bool _3MF_Exporter::_add_model_file_to_archive(mz_zip_archive& archive, Model& model)
+    {
+        std::stringstream stream;
+        stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+        stream << "<model unit=\"millimeter\" xml:lang=\"en-US\" xmlns=\"http://schemas.microsoft.com/3dmanufacturing/core/2015/02\">\n";
+        stream << " <resources>\n";
+
+        BuildItemsList build_items;
+
+        unsigned int object_id = 1;
+        for (ModelObject* obj : model.objects)
+        {
+            if (obj == nullptr)
+                continue;
+
+            if (!_add_object_to_model_stream(stream, object_id, *obj, build_items))
+            {
+                add_error("Unable to add object to archive");
+                return false;
+            }
+        }
+
+
+        stream << " </resources>\n";
+
+        if (!_add_build_to_model_stream(stream, build_items))
+        {
+            add_error("Unable to add build to archive");
+            return false;
+        }
+
+        stream << "</model>\n";
+
+        std::string out = stream.str();
+
+        if (!mz_zip_writer_add_mem(&archive, MODEL_FILE.c_str(), (const void*)out.data(), out.length(), MZ_DEFAULT_COMPRESSION))
+        {
+            add_error("Unable to add model file to archive");
+            return false;
+        }
+
+        return true;
+    }
+
+    bool _3MF_Exporter::_add_object_to_model_stream(std::stringstream& stream, unsigned int& object_id, ModelObject& object, BuildItemsList& build_items)
+    {
+        unsigned int id = 0;
+        for (const ModelInstance* instance : object.instances)
+        {
+            if (instance == nullptr)
+                continue;
+
+            unsigned int instance_id = object_id + id;
+            stream << "  <object id=\"" << instance_id << "\" type=\"model\">\n";
+
+            if (id == 0)
+            {
+                if (!_add_mesh_to_object_stream(stream, object))
+                {
+                    add_error("Unable to add mesh to archive");
+                    return false;
+                }
+            }
+            else
+            {
+                stream << "   <components>\n";
+                stream << "    <component objectid=\"" << object_id << "\" />\n";
+                stream << "   </components>\n";
+            }
+
+            Eigen::Affine3f transform;
+            transform = Eigen::Translation3f((float)(instance->offset.x + object.origin_translation.x), (float)(instance->offset.y + object.origin_translation.y), (float)object.origin_translation.z)
+                        * Eigen::AngleAxisf((float)instance->rotation, Eigen::Vector3f::UnitZ())
+                        * Eigen::Scaling((float)instance->scaling_factor);
+            build_items.emplace_back(instance_id, transform.matrix());
+
+            stream << "  </object>\n";
+
+            ++id;
+        }
+
+        object_id += id;
+        return true;
+    }
+
+    bool _3MF_Exporter::_add_mesh_to_object_stream(std::stringstream& stream, ModelObject& object)
+    {
+        stream << "   <mesh>\n";
+        stream << "    <vertices>\n";
+
+        typedef std::map<ModelVolume*, unsigned int> VolumeToOffsetMap; 
+        VolumeToOffsetMap volumes_offset;
+        unsigned int vertices_count = 0;
+        for (ModelVolume* volume : object.volumes)
+        {
+            if (volume == nullptr)
+                continue;
+
+            volumes_offset.insert(VolumeToOffsetMap::value_type(volume, vertices_count));
+
+            if (!volume->mesh.repaired)
+                volume->mesh.repair();
+
+            stl_file& stl = volume->mesh.stl;
+            if (stl.v_shared == nullptr)
+                stl_generate_shared_vertices(&stl);
+
+            if (stl.stats.shared_vertices == 0)
+            {
+                add_error("Found invalid mesh");
+                return false;
+            }
+
+            vertices_count += stl.stats.shared_vertices;
+
+            for (int i = 0; i < stl.stats.shared_vertices; ++i)
+            {
+                stream << "     <vertex ";
+                // Subtract origin_translation in order to restore the original local coordinates
+                stream << "x=\"" << (stl.v_shared[i].x - object.origin_translation.x) << "\" ";
+                stream << "y=\"" << (stl.v_shared[i].y - object.origin_translation.y) << "\" ";
+                stream << "z=\"" << (stl.v_shared[i].z - object.origin_translation.z) << "\" />\n";
+            }
+        }
+
+        stream << "    </vertices>\n";
+        stream << "    <triangles>\n";
+
+        for (ModelVolume* volume : object.volumes)
+        {
+            if (volume == nullptr)
+                continue;
+
+            VolumeToOffsetMap::const_iterator offset_it = volumes_offset.find(volume);
+            assert(offset_it != volumes_offset.end());
+
+            stl_file& stl = volume->mesh.stl;
+
+            for (uint32_t i = 0; i < stl.stats.number_of_facets; ++i)
+            {
+                stream << "     <triangle ";
+                for (int j = 0; j < 3; ++j)
+                {
+                    stream << "v" << j + 1 << "=\"" << stl.v_indices[i].vertex[j] + offset_it->second << "\" ";
+                }
+                stream << "/>\n";
+            }
+
+        }
+
+        stream << "    </triangles>\n";
+        stream << "   </mesh>\n";
+
+        return true;
+    }
+
+    bool _3MF_Exporter::_add_build_to_model_stream(std::stringstream& stream, const BuildItemsList& build_items)
+    {
+        if (build_items.size() == 0)
+        {
+            add_error("No build item found");
+            return false;
+        }
+
+        stream << " <build>\n";
+
+        for (const BuildItem& item : build_items)
+        {
+            stream << "  <item objectid=\"" << item.id << "\" transform =\"";
+            for (unsigned c = 0; c < 4; ++c)
+            {
+                for (unsigned r = 0; r < 3; ++r)
+                {
+                    stream << item.matrix(r, c);
+                    if ((r != 2) || (c != 3))
+                        stream << " ";
+                }
+            }
+            stream << "\" />\n";
+        }
+
+        stream << " </build>\n";
+
+        return true;
+    }
+
+    bool _3MF_Exporter::_add_config_file_to_archive(mz_zip_archive& archive, const Print& print)
+    {
+        char buffer[1024];
+        sprintf(buffer, "; %s\n\n", header_slic3r_generated().c_str());
+        std::string out = buffer;
+
+        GCode::append_full_config(print, out);
+
+        if (!mz_zip_writer_add_mem(&archive, CONFIG_FILE.c_str(), (const void*)out.data(), out.length(), MZ_DEFAULT_COMPRESSION))
+        {
+            add_error("Unable to add config file to archive");
+            return false;
+        }
+
+        return true;
+    }
+
+    bool load_3mf(const char* path, PresetBundle* bundle, Model* model)
+    {
+        if ((path == nullptr) || (bundle == nullptr) || (model == nullptr))
+            return false;
+
+        _3MF_Importer importer;
+        bool res = importer.load_model_from_file(path, *model, *bundle);
+
+        if (!res)
+            importer.log_errors();
+
+        return res;
+    }
+
+    bool store_3mf(const char* path, Model* model, Print* print)
+    {
+        if ((path == nullptr) || (model == nullptr) || (print == nullptr))
+            return false;
+
+        _3MF_Exporter exporter;
+        bool res = exporter.save_model_to_file(path, *model, *print);
+
+        if (!res)
+            exporter.log_errors();
+
+        return res;
+    }
+
+} // namespace Slic3r
diff --git a/xs/src/libslic3r/Format/3mf.hpp b/xs/src/libslic3r/Format/3mf.hpp
new file mode 100644
index 000000000..9b48c860b
--- /dev/null
+++ b/xs/src/libslic3r/Format/3mf.hpp
@@ -0,0 +1,19 @@
+#ifndef slic3r_Format_3mf_hpp_
+#define slic3r_Format_3mf_hpp_
+
+namespace Slic3r {
+
+    class Model;
+    class Print;
+    class PresetBundle;
+
+    // Load the content of a 3mf file into the given model and preset bundle.
+    extern bool load_3mf(const char* path, PresetBundle* bundle, Model* model);
+
+    // Save the given model and the config data contained in the given Print into a 3mf file.
+    // The model could be modified during the export process if meshes are not repaired or have no shared vertices
+    extern bool store_3mf(const char* path, Model* model, Print* print);
+
+}; // namespace Slic3r
+
+#endif /* slic3r_Format_3mf_hpp_ */
diff --git a/xs/src/libslic3r/Format/AMF.cpp b/xs/src/libslic3r/Format/AMF.cpp
index b8abf038b..a52dd532a 100644
--- a/xs/src/libslic3r/Format/AMF.cpp
+++ b/xs/src/libslic3r/Format/AMF.cpp
@@ -7,8 +7,14 @@
 
 #include "../libslic3r.h"
 #include "../Model.hpp"
+#include "../GCode.hpp"
+#include "../slic3r/GUI/PresetBundle.hpp"
 #include "AMF.hpp"
 
+#include <boost/filesystem/operations.hpp>
+#include <boost/algorithm/string.hpp>
+#include <miniz/miniz_zip.h>
+
 #if 0
 // Enable debugging and assert in this file.
 #define DEBUG
@@ -18,18 +24,22 @@
 
 #include <assert.h>
 
+const char* SLIC3R_CONFIG_TYPE = "slic3rpe_config";
+
 namespace Slic3r
 {
 
 struct AMFParserContext
 {
-    AMFParserContext(XML_Parser parser, Model *model) :
+    AMFParserContext(XML_Parser parser, const std::string& archive_filename, PresetBundle* preset_bundle, Model *model) :
         m_parser(parser),
         m_model(*model), 
         m_object(nullptr), 
         m_volume(nullptr),
         m_material(nullptr),
-        m_instance(nullptr)
+        m_instance(nullptr),
+        m_preset_bundle(preset_bundle),
+        m_archive_filename(archive_filename)
     {
         m_path.reserve(12);
     }
@@ -149,6 +159,10 @@ struct AMFParserContext
     Instance                *m_instance;
     // Generic string buffer for vertices, face indices, metadata etc.
     std::string              m_value[3];
+    // Pointer to preset bundle to update if config data are stored inside the amf file
+    PresetBundle*            m_preset_bundle;
+    // Fullpath name of the amf file
+    std::string              m_archive_filename;
 
 private:
     AMFParserContext& operator=(AMFParserContext&);
@@ -403,7 +417,10 @@ void AMFParserContext::endElement(const char * /* name */)
         break;
 
     case NODE_TYPE_METADATA:
-        if (strncmp(m_value[0].c_str(), "slic3r.", 7) == 0) {
+        if ((m_preset_bundle != nullptr) && strncmp(m_value[0].c_str(), SLIC3R_CONFIG_TYPE, strlen(SLIC3R_CONFIG_TYPE)) == 0) {
+            m_preset_bundle->load_config_string(m_value[1].c_str(), m_archive_filename.c_str());
+        }
+        else if (strncmp(m_value[0].c_str(), "slic3r.", 7) == 0) {
             const char *opt_key = m_value[0].c_str() + 7;
             if (print_config_def.options.find(opt_key) != print_config_def.options.end()) {
                 DynamicPrintConfig *config = nullptr;
@@ -474,10 +491,13 @@ void AMFParserContext::endDocument()
 }
 
 // Load an AMF file into a provided model.
-bool load_amf(const char *path, Model *model)
+bool load_amf_file(const char *path, PresetBundle* bundle, Model *model)
 {
+    if ((path == nullptr) || (model == nullptr))
+        return false;
+
     XML_Parser parser = XML_ParserCreate(nullptr); // encoding
-    if (! parser) {
+    if (!parser) {
         printf("Couldn't allocate memory for parser\n");
         return false;
     }
@@ -488,7 +508,7 @@ bool load_amf(const char *path, Model *model)
         return false;
     }
 
-    AMFParserContext ctx(parser, model);
+    AMFParserContext ctx(parser, path, bundle, model);
     XML_SetUserData(parser, (void*)&ctx);
     XML_SetElementHandler(parser, AMFParserContext::startElement, AMFParserContext::endElement);
     XML_SetCharacterDataHandler(parser, AMFParserContext::characters);
@@ -519,49 +539,163 @@ bool load_amf(const char *path, Model *model)
 
     if (result)
         ctx.endDocument();
+
     return result;
 }
 
-bool store_amf(const char *path, Model *model)
+// Load an AMF archive into a provided model.
+bool load_amf_archive(const char *path, PresetBundle* bundle, Model *model)
 {
-    FILE *file = boost::nowide::fopen(path, "wb");
-    if (file == nullptr)
+    if ((path == nullptr) || (model == nullptr))
         return false;
 
-    fprintf(file, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
-    fprintf(file, "<amf unit=\"millimeter\">\n");
-    fprintf(file, "<metadata type=\"cad\">Slic3r %s</metadata>\n", SLIC3R_VERSION);
+    mz_zip_archive archive;
+    mz_zip_zero_struct(&archive);
+
+    mz_bool res = mz_zip_reader_init_file(&archive, path, 0);
+    if (res == 0)
+    {
+        printf("Unable to init zip reader\n");
+        return false;
+    }
+
+    mz_uint num_entries = mz_zip_reader_get_num_files(&archive);
+    if (num_entries != 1)
+    {
+        printf("Found invalid number of entries\n");
+        mz_zip_reader_end(&archive);
+        return false;
+    }
+
+    mz_zip_archive_file_stat stat;
+    res = mz_zip_reader_file_stat(&archive, 0, &stat);
+    if (res == 0)
+    {
+        printf("Unable to extract entry statistics\n");
+        mz_zip_reader_end(&archive);
+        return false;
+    }
+
+    std::string internal_amf_filename = boost::ireplace_last_copy(boost::filesystem::path(path).filename().string(), ".zip.amf", ".amf");
+    if (internal_amf_filename != stat.m_filename)
+    {
+        printf("Found invalid internal filename\n");
+        mz_zip_reader_end(&archive);
+        return false;
+    }
+
+    if (stat.m_uncomp_size == 0)
+    {
+        printf("Found invalid size\n");
+        mz_zip_reader_end(&archive);
+        return false;
+    }
+
+    XML_Parser parser = XML_ParserCreate(nullptr); // encoding
+    if (!parser) {
+        printf("Couldn't allocate memory for parser\n");
+        mz_zip_reader_end(&archive);
+        return false;
+    }
+
+    AMFParserContext ctx(parser, path, bundle, model);
+    XML_SetUserData(parser, (void*)&ctx);
+    XML_SetElementHandler(parser, AMFParserContext::startElement, AMFParserContext::endElement);
+    XML_SetCharacterDataHandler(parser, AMFParserContext::characters);
+
+    void* parser_buffer = XML_GetBuffer(parser, (int)stat.m_uncomp_size);
+    if (parser_buffer == nullptr)
+    {
+        printf("Unable to create buffer\n");
+        mz_zip_reader_end(&archive);
+        return false;
+    }
+
+    res = mz_zip_reader_extract_file_to_mem(&archive, stat.m_filename, parser_buffer, (size_t)stat.m_uncomp_size, 0);
+    if (res == 0)
+    {
+        printf("Error while reading model data to buffer\n");
+        mz_zip_reader_end(&archive);
+        return false;
+    }
+
+    if (!XML_ParseBuffer(parser, (int)stat.m_uncomp_size, 1))
+    {
+        printf("Error (%s) while parsing xml file at line %d\n", XML_ErrorString(XML_GetErrorCode(parser)), XML_GetCurrentLineNumber(parser));
+        mz_zip_reader_end(&archive);
+        return false;
+    }
+
+    ctx.endDocument();
+
+    mz_zip_reader_end(&archive);
+    return true;
+}
+
+// Load an AMF file into a provided model.
+// If bundle is not a null pointer, updates it if the amf file/archive contains config data
+bool load_amf(const char *path, PresetBundle* bundle, Model *model)
+{
+    if (boost::iends_with(path, ".zip.amf"))
+        return load_amf_archive(path, bundle, model);
+    else if (boost::iends_with(path, ".amf") || boost::iends_with(path, ".amf.xml"))
+        return load_amf_file(path, bundle, model);
+    else
+        return false;
+}
+
+bool store_amf(const char *path, Model *model, Print* print)
+{
+    if ((path == nullptr) || (model == nullptr) || (print == nullptr))
+        return false;
+
+    mz_zip_archive archive;
+    mz_zip_zero_struct(&archive);
+
+    mz_bool res = mz_zip_writer_init_file(&archive, path, 0);
+    if (res == 0)
+        return false;
+
+    std::stringstream stream;
+    stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+    stream << "<amf unit=\"millimeter\">\n";
+    stream << "<metadata type=\"cad\">Slic3r " << SLIC3R_VERSION << "</metadata>\n";
+
+    std::string config = "\n";
+    GCode::append_full_config(*print, config);
+    stream << "<metadata type=\"" << SLIC3R_CONFIG_TYPE << "\">" << config << "</metadata>\n";
+
     for (const auto &material : model->materials) {
         if (material.first.empty())
             continue;
         // note that material-id must never be 0 since it's reserved by the AMF spec
-        fprintf(file, "  <material id=\"%s\">\n", material.first.c_str());
+        stream << "  <material id=\"" << material.first << "\">\n";
         for (const auto &attr : material.second->attributes)
-             fprintf(file, "    <metadata type=\"%s\">%s</metadata>\n", attr.first.c_str(), attr.second.c_str());
+            stream << "    <metadata type=\"" << attr.first << "\">" << attr.second << "</metadata>\n";
         for (const std::string &key : material.second->config.keys())
-             fprintf(file, "    <metadata type=\"slic3r.%s\">%s</metadata>\n", key.c_str(), material.second->config.serialize(key).c_str());
-        fprintf(file, "  </material>\n");
+            stream << "    <metadata type=\"slic3r." << key << "\">" << material.second->config.serialize(key) << "</metadata>\n";
+        stream << "  </material>\n";
     }
     std::string instances;
     for (size_t object_id = 0; object_id < model->objects.size(); ++ object_id) {
         ModelObject *object = model->objects[object_id];
-        fprintf(file, "  <object id=\"" PRINTF_ZU "\">\n", object_id);
+        stream << "  <object id=\"" << object_id << "\">\n";
         for (const std::string &key : object->config.keys())
-             fprintf(file, "    <metadata type=\"slic3r.%s\">%s</metadata>\n", key.c_str(), object->config.serialize(key).c_str());
-        if (! object->name.empty())
-            fprintf(file, "    <metadata type=\"name\">%s</metadata>\n", object->name.c_str());
+            stream << "    <metadata type=\"slic3r." << key << "\">" << object->config.serialize(key) << "</metadata>\n";
+        if (!object->name.empty())
+            stream << "    <metadata type=\"name\">" << object->name << "</metadata>\n";
         std::vector<double> layer_height_profile = object->layer_height_profile_valid ? object->layer_height_profile : std::vector<double>();
         if (layer_height_profile.size() >= 4 && (layer_height_profile.size() % 2) == 0) {
             // Store the layer height profile as a single semicolon separated list.
-            fprintf(file, "    <metadata type=\"slic3r.layer_height_profile\">");
-            fprintf(file, "%f", layer_height_profile.front());
-            for (size_t i = 1; i < layer_height_profile.size(); ++ i)
-                fprintf(file, ";%f", layer_height_profile[i]);
-            fprintf(file, "\n    </metadata>\n");
+            stream << "    <metadata type=\"slic3r.layer_height_profile\">";
+            stream << layer_height_profile.front();
+            for (size_t i = 1; i < layer_height_profile.size(); ++i)
+                stream << ";" << layer_height_profile[i];
+                stream << "\n    </metadata>\n";
         }
         //FIXME Store the layer height ranges (ModelObject::layer_height_ranges)
-        fprintf(file, "    <mesh>\n");
-        fprintf(file, "      <vertices>\n");
+        stream << "    <mesh>\n";
+        stream << "      <vertices>\n";
         std::vector<int> vertices_offsets;
         int              num_vertices = 0;
         for (ModelVolume *volume : object->volumes) {
@@ -572,41 +706,41 @@ bool store_amf(const char *path, Model *model)
             if (stl.v_shared == nullptr)
                 stl_generate_shared_vertices(&stl);
             for (size_t i = 0; i < stl.stats.shared_vertices; ++ i) {
-                fprintf(file, "         <vertex>\n");
-                fprintf(file, "           <coordinates>\n");
-                fprintf(file, "             <x>%f</x>\n", stl.v_shared[i].x);
-                fprintf(file, "             <y>%f</y>\n", stl.v_shared[i].y);
-                fprintf(file, "             <z>%f</z>\n", stl.v_shared[i].z);
-                fprintf(file, "           </coordinates>\n");
-                fprintf(file, "         </vertex>\n");
+                stream << "         <vertex>\n";
+                stream << "           <coordinates>\n";
+                stream << "             <x>" << stl.v_shared[i].x << "</x>\n";
+                stream << "             <y>" << stl.v_shared[i].y << "</y>\n";
+                stream << "             <z>" << stl.v_shared[i].z << "</z>\n";
+                stream << "           </coordinates>\n";
+                stream << "         </vertex>\n";
             }
             num_vertices += stl.stats.shared_vertices;
         }
-        fprintf(file, "      </vertices>\n");
-        for (size_t i_volume = 0; i_volume < object->volumes.size(); ++ i_volume) {
+        stream << "      </vertices>\n";
+        for (size_t i_volume = 0; i_volume < object->volumes.size(); ++i_volume) {
             ModelVolume *volume = object->volumes[i_volume];
             int vertices_offset = vertices_offsets[i_volume];
             if (volume->material_id().empty())
-                fprintf(file, "      <volume>\n");
+                stream << "      <volume>\n";
             else
-                fprintf(file, "      <volume materialid=\"%s\">\n", volume->material_id().c_str());
+                stream << "      <volume materialid=\"" << volume->material_id() << "\">\n";
             for (const std::string &key : volume->config.keys())
-                fprintf(file, "        <metadata type=\"slic3r.%s\">%s</metadata>\n", key.c_str(), volume->config.serialize(key).c_str());
-            if (! volume->name.empty())
-                fprintf(file, "        <metadata type=\"name\">%s</metadata>\n", volume->name.c_str());
+                stream << "        <metadata type=\"slic3r." << key << "\">" << volume->config.serialize(key) << "</metadata>\n";
+            if (!volume->name.empty())
+                stream << "        <metadata type=\"name\">" << volume->name << "</metadata>\n";
             if (volume->modifier)
-                fprintf(file, "        <metadata type=\"slic3r.modifier\">1</metadata>\n");
-            for (int i = 0; i < volume->mesh.stl.stats.number_of_facets; ++ i) {
-                fprintf(file, "        <triangle>\n");
-                for (int j = 0; j < 3; ++ j)
-                    fprintf(file, "          <v%d>%d</v%d>\n", j+1, volume->mesh.stl.v_indices[i].vertex[j] + vertices_offset, j+1);
-                fprintf(file, "        </triangle>\n");
+                stream << "        <metadata type=\"slic3r.modifier\">1</metadata>\n";
+            for (int i = 0; i < volume->mesh.stl.stats.number_of_facets; ++i) {
+                stream << "        <triangle>\n";
+                for (int j = 0; j < 3; ++j)
+                stream << "          <v" << j + 1 << ">" << volume->mesh.stl.v_indices[i].vertex[j] + vertices_offset << "</v" << j + 1 << ">\n";
+                stream << "        </triangle>\n";
             }
-            fprintf(file, "      </volume>\n");
+            stream << "      </volume>\n";
         }
-        fprintf(file, "    </mesh>\n");
-        fprintf(file, "  </object>\n");
-        if (! object->instances.empty()) {
+        stream << "    </mesh>\n";
+        stream << "  </object>\n";
+        if (!object->instances.empty()) {
             for (ModelInstance *instance : object->instances) {
                 char buf[512];
                 sprintf(buf,
@@ -627,12 +761,31 @@ bool store_amf(const char *path, Model *model)
         }
     }
     if (! instances.empty()) {
-        fprintf(file, "  <constellation id=\"1\">\n");
-        fwrite(instances.data(), instances.size(), 1, file);
-        fprintf(file, "  </constellation>\n");
+        stream << "  <constellation id=\"1\">\n";
+        stream << instances;
+        stream << "  </constellation>\n";
     }
-    fprintf(file, "</amf>\n");
-    fclose(file);
+    stream << "</amf>\n";
+
+    std::string internal_amf_filename = boost::ireplace_last_copy(boost::filesystem::path(path).filename().string(), ".zip.amf", ".amf");
+    std::string out = stream.str();
+
+    if (!mz_zip_writer_add_mem(&archive, internal_amf_filename.c_str(), (const void*)out.data(), out.length(), MZ_DEFAULT_COMPRESSION))
+    {
+        mz_zip_writer_end(&archive);
+        boost::filesystem::remove(path);
+        return false;
+    }
+
+    if (!mz_zip_writer_finalize_archive(&archive))
+    {
+        mz_zip_writer_end(&archive);
+        boost::filesystem::remove(path);
+        return false;
+    }
+
+    mz_zip_writer_end(&archive);
+
     return true;
 }
 
diff --git a/xs/src/libslic3r/Format/AMF.hpp b/xs/src/libslic3r/Format/AMF.hpp
index e58ce2f0f..027ebdab3 100644
--- a/xs/src/libslic3r/Format/AMF.hpp
+++ b/xs/src/libslic3r/Format/AMF.hpp
@@ -4,11 +4,15 @@
 namespace Slic3r {
 
 class Model;
+class Print;
+class PresetBundle;
 
-// Load an AMF file into a provided model.
-extern bool load_amf(const char *path, Model *model);
+// Load the content of an amf file into the given model and preset bundle.
+extern bool load_amf(const char *path, PresetBundle* bundle, Model *model);
 
-extern bool store_amf(const char *path, Model *model);
+// Save the given model and the config data contained in the given Print into an amf file.
+// The model could be modified during the export process if meshes are not repaired or have no shared vertices
+extern bool store_amf(const char *path, Model *model, Print* print);
 
 }; // namespace Slic3r
 
diff --git a/xs/src/libslic3r/Format/PRUS.cpp b/xs/src/libslic3r/Format/PRUS.cpp
index b7ef33774..1809eaead 100644
--- a/xs/src/libslic3r/Format/PRUS.cpp
+++ b/xs/src/libslic3r/Format/PRUS.cpp
@@ -148,7 +148,7 @@ bool load_prus(const char *path, Model *model)
                 if (scene_xml_data.size() < size_last + size_incr)
                     scene_xml_data.resize(size_last + size_incr);
             }
-            size_last += size_last + zip.LastRead();
+            size_last += zip.LastRead();
             if (scene_xml_data.size() == size_last)
                 scene_xml_data.resize(size_last + 1);
             else if (scene_xml_data.size() > size_last + 1)
diff --git a/xs/src/libslic3r/GCode.cpp b/xs/src/libslic3r/GCode.cpp
index 47695a230..2c2df6ec3 100644
--- a/xs/src/libslic3r/GCode.cpp
+++ b/xs/src/libslic3r/GCode.cpp
@@ -13,6 +13,7 @@
 #include <boost/algorithm/string.hpp>
 #include <boost/algorithm/string/find.hpp>
 #include <boost/foreach.hpp>
+#include <boost/log/trivial.hpp>
 
 #include <boost/nowide/iostream.hpp>
 #include <boost/nowide/cstdio.hpp>
@@ -20,6 +21,8 @@
 
 #include "SVG.hpp"
 
+#include <Shiny/Shiny.h>
+
 #if 0
 // Enable debugging and asserts, even in the release build.
 #define DEBUG
@@ -267,22 +270,6 @@ std::string WipeTowerIntegration::finalize(GCode &gcodegen)
 
 #define EXTRUDER_CONFIG(OPT) m_config.OPT.get_at(m_writer.extruder()->id())
 
-inline void write(FILE *file, const std::string &what)
-{
-    fwrite(what.data(), 1, what.size(), file);
-}
-
-// Write a string into a file. Add a newline, if the string does not end with a newline already.
-// Used to export a custom G-code section processed by the PlaceholderParser.
-inline void writeln(FILE *file, const std::string &what)
-{
-    if (! what.empty()) {
-        write(file, what);
-        if (what.back() != '\n')
-            fprintf(file, "\n");
-    }
-}
-
 // Collect pairs of object_layer + support_layer sorted by print_z.
 // object_layer & support_layer are considered to be on the same print_z, if they are not further than EPSILON.
 std::vector<GCode::LayerToPrint> GCode::collect_layers_to_print(const PrintObject &object)
@@ -362,8 +349,12 @@ std::vector<std::pair<coordf_t, std::vector<GCode::LayerToPrint>>> GCode::collec
     return layers_to_print;
 }
 
-void GCode::do_export(Print *print, const char *path)
+void GCode::do_export(Print *print, const char *path, GCodePreviewData *preview_data)
 {
+    PROFILE_CLEAR();
+
+    BOOST_LOG_TRIVIAL(info) << "Exporting G-code...";
+
     // Remove the old g-code if it exists.
     boost::nowide::remove(path);
 
@@ -375,7 +366,7 @@ void GCode::do_export(Print *print, const char *path)
         throw std::runtime_error(std::string("G-code export to ") + path + " failed.\nCannot open the file for writing.\n");
 
     this->m_placeholder_parser_failed_templates.clear();
-    this->_do_export(*print, file);
+    this->_do_export(*print, file, preview_data);
     fflush(file);
     if (ferror(file)) {
         fclose(file);
@@ -395,14 +386,36 @@ void GCode::do_export(Print *print, const char *path)
         msg += "        !!!!! End of an error report for the custom G-code template ...\n";
         throw std::runtime_error(msg);
     }
+
     if (boost::nowide::rename(path_tmp.c_str(), path) != 0)
         throw std::runtime_error(
             std::string("Failed to rename the output G-code file from ") + path_tmp + " to " + path + '\n' +
             "Is " + path_tmp + " locked?" + '\n');
+
+    BOOST_LOG_TRIVIAL(info) << "Exporting G-code finished";
+
+    // Write the profiler measurements to file
+    PROFILE_UPDATE();
+    PROFILE_OUTPUT(debug_out_path("gcode-export-profile.txt").c_str());
 }
 
-void GCode::_do_export(Print &print, FILE *file)
+void GCode::_do_export(Print &print, FILE *file, GCodePreviewData *preview_data)
 {
+    PROFILE_FUNC();
+
+    // resets time estimator
+    m_time_estimator.reset();
+    m_time_estimator.set_dialect(print.config.gcode_flavor);
+
+    // resets analyzer
+    m_analyzer.reset();
+    m_enable_analyzer = preview_data != nullptr;
+
+    // resets analyzer's tracking data
+    m_last_mm3_per_mm = GCodeAnalyzer::Default_mm3_per_mm;
+    m_last_width = GCodeAnalyzer::Default_Width;
+    m_last_height = GCodeAnalyzer::Default_Height;
+
     // How many times will be change_layer() called?
     // change_layer() in turn increments the progress bar status.
     m_layer_count = 0;
@@ -486,7 +499,7 @@ void GCode::_do_export(Print &print, FILE *file)
     m_enable_extrusion_role_markers = (bool)m_pressure_equalizer;
 
     // Write information on the generator.
-    fprintf(file, "; %s\n\n", Slic3r::header_slic3r_generated().c_str());
+    _write_format(file, "; %s\n\n", Slic3r::header_slic3r_generated().c_str());
     // Write notes (content of the Print Settings tab -> Notes)
     {
         std::list<std::string> lines;
@@ -495,10 +508,10 @@ void GCode::_do_export(Print &print, FILE *file)
             // Remove the trailing '\r' from the '\r\n' sequence.
             if (! line.empty() && line.back() == '\r')
                 line.pop_back();
-            fprintf(file, "; %s\n", line.c_str());
+            _write_format(file, "; %s\n", line.c_str());
         }
         if (! lines.empty())
-            fprintf(file, "\n");
+            _write(file, "\n");
     }
     // Write some terse information on the slicing parameters.
     const PrintObject *first_object         = print.objects.front();
@@ -506,16 +519,16 @@ void GCode::_do_export(Print &print, FILE *file)
     const double       first_layer_height   = first_object->config.first_layer_height.get_abs_value(layer_height);
     for (size_t region_id = 0; region_id < print.regions.size(); ++ region_id) {
         auto region = print.regions[region_id];
-        fprintf(file, "; external perimeters extrusion width = %.2fmm\n", region->flow(frExternalPerimeter, layer_height, false, false, -1., *first_object).width);
-        fprintf(file, "; perimeters extrusion width = %.2fmm\n",          region->flow(frPerimeter,         layer_height, false, false, -1., *first_object).width);
-        fprintf(file, "; infill extrusion width = %.2fmm\n",              region->flow(frInfill,            layer_height, false, false, -1., *first_object).width);
-        fprintf(file, "; solid infill extrusion width = %.2fmm\n",        region->flow(frSolidInfill,       layer_height, false, false, -1., *first_object).width);
-        fprintf(file, "; top infill extrusion width = %.2fmm\n",          region->flow(frTopSolidInfill,    layer_height, false, false, -1., *first_object).width);
+        _write_format(file, "; external perimeters extrusion width = %.2fmm\n", region->flow(frExternalPerimeter, layer_height, false, false, -1., *first_object).width);
+        _write_format(file, "; perimeters extrusion width = %.2fmm\n",          region->flow(frPerimeter,         layer_height, false, false, -1., *first_object).width);
+        _write_format(file, "; infill extrusion width = %.2fmm\n",              region->flow(frInfill,            layer_height, false, false, -1., *first_object).width);
+        _write_format(file, "; solid infill extrusion width = %.2fmm\n",        region->flow(frSolidInfill,       layer_height, false, false, -1., *first_object).width);
+        _write_format(file, "; top infill extrusion width = %.2fmm\n",          region->flow(frTopSolidInfill,    layer_height, false, false, -1., *first_object).width);
         if (print.has_support_material())
-            fprintf(file, "; support material extrusion width = %.2fmm\n", support_material_flow(first_object).width);
+            _write_format(file, "; support material extrusion width = %.2fmm\n", support_material_flow(first_object).width);
         if (print.config.first_layer_extrusion_width.value > 0)
-            fprintf(file, "; first layer extrusion width = %.2fmm\n",   region->flow(frPerimeter, first_layer_height, false, true, -1., *first_object).width);
-        fprintf(file, "\n");
+            _write_format(file, "; first layer extrusion width = %.2fmm\n",   region->flow(frPerimeter, first_layer_height, false, true, -1., *first_object).width);
+        _write_format(file, "\n");
     }
     
     // Prepare the helper object for replacing placeholders in custom G-code and output filename.
@@ -558,7 +571,7 @@ void GCode::_do_export(Print &print, FILE *file)
 
     // Disable fan.
     if (! print.config.cooling.get_at(initial_extruder_id) || print.config.disable_fan_first_layers.get_at(initial_extruder_id))
-        write(file, m_writer.set_fan(0, true));
+        _write(file, m_writer.set_fan(0, true));
 
     // Let the start-up script prime the 1st printing tool.
     m_placeholder_parser.set("initial_tool", initial_extruder_id);
@@ -575,24 +588,24 @@ void GCode::_do_export(Print &print, FILE *file)
     // Set extruder(s) temperature before and after start G-code.
     this->_print_first_layer_extruder_temperatures(file, print, start_gcode, initial_extruder_id, false);
     // Write the custom start G-code
-    writeln(file, start_gcode);
+    _writeln(file, start_gcode);
     // Process filament-specific gcode in extruder order.
     if (print.config.single_extruder_multi_material) {
         if (has_wipe_tower) {
             // Wipe tower will control the extruder switching, it will call the start_filament_gcode.
         } else {
             // Only initialize the initial extruder.
-            writeln(file, this->placeholder_parser_process("start_filament_gcode", print.config.start_filament_gcode.values[initial_extruder_id], initial_extruder_id));
+            _writeln(file, this->placeholder_parser_process("start_filament_gcode", print.config.start_filament_gcode.values[initial_extruder_id], initial_extruder_id));
         }
     } else {
         for (const std::string &start_gcode : print.config.start_filament_gcode.values)
-            writeln(file, this->placeholder_parser_process("start_gcode", start_gcode, (unsigned int)(&start_gcode - &print.config.start_filament_gcode.values.front())));
+            _writeln(file, this->placeholder_parser_process("start_gcode", start_gcode, (unsigned int)(&start_gcode - &print.config.start_filament_gcode.values.front())));
     }
     this->_print_first_layer_extruder_temperatures(file, print, start_gcode, initial_extruder_id, true);
     
     // Set other general things.
-    write(file, this->preamble());
-    
+    _write(file, this->preamble());
+
     // Initialize a motion planner for object-to-object travel moves.
     if (print.config.avoid_crossing_perimeters.value) {
         // Collect outer contours of all objects over all layers.
@@ -640,7 +653,7 @@ void GCode::_do_export(Print &print, FILE *file)
     }
     
     // Set initial extruder only after custom start G-code.
-    write(file, this->set_extruder(initial_extruder_id));
+    _write(file, this->set_extruder(initial_extruder_id));
 
     // Do all objects for each layer.
     if (print.config.complete_objects.value) {
@@ -670,8 +683,8 @@ void GCode::_do_export(Print &print, FILE *file)
                     // This happens before Z goes down to layer 0 again, so that no collision happens hopefully.
                     m_enable_cooling_markers = false; // we're not filtering these moves through CoolingBuffer
                     m_avoid_crossing_perimeters.use_external_mp_once = true;
-                    write(file, this->retract());
-                    write(file, this->travel_to(Point(0, 0), erNone, "move to origin position for next object"));
+                    _write(file, this->retract());
+                    _write(file, this->travel_to(Point(0, 0), erNone, "move to origin position for next object"));
                     m_enable_cooling_markers = true;
                     // Disable motion planner when traveling to first object point.
                     m_avoid_crossing_perimeters.disable_once = true;
@@ -683,7 +696,7 @@ void GCode::_do_export(Print &print, FILE *file)
                     // Set first layer bed and extruder temperatures, don't wait for it to reach the temperature.
                     this->_print_first_layer_bed_temperature(file, print, between_objects_gcode, initial_extruder_id, false);
                     this->_print_first_layer_extruder_temperatures(file, print, between_objects_gcode, initial_extruder_id, false);
-                    writeln(file, between_objects_gcode);
+                    _writeln(file, between_objects_gcode);
                 }
                 // Reset the cooling buffer internal state (the current position, feed rate, accelerations).
                 m_cooling_buffer->reset();
@@ -696,7 +709,7 @@ void GCode::_do_export(Print &print, FILE *file)
                     this->process_layer(file, print, lrs, tool_ordering.tools_for_layer(ltp.print_z()), &copy - object._shifted_copies.data());
                 }
                 if (m_pressure_equalizer)
-                    write(file, m_pressure_equalizer->process("", true));
+                    _write(file, m_pressure_equalizer->process("", true));
                 ++ finished_objects;
                 // Flag indicating whether the nozzle temperature changes from 1st to 2nd layer were performed.
                 // Reset it when starting another object from 1st layer.
@@ -716,8 +729,8 @@ void GCode::_do_export(Print &print, FILE *file)
         // Prusa Multi-Material wipe tower.
         if (has_wipe_tower && ! layers_to_print.empty()) {
             m_wipe_tower.reset(new WipeTowerIntegration(print.config, *print.m_wipe_tower_priming.get(), print.m_wipe_tower_tool_changes, *print.m_wipe_tower_final_purge.get()));
-            write(file, m_writer.travel_to_z(first_layer_height + m_config.z_offset.value, "Move to the first layer height"));
-		    write(file, m_wipe_tower->prime(*this));
+            _write(file, m_writer.travel_to_z(first_layer_height + m_config.z_offset.value, "Move to the first layer height"));
+		    _write(file, m_wipe_tower->prime(*this));
             // Verify, whether the print overaps the priming extrusions.
             BoundingBoxf bbox_print(get_print_extrusions_extents(print));
             coordf_t twolayers_printz = ((layers_to_print.size() == 1) ? layers_to_print.front() : layers_to_print[1]).first + EPSILON;
@@ -727,16 +740,17 @@ void GCode::_do_export(Print &print, FILE *file)
             BoundingBoxf bbox_prime(get_wipe_tower_priming_extrusions_extents(print));
             bbox_prime.offset(0.5f);
             // Beep for 500ms, tone 800Hz. Yet better, play some Morse.
-            write(file, this->retract());
-            fprintf(file, "M300 S800 P500\n");
+            _write(file, this->retract());
+            _write(file, "M300 S800 P500\n");
             if (bbox_prime.overlap(bbox_print)) {
                 // Wait for the user to remove the priming extrusions, otherwise they would
                 // get covered by the print.
-                fprintf(file, "M1 Remove priming towers and click button.\n");
-            } else {
+                _write(file, "M1 Remove priming towers and click button.\n");
+            }
+            else {
                 // Just wait for a bit to let the user check, that the priming succeeded.
                 //TODO Add a message explaining what the printer is waiting for. This needs a firmware fix.
-                fprintf(file, "M1 S10\n");
+                _write(file, "M1 S10\n");
             }
         }
         // Extrude the layers.
@@ -747,26 +761,29 @@ void GCode::_do_export(Print &print, FILE *file)
             this->process_layer(file, print, layer.second, layer_tools, size_t(-1));
         }
         if (m_pressure_equalizer)
-            write(file, m_pressure_equalizer->process("", true));
+            _write(file, m_pressure_equalizer->process("", true));
         if (m_wipe_tower)
             // Purge the extruder, pull out the active filament.
-            write(file, m_wipe_tower->finalize(*this));
+            _write(file, m_wipe_tower->finalize(*this));
     }
 
     // Write end commands to file.
-    write(file, this->retract());
-    write(file, m_writer.set_fan(false));
+    _write(file, this->retract());
+    _write(file, m_writer.set_fan(false));
     // Process filament-specific gcode in extruder order.
     if (print.config.single_extruder_multi_material) {
         // Process the end_filament_gcode for the active filament only.
-        writeln(file, this->placeholder_parser_process("end_filament_gcode", print.config.end_filament_gcode.get_at(m_writer.extruder()->id()), m_writer.extruder()->id()));
+        _writeln(file, this->placeholder_parser_process("end_filament_gcode", print.config.end_filament_gcode.get_at(m_writer.extruder()->id()), m_writer.extruder()->id()));
     } else {
         for (const std::string &end_gcode : print.config.end_filament_gcode.values)
-            writeln(file, this->placeholder_parser_process("end_gcode", end_gcode, (unsigned int)(&end_gcode - &print.config.end_filament_gcode.values.front())));
+            _writeln(file, this->placeholder_parser_process("end_filament_gcode", end_gcode, (unsigned int)(&end_gcode - &print.config.end_filament_gcode.values.front())));
     }
-    writeln(file, this->placeholder_parser_process("end_gcode", print.config.end_gcode, m_writer.extruder()->id()));
-    write(file, m_writer.update_progress(m_layer_count, m_layer_count, true)); // 100%
-    write(file, m_writer.postamble());
+    _writeln(file, this->placeholder_parser_process("end_gcode", print.config.end_gcode, m_writer.extruder()->id()));
+    _write(file, m_writer.update_progress(m_layer_count, m_layer_count, true)); // 100%
+    _write(file, m_writer.postamble());
+
+    // calculates estimated printing time
+    m_time_estimator.calculate_time();
 
     // Get filament stats.
     print.filament_stats.clear();
@@ -774,37 +791,40 @@ void GCode::_do_export(Print &print, FILE *file)
     print.total_extruded_volume  = 0.;
     print.total_weight           = 0.;
     print.total_cost             = 0.;
+    print.estimated_print_time   = m_time_estimator.get_time_hms();
     for (const Extruder &extruder : m_writer.extruders()) {
         double used_filament   = extruder.used_filament();
         double extruded_volume = extruder.extruded_volume();
         double filament_weight = extruded_volume * extruder.filament_density() * 0.001;
         double filament_cost   = filament_weight * extruder.filament_cost()    * 0.001;
         print.filament_stats.insert(std::pair<size_t,float>(extruder.id(), used_filament));
-        fprintf(file, "; filament used = %.1lfmm (%.1lfcm3)\n", used_filament, extruded_volume * 0.001);
+        _write_format(file, "; filament used = %.1lfmm (%.1lfcm3)\n", used_filament, extruded_volume * 0.001);
         if (filament_weight > 0.) {
             print.total_weight = print.total_weight + filament_weight;
-            fprintf(file, "; filament used = %.1lf\n", filament_weight);
+            _write_format(file, "; filament used = %.1lf\n", filament_weight);
             if (filament_cost > 0.) {
                 print.total_cost = print.total_cost + filament_cost;
-                fprintf(file, "; filament cost = %.1lf\n", filament_cost);
+                _write_format(file, "; filament cost = %.1lf\n", filament_cost);
             }
         }
-        print.total_used_filament   = print.total_used_filament + used_filament;
+        print.total_used_filament = print.total_used_filament + used_filament;
         print.total_extruded_volume = print.total_extruded_volume + extruded_volume;
     }
-    fprintf(file, "; total filament cost = %.1lf\n", print.total_cost);
+    _write_format(file, "; total filament cost = %.1lf\n", print.total_cost);
+    _write_format(file, "; estimated printing time = %s\n", m_time_estimator.get_time_hms().c_str());
 
     // Append full config.
-    fprintf(file, "\n");
+    _write(file, "\n");
     {
-        StaticPrintConfig *configs[] = { &print.config, &print.default_object_config, &print.default_region_config };
-        for (size_t i = 0; i < sizeof(configs) / sizeof(configs[0]); ++ i) {
-            StaticPrintConfig *cfg = configs[i];
-        for (const std::string &key : cfg->keys())
-            if (key != "compatible_printers")
-                fprintf(file, "; %s = %s\n", key.c_str(), cfg->serialize(key).c_str());
-        }
+        std::string full_config = "";
+        append_full_config(print, full_config);
+        if (!full_config.empty())
+            _write(file, full_config);
     }
+
+    // starts analizer calculations
+    if (preview_data != nullptr)
+        m_analyzer.calc_gcode_preview_data(*preview_data);
 }
 
 std::string GCode::placeholder_parser_process(const std::string &name, const std::string &templ, unsigned int current_extruder_id, const DynamicConfig *config_override)
@@ -893,7 +913,7 @@ void GCode::_print_first_layer_bed_temperature(FILE *file, Print &print, const s
     // the custom start G-code emited these.
     std::string set_temp_gcode = m_writer.set_bed_temperature(temp, wait);
     if (! temp_set_by_gcode)
-        write(file, set_temp_gcode);
+        _write(file, set_temp_gcode);
 }
 
 // Write 1st layer extruder temperatures into the G-code.
@@ -916,7 +936,7 @@ void GCode::_print_first_layer_extruder_temperatures(FILE *file, Print &print, c
             // Set temperature of the first printing extruder only.
             int temp = print.config.first_layer_temperature.get_at(first_printing_extruder_id);
             if (temp > 0)
-                write(file, m_writer.set_temperature(temp, wait, first_printing_extruder_id));
+                _write(file, m_writer.set_temperature(temp, wait, first_printing_extruder_id));
         } else {
             // Set temperatures of all the printing extruders.
             for (unsigned int tool_id : print.extruders()) {
@@ -924,7 +944,7 @@ void GCode::_print_first_layer_extruder_temperatures(FILE *file, Print &print, c
                 if (print.config.ooze_prevention.value)
                     temp += print.config.standby_temperature_delta.value;
                 if (temp > 0)
-                    write(file, m_writer.set_temperature(temp, wait, tool_id));
+                    _write(file, m_writer.set_temperature(temp, wait, tool_id));
             }
         }
     }
@@ -1296,12 +1316,7 @@ void GCode::process_layer(
 			if (print_object == nullptr)
 				// This layer is empty for this particular object, it has neither object extrusions nor support extrusions at this print_z.
 				continue;
-            if (m_enable_analyzer_markers) {
-                // Store the binary pointer to the layer object directly into the G-code to be accessed by the GCodeAnalyzer.
-                char buf[64];
-                sprintf(buf, ";_LAYEROBJ:%p\n", m_layer);
-                gcode += buf;
-            }
+
             m_config.apply(print_object->config, true);
             m_layer = layers[layer_id].layer();
             if (m_config.avoid_crossing_perimeters)
@@ -1358,7 +1373,7 @@ void GCode::process_layer(
         gcode = m_pressure_equalizer->process(gcode.c_str(), false);
     // printf("G-code after filter:\n%s\n", out.c_str());
 
-    write(file, gcode);
+    _write(file, gcode);
 }
 
 void GCode::apply_print_config(const PrintConfig &print_config)
@@ -1367,6 +1382,24 @@ void GCode::apply_print_config(const PrintConfig &print_config)
     m_config.apply(print_config);
 }
 
+void GCode::append_full_config(const Print& print, std::string& str)
+{
+    char buff[4096];
+
+    const StaticPrintConfig *configs[] = { &print.config, &print.default_object_config, &print.default_region_config };
+    for (size_t i = 0; i < sizeof(configs) / sizeof(configs[0]); ++i) {
+        const StaticPrintConfig *cfg = configs[i];
+        for (const std::string &key : cfg->keys())
+        {
+            if (key != "compatible_printers")
+            {
+                sprintf(buff, "; %s = %s\n", key.c_str(), cfg->serialize(key).c_str());
+                str += buff;
+            }
+        }
+    }
+}
+
 void GCode::set_extruders(const std::vector<unsigned int> &extruder_ids)
 {
     m_writer.set_extruders(extruder_ids);
@@ -1443,7 +1476,9 @@ static inline const char* ExtrusionRole2String(const ExtrusionRole role)
     case erSkirt:                       return "erSkirt";
     case erSupportMaterial:             return "erSupportMaterial";
     case erSupportMaterialInterface:    return "erSupportMaterialInterface";
+    case erWipeTower:                   return "erWipeTower";
     case erMixed:                       return "erMixed";
+
     default:                            return "erInvalid";
     };
 }
@@ -1993,6 +2028,57 @@ std::string GCode::extrude_support(const ExtrusionEntityCollection &support_fill
     return gcode;
 }
 
+void GCode::_write(FILE* file, const char *what)
+{
+    if (what != nullptr) {
+        // apply analyzer, if enabled
+        const char* gcode = m_enable_analyzer ? m_analyzer.process_gcode(what).c_str() : what;
+
+        // writes string to file
+        fwrite(gcode, 1, ::strlen(gcode), file);
+        // updates time estimator and gcode lines vector
+        m_time_estimator.add_gcode_block(gcode);
+    }
+}
+
+void GCode::_writeln(FILE* file, const std::string &what)
+{
+    if (! what.empty())
+        _write(file, (what.back() == '\n') ? what : (what + '\n'));
+}
+
+void GCode::_write_format(FILE* file, const char* format, ...)
+{
+    va_list args;
+    va_start(args, format);
+
+    int buflen;
+    {
+        va_list args2;
+        va_copy(args2, args);
+        buflen =
+    #ifdef _MSC_VER
+            ::_vscprintf(format, args2)
+    #else
+            ::vsnprintf(nullptr, 0, format, args2)
+    #endif
+            + 1;
+        va_end(args2);
+    }
+
+    char buffer[1024];
+    bool buffer_dynamic = buflen > 1024;
+    char *bufptr = buffer_dynamic ? (char*)malloc(buflen) : buffer;
+    int res = ::vsnprintf(bufptr, buflen, format, args);
+    if (res > 0)
+        _write(file, bufptr);
+
+    if (buffer_dynamic)
+        free(bufptr);
+
+    va_end(args);
+}
+
 std::string GCode::_extrude(const ExtrusionPath &path, std::string description, double speed)
 {
     std::string gcode;
@@ -2071,14 +2157,57 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
     double F = speed * 60;  // convert mm/sec to mm/min
     
     // extrude arc or line
-    if (m_enable_extrusion_role_markers || m_enable_analyzer_markers) {
-        if (path.role() != m_last_extrusion_role) {
+    if (m_enable_extrusion_role_markers || m_enable_analyzer)
+    {
+        if (path.role() != m_last_extrusion_role)
+        {
             m_last_extrusion_role = path.role();
+            if (m_enable_extrusion_role_markers)
+            {
+                char buf[32];
+                sprintf(buf, ";_EXTRUSION_ROLE:%d\n", int(m_last_extrusion_role));
+                gcode += buf;
+            }
+            if (m_enable_analyzer)
+            {
+                char buf[32];
+                sprintf(buf, ";%s%d\n", GCodeAnalyzer::Extrusion_Role_Tag.c_str(), int(m_last_extrusion_role));
+                gcode += buf;
+            }
+        }
+    }
+
+    // adds analyzer tags and updates analyzer's tracking data
+    if (m_enable_analyzer)
+    {
+        if (m_last_mm3_per_mm != path.mm3_per_mm)
+        {
+            m_last_mm3_per_mm = path.mm3_per_mm;
+
             char buf[32];
-            sprintf(buf, ";_EXTRUSION_ROLE:%d\n", int(path.role()));
+            sprintf(buf, ";%s%f\n", GCodeAnalyzer::Mm3_Per_Mm_Tag.c_str(), m_last_mm3_per_mm);
+            gcode += buf;
+        }
+
+        if (m_last_width != path.width)
+        {
+            m_last_width = path.width;
+
+            char buf[32];
+            sprintf(buf, ";%s%f\n", GCodeAnalyzer::Width_Tag.c_str(), m_last_width);
+            gcode += buf;
+        }
+
+        if (m_last_height != path.height)
+        {
+            m_last_height = path.height;
+
+            char buf[32];
+            sprintf(buf, ";%s%f\n", GCodeAnalyzer::Height_Tag.c_str(), m_last_height);
             gcode += buf;
         }
     }
+
     std::string comment;
     if (m_enable_cooling_markers) {
         if (is_bridge(path.role()))
@@ -2182,8 +2311,7 @@ bool GCode::needs_retraction(const Polyline &travel, ExtrusionRole role)
     return true;
 }
 
-std::string
-GCode::retract(bool toolchange)
+std::string GCode::retract(bool toolchange)
 {
     std::string gcode;
     
diff --git a/xs/src/libslic3r/GCode.hpp b/xs/src/libslic3r/GCode.hpp
index 2fd3b39d3..968cd14de 100644
--- a/xs/src/libslic3r/GCode.hpp
+++ b/xs/src/libslic3r/GCode.hpp
@@ -15,7 +15,9 @@
 #include "GCode/SpiralVase.hpp"
 #include "GCode/ToolOrdering.hpp"
 #include "GCode/WipeTower.hpp"
+#include "GCodeTimeEstimator.hpp"
 #include "EdgeGrid.hpp"
+#include "GCode/Analyzer.hpp"
 
 #include <memory>
 #include <string>
@@ -24,6 +26,7 @@ namespace Slic3r {
 
 // Forward declarations.
 class GCode;
+class GCodePreviewData;
 
 class AvoidCrossingPerimeters {
 public:
@@ -117,13 +120,16 @@ public:
         m_enable_loop_clipping(true), 
         m_enable_cooling_markers(false), 
         m_enable_extrusion_role_markers(false), 
-        m_enable_analyzer_markers(false),
+        m_enable_analyzer(false),
         m_layer_count(0),
         m_layer_index(-1), 
         m_layer(nullptr), 
         m_volumetric_speed(0),
         m_last_pos_defined(false),
         m_last_extrusion_role(erNone),
+        m_last_mm3_per_mm(GCodeAnalyzer::Default_mm3_per_mm),
+        m_last_width(GCodeAnalyzer::Default_Width),
+        m_last_height(GCodeAnalyzer::Default_Height),
         m_brim_done(false),
         m_second_layer_things_done(false),
         m_last_obj_copy(nullptr, Point(std::numeric_limits<coord_t>::max(), std::numeric_limits<coord_t>::max()))
@@ -131,7 +137,7 @@ public:
     ~GCode() {}
 
     // throws std::runtime_exception
-    void            do_export(Print *print, const char *path);
+    void            do_export(Print *print, const char *path, GCodePreviewData *preview_data = nullptr);
 
     // Exported for the helper classes (OozePrevention, Wipe) and for the Perl binding for unit tests.
     const Pointf&   origin() const { return m_origin; }
@@ -154,8 +160,11 @@ public:
     void            set_layer_count(unsigned int value) { m_layer_count = value; }
     void            apply_print_config(const PrintConfig &print_config);
 
+    // append full config to the given string
+    static void append_full_config(const Print& print, std::string& str);
+
 protected:
-    void            _do_export(Print &print, FILE *file);
+    void            _do_export(Print &print, FILE *file, GCodePreviewData *preview_data);
 
     // Object and support extrusions of the same PrintObject at the same print_z.
     struct LayerToPrint
@@ -240,9 +249,10 @@ protected:
     // Markers for the Pressure Equalizer to recognize the extrusion type.
     // The Pressure Equalizer removes the markers from the final G-code.
     bool                                m_enable_extrusion_role_markers;
-    // Extended markers for the G-code Analyzer.
+    // Enableds the G-code Analyzer.
+    // Extended markers will be added during G-code generation.
     // The G-code Analyzer will remove these comments from the final G-code.
-    bool                                m_enable_analyzer_markers;
+    bool                                m_enable_analyzer;
     // How many times will change_layer() be called?
     // change_layer() will update the progress bar.
     unsigned int                        m_layer_count;
@@ -255,6 +265,10 @@ protected:
     double                              m_volumetric_speed;
     // Support for the extrusion role markers. Which marker is active?
     ExtrusionRole                       m_last_extrusion_role;
+    // Support for G-Code Analyzer
+    double                              m_last_mm3_per_mm;
+    float                               m_last_width;
+    float                               m_last_height;
 
     Point                               m_last_pos;
     bool                                m_last_pos_defined;
@@ -273,6 +287,24 @@ protected:
     // Index of a last object copy extruded.
     std::pair<const PrintObject*, Point> m_last_obj_copy;
 
+    // Time estimator
+    GCodeTimeEstimator m_time_estimator;
+
+    // Analyzer
+    GCodeAnalyzer m_analyzer;
+
+    // Write a string into a file.
+    void _write(FILE* file, const std::string& what) { this->_write(file, what.c_str()); }
+    void _write(FILE* file, const char *what);
+
+    // Write a string into a file. 
+    // Add a newline, if the string does not end with a newline already.
+    // Used to export a custom G-code section processed by the PlaceholderParser.
+    void _writeln(FILE* file, const std::string& what);
+
+    // Formats and write into a file the given data. 
+    void _write_format(FILE* file, const char* format, ...);
+
     std::string _extrude(const ExtrusionPath &path, std::string description = "", double speed = -1);
     void _print_first_layer_bed_temperature(FILE *file, Print &print, const std::string &gcode, unsigned int first_printing_extruder_id, bool wait);
     void _print_first_layer_extruder_temperatures(FILE *file, Print &print, const std::string &gcode, unsigned int first_printing_extruder_id, bool wait);
diff --git a/xs/src/libslic3r/GCode/Analyzer.cpp b/xs/src/libslic3r/GCode/Analyzer.cpp
index ab2955eb5..f8d196f23 100644
--- a/xs/src/libslic3r/GCode/Analyzer.cpp
+++ b/xs/src/libslic3r/GCode/Analyzer.cpp
@@ -4,323 +4,790 @@
 
 #include "../libslic3r.h"
 #include "../PrintConfig.hpp"
+#include "Print.hpp"
 
 #include "Analyzer.hpp"
+#include "PreviewData.hpp"
+
+static const std::string AXIS_STR = "XYZE";
+static const float MMMIN_TO_MMSEC = 1.0f / 60.0f;
+static const float INCHES_TO_MM = 25.4f;
+static const float DEFAULT_FEEDRATE = 0.0f;
+static const unsigned int DEFAULT_EXTRUDER_ID = 0;
+static const Slic3r::Pointf3 DEFAULT_START_POSITION = Slic3r::Pointf3(0.0f, 0.0f, 0.0f);
+static const float DEFAULT_START_EXTRUSION = 0.0f;
 
 namespace Slic3r {
 
-void GCodeMovesDB::reset()
+const std::string GCodeAnalyzer::Extrusion_Role_Tag = "_ANALYZER_EXTR_ROLE:";
+const std::string GCodeAnalyzer::Mm3_Per_Mm_Tag = "_ANALYZER_MM3_PER_MM:";
+const std::string GCodeAnalyzer::Width_Tag = "_ANALYZER_WIDTH:";
+const std::string GCodeAnalyzer::Height_Tag = "_ANALYZER_HEIGHT:";
+
+const double GCodeAnalyzer::Default_mm3_per_mm = 0.0;
+const float GCodeAnalyzer::Default_Width = 0.0f;
+const float GCodeAnalyzer::Default_Height = 0.0f;
+
+GCodeAnalyzer::Metadata::Metadata()
+    : extrusion_role(erNone)
+    , extruder_id(DEFAULT_EXTRUDER_ID)
+    , mm3_per_mm(GCodeAnalyzer::Default_mm3_per_mm)
+    , width(GCodeAnalyzer::Default_Width)
+    , height(GCodeAnalyzer::Default_Height)
+    , feedrate(DEFAULT_FEEDRATE)
 {
-    for (size_t i = 0; i < m_layers.size(); ++ i)
-        delete m_layers[i];
-    m_layers.clear();
 }
 
-GCodeAnalyzer::GCodeAnalyzer(const Slic3r::GCodeConfig *config) : 
-    m_config(config)
+GCodeAnalyzer::Metadata::Metadata(ExtrusionRole extrusion_role, unsigned int extruder_id, double mm3_per_mm, float width, float height, float feedrate)
+    : extrusion_role(extrusion_role)
+    , extruder_id(extruder_id)
+    , mm3_per_mm(mm3_per_mm)
+    , width(width)
+    , height(height)
+    , feedrate(feedrate)
+{
+}
+
+bool GCodeAnalyzer::Metadata::operator != (const GCodeAnalyzer::Metadata& other) const
+{
+    if (extrusion_role != other.extrusion_role)
+        return true;
+
+    if (extruder_id != other.extruder_id)
+        return true;
+
+    if (mm3_per_mm != other.mm3_per_mm)
+        return true;
+
+    if (width != other.width)
+        return true;
+
+    if (height != other.height)
+        return true;
+
+    if (feedrate != other.feedrate)
+        return true;
+
+    return false;
+}
+
+GCodeAnalyzer::GCodeMove::GCodeMove(GCodeMove::EType type, ExtrusionRole extrusion_role, unsigned int extruder_id, double mm3_per_mm, float width, float height, float feedrate, const Pointf3& start_position, const Pointf3& end_position, float delta_extruder)
+    : type(type)
+    , data(extrusion_role, extruder_id, mm3_per_mm, width, height, feedrate)
+    , start_position(start_position)
+    , end_position(end_position)
+    , delta_extruder(delta_extruder)
+{
+}
+
+GCodeAnalyzer::GCodeMove::GCodeMove(GCodeMove::EType type, const GCodeAnalyzer::Metadata& data, const Pointf3& start_position, const Pointf3& end_position, float delta_extruder)
+    : type(type)
+    , data(data)
+    , start_position(start_position)
+    , end_position(end_position)
+    , delta_extruder(delta_extruder)
+{
+}
+
+GCodeAnalyzer::GCodeAnalyzer()
 {
     reset();
-    m_moves = new GCodeMovesDB();
-}
-
-GCodeAnalyzer::~GCodeAnalyzer()
-{
-    delete m_moves;
 }
 
 void GCodeAnalyzer::reset()
 {
-    output_buffer.clear();
-    output_buffer_length = 0;
+    _set_units(Millimeters);
+    _set_positioning_xyz_type(Absolute);
+    _set_positioning_e_type(Relative);
+    _set_extrusion_role(erNone);
+    _set_extruder_id(DEFAULT_EXTRUDER_ID);
+    _set_mm3_per_mm(Default_mm3_per_mm);
+    _set_width(Default_Width);
+    _set_height(Default_Height);
+    _set_feedrate(DEFAULT_FEEDRATE);
+    _set_start_position(DEFAULT_START_POSITION);
+    _set_start_extrusion(DEFAULT_START_EXTRUSION);
+    _reset_axes_position();
 
-    m_current_extruder = 0;
-    // Zero the position of the XYZE axes + the current feed
-    memset(m_current_pos, 0, sizeof(float) * 5);
-    m_current_extrusion_role = erNone;
-    m_current_extrusion_width = 0;
-    m_current_extrusion_height = 0;
-    // Expect the first command to fill the nozzle (deretract).
-    m_retracted = true;
-    m_moves->reset();
+    m_moves_map.clear();
 }
 
-const char* GCodeAnalyzer::process(const char *szGCode, bool flush)
+const std::string& GCodeAnalyzer::process_gcode(const std::string& gcode)
 {
-    // Reset length of the output_buffer.
-    output_buffer_length = 0;
+    m_process_output = "";
 
-    if (szGCode != 0) {
-        const char *p = szGCode;
-        while (*p != 0) {
-            // Find end of the line.
-            const char *endl = p;
-            // Slic3r always generates end of lines in a Unix style.
-            for (; *endl != 0 && *endl != '\n'; ++ endl) ;
-            // Process a G-code line, store it into the provided GCodeLine object.
-            bool should_output = process_line(p, endl - p);
-            if (*endl == '\n') 
-                ++ endl;
-            if (should_output)
-                push_to_output(p, endl - p);
-            p = endl;
-        }
-    }
+    m_parser.parse_buffer(gcode,
+        [this](GCodeReader& reader, const GCodeReader::GCodeLine& line)
+    { this->_process_gcode_line(reader, line); });
 
-    return output_buffer.data();
+    return m_process_output;
 }
 
-// Is a white space?
-static inline bool is_ws(const char c) { return c == ' ' || c == '\t'; }
-// Is it an end of line? Consider a comment to be an end of line as well.
-static inline bool is_eol(const char c) { return c == 0 || c == '\r' || c == '\n' || c == ';'; };
-// Is it a white space or end of line?
-static inline bool is_ws_or_eol(const char c) { return is_ws(c) || is_eol(c); };
-
-// Eat whitespaces.
-static void eatws(const char *&line)
+void GCodeAnalyzer::calc_gcode_preview_data(GCodePreviewData& preview_data)
 {
-    while (is_ws(*line)) 
-        ++ line;
+    // resets preview data
+    preview_data.reset();
+
+    // calculates extrusion layers
+    _calc_gcode_preview_extrusion_layers(preview_data);
+
+    // calculates travel
+    _calc_gcode_preview_travel(preview_data);
+
+    // calculates retractions
+    _calc_gcode_preview_retractions(preview_data);
+
+    // calculates unretractions
+    _calc_gcode_preview_unretractions(preview_data);
 }
 
-// Parse an int starting at the current position of a line.
-// If succeeded, the line pointer is advanced.
-static inline int parse_int(const char *&line)
+bool GCodeAnalyzer::is_valid_extrusion_role(ExtrusionRole role)
 {
-    char *endptr = NULL;
-    long result = strtol(line, &endptr, 10);
-    if (endptr == NULL || !is_ws_or_eol(*endptr))
-        throw std::runtime_error("GCodeAnalyzer: Error parsing an int");
-    line = endptr;
-    return int(result);
-};
+    return ((erPerimeter <= role) && (role < erMixed));
+}
 
-// Parse an int starting at the current position of a line.
-// If succeeded, the line pointer is advanced.
-static inline float parse_float(const char *&line)
+void GCodeAnalyzer::_process_gcode_line(GCodeReader&, const GCodeReader::GCodeLine& line)
 {
-    char *endptr = NULL;
-    float result = strtof(line, &endptr);
-    if (endptr == NULL || !is_ws_or_eol(*endptr))
-        throw std::runtime_error("GCodeAnalyzer: Error parsing a float");
-    line = endptr;
-    return result;
-};
+    // processes 'special' comments contained in line
+    if (_process_tags(line))
+        return;
 
-#define EXTRUSION_ROLE_TAG ";_EXTRUSION_ROLE:"
-bool GCodeAnalyzer::process_line(const char *line, const size_t len)
-{
-    if (strncmp(line, EXTRUSION_ROLE_TAG, strlen(EXTRUSION_ROLE_TAG)) == 0) {
-        line += strlen(EXTRUSION_ROLE_TAG);
-        int role = atoi(line);
-        this->m_current_extrusion_role = ExtrusionRole(role);
-        return false;
-    }
+    // sets new start position/extrusion
+    _set_start_position(_get_end_position());
+    _set_start_extrusion(_get_axis_position(E));
 
-/*
-    // Set the type, copy the line to the buffer.
-    buf.type = GCODE_MOVE_TYPE_OTHER;
-    buf.modified = false;
-    if (buf.raw.size() < len + 1)
-        buf.raw.assign(line, line + len + 1);
-    else
-        memcpy(buf.raw.data(), line, len);
-    buf.raw[len] = 0;
-    buf.raw_length = len;
-
-    memcpy(buf.pos_start, m_current_pos, sizeof(float)*5);
-    memcpy(buf.pos_end, m_current_pos, sizeof(float)*5);
-    memset(buf.pos_provided, 0, 5);
-
-    buf.volumetric_extrusion_rate = 0.f;
-    buf.volumetric_extrusion_rate_start = 0.f;
-    buf.volumetric_extrusion_rate_end = 0.f;
-    buf.max_volumetric_extrusion_rate_slope_positive = 0.f;
-    buf.max_volumetric_extrusion_rate_slope_negative = 0.f;
-	buf.extrusion_role = m_current_extrusion_role;
-
-    // Parse the G-code line, store the result into the buf.
-    switch (toupper(*line ++)) {
-    case 'G': {
-        int gcode = parse_int(line);
-        eatws(line);
-        switch (gcode) {
-        case 0:
-        case 1:
+    // processes 'normal' gcode lines
+    std::string cmd = line.cmd();
+    if (cmd.length() > 1)
+    {
+        switch (::toupper(cmd[0]))
         {
-            // G0, G1: A FFF 3D printer does not make a difference between the two.
-            float new_pos[5];
-            memcpy(new_pos, m_current_pos, sizeof(float)*5);
-            bool  changed[5] = { false, false, false, false, false };
-            while (!is_eol(*line)) {
-                char axis = toupper(*line++);
-                int  i = -1;
-                switch (axis) {
-                case 'X':
-                case 'Y':
-                case 'Z':
-                    i = axis - 'X';
-                    break;
-                case 'E':
-                    i = 3;
-                    break;
-                case 'F':
-                    i = 4;
-                    break;
-                default:
-                    assert(false);
-                }
-                if (i == -1)
-                    throw std::runtime_error(std::string("GCodeAnalyzer: Invalid axis for G0/G1: ") + axis);
-                buf.pos_provided[i] = true;
-                new_pos[i] = parse_float(line);
-                if (i == 3 && m_config->use_relative_e_distances.value)
-                    new_pos[i] += m_current_pos[i];
-                changed[i] = new_pos[i] != m_current_pos[i];
-                eatws(line);
-            }
-            if (changed[3]) {
-                // Extrusion, retract or unretract.
-                float diff = new_pos[3] - m_current_pos[3];
-                if (diff < 0) {
-                    buf.type = GCODE_MOVE_TYPE_RETRACT;
-                    m_retracted = true;
-                } else if (! changed[0] && ! changed[1] && ! changed[2]) {
-                    // assert(m_retracted);
-                    buf.type = GCODE_MOVE_TYPE_UNRETRACT;
-                    m_retracted = false;
-                } else {
-                    assert(changed[0] || changed[1]);
-                    // Moving in XY plane.
-                    buf.type = GCODE_MOVE_TYPE_EXTRUDE;
-                    // Calculate the volumetric extrusion rate.
-                    float diff[4];
-                    for (size_t i = 0; i < 4; ++ i)
-                        diff[i] = new_pos[i] - m_current_pos[i];
-                    // volumetric extrusion rate = A_filament * F_xyz * L_e / L_xyz [mm^3/min]
-                    float len2 = diff[0]*diff[0]+diff[1]*diff[1]+diff[2]*diff[2];
-                    float rate = m_filament_crossections[m_current_extruder] * new_pos[4] * sqrt((diff[3]*diff[3])/len2);
-                    buf.volumetric_extrusion_rate       = rate;
-                    buf.volumetric_extrusion_rate_start = rate;
-                    buf.volumetric_extrusion_rate_end   = rate;
-                    m_stat.update(rate, sqrt(len2));
-                    if (rate < 10.f) {
-                    	printf("Extremely low flow rate: %f\n", rate);
+        case 'G':
+            {
+                switch (::atoi(&cmd[1]))
+                {
+                case 1: // Move
+                    {
+                        _processG1(line);
+                        break;
+                    }
+                case 22: // Firmware controlled Retract
+                    {
+                        _processG22(line);
+                        break;
+                    }
+                case 23: // Firmware controlled Unretract
+                    {
+                        _processG23(line);
+                        break;
+                    }
+                case 90: // Set to Absolute Positioning
+                    {
+                        _processG90(line);
+                        break;
+                    }
+                case 91: // Set to Relative Positioning
+                    {
+                        _processG91(line);
+                        break;
+                    }
+                case 92: // Set Position
+                    {
+                        _processG92(line);
+                        break;
                     }
                 }
-            } else if (changed[0] || changed[1] || changed[2]) {
-                // Moving without extrusion.
-                buf.type = GCODE_MOVE_TYPE_MOVE;
+
+                break;
             }
-            memcpy(m_current_pos, new_pos, sizeof(float) * 5);
-            break;
-        }
-        case 92:
-        {
-            // G92 : Set Position
-            // Set a logical coordinate position to a new value without actually moving the machine motors.
-            // Which axes to set?
-            bool set = false;
-            while (!is_eol(*line)) {
-                char axis = toupper(*line++);
-                switch (axis) {
-                case 'X':
-                case 'Y':
-                case 'Z':
-                    m_current_pos[axis - 'X'] = (!is_ws_or_eol(*line)) ? parse_float(line) : 0.f;
-                    set = true;
-                    break;
-                case 'E':
-                    m_current_pos[3] = (!is_ws_or_eol(*line)) ? parse_float(line) : 0.f;
-                    set = true;
-                    break;
-                default:
-                    throw std::runtime_error(std::string("GCodeAnalyzer: Incorrect axis in a G92 G-code: ") + axis);
+        case 'M':
+            {
+                switch (::atoi(&cmd[1]))
+                {
+                case 82: // Set extruder to absolute mode
+                    {
+                        _processM82(line);
+                        break;
+                    }
+                case 83: // Set extruder to relative mode
+                    {
+                        _processM83(line);
+                        break;
+                    }
                 }
-                eatws(line);
+
+                break;
+            }
+        case 'T': // Select Tools
+            {
+                _processT(line);
+                break;
             }
-            assert(set);
-            break;
         }
-        case 10:
-        case 22:
-            // Firmware retract.
-            buf.type = GCODE_MOVE_TYPE_RETRACT;
-            m_retracted = true;
-            break;
-        case 11:
-        case 23:
-            // Firmware unretract.
-            buf.type = GCODE_MOVE_TYPE_UNRETRACT;
-            m_retracted = false;
-            break;
-        default:
-            // Ignore the rest.
-        break;
-        }
-        break;
-    }
-    case 'M': {
-        int mcode = parse_int(line);
-        eatws(line);
-        switch (mcode) {
-        default:
-            // Ignore the rest of the M-codes.
-        break;
-        }
-        break;
-    }
-    case 'T':
-    {
-        // Activate an extruder head.
-        int new_extruder = parse_int(line);
-        if (new_extruder != m_current_extruder) {
-            m_current_extruder = new_extruder;
-            m_retracted = true;
-            buf.type = GCODE_MOVE_TYPE_TOOL_CHANGE;
-        } else {
-            buf.type = GCODE_MOVE_TYPE_NOOP;
-        }
-        break;
-    }
     }
 
-    buf.extruder_id = m_current_extruder;
-    memcpy(buf.pos_end, m_current_pos, sizeof(float)*5);
-*/
-	return true;
+    // puts the line back into the gcode
+    m_process_output += line.raw() + "\n";
 }
 
-void GCodeAnalyzer::push_to_output(const char *text, const size_t len, bool add_eol)
+// Returns the new absolute position on the given axis in dependence of the given parameters
+float axis_absolute_position_from_G1_line(GCodeAnalyzer::EAxis axis, const GCodeReader::GCodeLine& lineG1, GCodeAnalyzer::EUnits units, GCodeAnalyzer::EPositioningType type, float current_absolute_position)
 {
-    // New length of the output buffer content.
-    size_t len_new = output_buffer_length + len + 1;
-    if (add_eol)
-        ++ len_new;
+    float lengthsScaleFactor = (units == GCodeAnalyzer::Inches) ? INCHES_TO_MM : 1.0f;
+    if (lineG1.has(Slic3r::Axis(axis)))
+    {
+        float ret = lineG1.value(Slic3r::Axis(axis)) * lengthsScaleFactor;
+        return (type == GCodeAnalyzer::Absolute) ? ret : current_absolute_position + ret;
+    }
+    else
+        return current_absolute_position;
+}
 
-    // Resize the output buffer to a power of 2 higher than the required memory.
-    if (output_buffer.size() < len_new) {
-        size_t v = len_new;
-        // Compute the next highest power of 2 of 32-bit v
-        // http://graphics.stanford.edu/~seander/bithacks.html
-        v--;
-        v |= v >> 1;
-        v |= v >> 2;
-        v |= v >> 4;
-        v |= v >> 8;
-        v |= v >> 16;
-        v++;
-        output_buffer.resize(v);
+void GCodeAnalyzer::_processG1(const GCodeReader::GCodeLine& line)
+{
+    // updates axes positions from line
+    EUnits units = _get_units();
+    float new_pos[Num_Axis];
+    for (unsigned char a = X; a < Num_Axis; ++a)
+    {
+        new_pos[a] = axis_absolute_position_from_G1_line((EAxis)a, line, units, (a == E) ? _get_positioning_e_type() : _get_positioning_xyz_type(), _get_axis_position((EAxis)a));
     }
 
-    // Copy the text to the output.
-    if (len != 0) {
-        memcpy(output_buffer.data() + output_buffer_length, text, len);
-        output_buffer_length += len;
+    // updates feedrate from line, if present
+    if (line.has_f())
+        _set_feedrate(line.f() * MMMIN_TO_MMSEC);
+
+    // calculates movement deltas
+    float delta_pos[Num_Axis];
+    for (unsigned char a = X; a < Num_Axis; ++a)
+    {
+        delta_pos[a] = new_pos[a] - _get_axis_position((EAxis)a);
     }
-    if (add_eol)
-        output_buffer[output_buffer_length ++] = '\n';
-    output_buffer[output_buffer_length] = 0;
+
+    // Detects move type
+    GCodeMove::EType type = GCodeMove::Noop;
+
+    if (delta_pos[E] < 0.0f)
+    {
+        if ((delta_pos[X] != 0.0f) || (delta_pos[Y] != 0.0f) || (delta_pos[Z] != 0.0f))
+            type = GCodeMove::Move;
+        else
+            type = GCodeMove::Retract;
+    }
+    else if (delta_pos[E] > 0.0f)
+    {
+        if ((delta_pos[X] == 0.0f) && (delta_pos[Y] == 0.0f) && (delta_pos[Z] == 0.0f))
+            type = GCodeMove::Unretract;
+        else if ((delta_pos[X] != 0.0f) || (delta_pos[Y] != 0.0f))
+            type = GCodeMove::Extrude;
+    }
+    else if ((delta_pos[X] != 0.0f) || (delta_pos[Y] != 0.0f) || (delta_pos[Z] != 0.0f))
+        type = GCodeMove::Move;
+
+    ExtrusionRole role = _get_extrusion_role();
+    if ((type == GCodeMove::Extrude) && ((_get_width() == 0.0f) || (_get_height() == 0.0f) || !is_valid_extrusion_role(role)))
+        type = GCodeMove::Move;
+
+    // updates axis positions
+    for (unsigned char a = X; a < Num_Axis; ++a)
+    {
+        _set_axis_position((EAxis)a, new_pos[a]);
+    }
+
+    // stores the move
+    if (type != GCodeMove::Noop)
+        _store_move(type);
+}
+
+void GCodeAnalyzer::_processG22(const GCodeReader::GCodeLine& line)
+{
+    // stores retract move
+    _store_move(GCodeMove::Retract);
+}
+
+void GCodeAnalyzer::_processG23(const GCodeReader::GCodeLine& line)
+{
+    // stores unretract move
+    _store_move(GCodeMove::Unretract);
+}
+
+void GCodeAnalyzer::_processG90(const GCodeReader::GCodeLine& line)
+{
+    _set_positioning_xyz_type(Absolute);
+}
+
+void GCodeAnalyzer::_processG91(const GCodeReader::GCodeLine& line)
+{
+    _set_positioning_xyz_type(Relative);
+}
+
+void GCodeAnalyzer::_processG92(const GCodeReader::GCodeLine& line)
+{
+    float lengthsScaleFactor = (_get_units() == Inches) ? INCHES_TO_MM : 1.0f;
+    bool anyFound = false;
+
+    if (line.has_x())
+    {
+        _set_axis_position(X, line.x() * lengthsScaleFactor);
+        anyFound = true;
+    }
+
+    if (line.has_y())
+    {
+        _set_axis_position(Y, line.y() * lengthsScaleFactor);
+        anyFound = true;
+    }
+
+    if (line.has_z())
+    {
+        _set_axis_position(Z, line.z() * lengthsScaleFactor);
+        anyFound = true;
+    }
+
+    if (line.has_e())
+    {
+        _set_axis_position(E, line.e() * lengthsScaleFactor);
+        anyFound = true;
+    }
+
+    if (!anyFound)
+    {
+        for (unsigned char a = X; a < Num_Axis; ++a)
+        {
+            _set_axis_position((EAxis)a, 0.0f);
+        }
+    }
+}
+
+void GCodeAnalyzer::_processM82(const GCodeReader::GCodeLine& line)
+{
+    _set_positioning_e_type(Absolute);
+}
+
+void GCodeAnalyzer::_processM83(const GCodeReader::GCodeLine& line)
+{
+    _set_positioning_e_type(Relative);
+}
+
+void GCodeAnalyzer::_processT(const GCodeReader::GCodeLine& line)
+{
+    std::string cmd = line.cmd();
+    if (cmd.length() > 1)
+    {
+        unsigned int id = (unsigned int)::strtol(cmd.substr(1).c_str(), nullptr, 10);
+        if (_get_extruder_id() != id)
+        {
+            _set_extruder_id(id);
+
+            // stores tool change move
+            _store_move(GCodeMove::Tool_change);
+        }
+    }
+}
+
+bool GCodeAnalyzer::_process_tags(const GCodeReader::GCodeLine& line)
+{
+    std::string comment = line.comment();
+
+    // extrusion role tag
+    size_t pos = comment.find(Extrusion_Role_Tag);
+    if (pos != comment.npos)
+    {
+        _process_extrusion_role_tag(comment, pos);
+        return true;
+    }
+
+    // mm3 per mm tag
+    pos = comment.find(Mm3_Per_Mm_Tag);
+    if (pos != comment.npos)
+    {
+        _process_mm3_per_mm_tag(comment, pos);
+        return true;
+    }
+
+    // width tag
+    pos = comment.find(Width_Tag);
+    if (pos != comment.npos)
+    {
+        _process_width_tag(comment, pos);
+        return true;
+    }
+
+    // height tag
+    pos = comment.find(Height_Tag);
+    if (pos != comment.npos)
+    {
+        _process_height_tag(comment, pos);
+        return true;
+    }
+
+    return false;
+}
+
+void GCodeAnalyzer::_process_extrusion_role_tag(const std::string& comment, size_t pos)
+{
+    int role = (int)::strtol(comment.substr(pos + Extrusion_Role_Tag.length()).c_str(), nullptr, 10);
+    if (_is_valid_extrusion_role(role))
+        _set_extrusion_role((ExtrusionRole)role);
+    else
+    {
+        // todo: show some error ?
+    }
+}
+
+void GCodeAnalyzer::_process_mm3_per_mm_tag(const std::string& comment, size_t pos)
+{
+    _set_mm3_per_mm(::strtod(comment.substr(pos + Mm3_Per_Mm_Tag.length()).c_str(), nullptr));
+}
+
+void GCodeAnalyzer::_process_width_tag(const std::string& comment, size_t pos)
+{
+    _set_width((float)::strtod(comment.substr(pos + Width_Tag.length()).c_str(), nullptr));
+}
+
+void GCodeAnalyzer::_process_height_tag(const std::string& comment, size_t pos)
+{
+    _set_height((float)::strtod(comment.substr(pos + Height_Tag.length()).c_str(), nullptr));
+}
+
+void GCodeAnalyzer::_set_units(GCodeAnalyzer::EUnits units)
+{
+    m_state.units = units;
+}
+
+GCodeAnalyzer::EUnits GCodeAnalyzer::_get_units() const
+{
+    return m_state.units;
+}
+
+void GCodeAnalyzer::_set_positioning_xyz_type(GCodeAnalyzer::EPositioningType type)
+{
+    m_state.positioning_xyz_type = type;
+}
+
+GCodeAnalyzer::EPositioningType GCodeAnalyzer::_get_positioning_xyz_type() const
+{
+    return m_state.positioning_xyz_type;
+}
+
+void GCodeAnalyzer::_set_positioning_e_type(GCodeAnalyzer::EPositioningType type)
+{
+    m_state.positioning_e_type = type;
+}
+
+GCodeAnalyzer::EPositioningType GCodeAnalyzer::_get_positioning_e_type() const
+{
+    return m_state.positioning_e_type;
+}
+
+void GCodeAnalyzer::_set_extrusion_role(ExtrusionRole extrusion_role)
+{
+    m_state.data.extrusion_role = extrusion_role;
+}
+
+ExtrusionRole GCodeAnalyzer::_get_extrusion_role() const
+{
+    return m_state.data.extrusion_role;
+}
+
+void GCodeAnalyzer::_set_extruder_id(unsigned int id)
+{
+    m_state.data.extruder_id = id;
+}
+
+unsigned int GCodeAnalyzer::_get_extruder_id() const
+{
+    return m_state.data.extruder_id;
+}
+
+void GCodeAnalyzer::_set_mm3_per_mm(double value)
+{
+    m_state.data.mm3_per_mm = value;
+}
+
+double GCodeAnalyzer::_get_mm3_per_mm() const
+{
+    return m_state.data.mm3_per_mm;
+}
+
+void GCodeAnalyzer::_set_width(float width)
+{
+    m_state.data.width = width;
+}
+
+float GCodeAnalyzer::_get_width() const
+{
+    return m_state.data.width;
+}
+
+void GCodeAnalyzer::_set_height(float height)
+{
+    m_state.data.height = height;
+}
+
+float GCodeAnalyzer::_get_height() const
+{
+    return m_state.data.height;
+}
+
+void GCodeAnalyzer::_set_feedrate(float feedrate_mm_sec)
+{
+    m_state.data.feedrate = feedrate_mm_sec;
+}
+
+float GCodeAnalyzer::_get_feedrate() const
+{
+    return m_state.data.feedrate;
+}
+
+void GCodeAnalyzer::_set_axis_position(EAxis axis, float position)
+{
+    m_state.position[axis] = position;
+}
+
+float GCodeAnalyzer::_get_axis_position(EAxis axis) const
+{
+    return m_state.position[axis];
+}
+
+void GCodeAnalyzer::_reset_axes_position()
+{
+    ::memset((void*)m_state.position, 0, Num_Axis * sizeof(float));
+}
+
+void GCodeAnalyzer::_set_start_position(const Pointf3& position)
+{
+    m_state.start_position = position;
+}
+
+const Pointf3& GCodeAnalyzer::_get_start_position() const
+{
+    return m_state.start_position;
+}
+
+void GCodeAnalyzer::_set_start_extrusion(float extrusion)
+{
+    m_state.start_extrusion = extrusion;
+}
+
+float GCodeAnalyzer::_get_start_extrusion() const
+{
+    return m_state.start_extrusion;
+}
+
+float GCodeAnalyzer::_get_delta_extrusion() const
+{
+    return _get_axis_position(E) - m_state.start_extrusion;
+}
+
+Pointf3 GCodeAnalyzer::_get_end_position() const
+{
+    return Pointf3(m_state.position[X], m_state.position[Y], m_state.position[Z]);
+}
+
+void GCodeAnalyzer::_store_move(GCodeAnalyzer::GCodeMove::EType type)
+{
+    // if type non mapped yet, map it
+    TypeToMovesMap::iterator it = m_moves_map.find(type);
+    if (it == m_moves_map.end())
+        it = m_moves_map.insert(TypeToMovesMap::value_type(type, GCodeMovesList())).first;
+
+    // store move
+    it->second.emplace_back(type, _get_extrusion_role(), _get_extruder_id(), _get_mm3_per_mm(), _get_width(), _get_height(), _get_feedrate(), _get_start_position(), _get_end_position(), _get_delta_extrusion());
+}
+
+bool GCodeAnalyzer::_is_valid_extrusion_role(int value) const
+{
+    return ((int)erNone <= value) && (value <= (int)erMixed);
+}
+
+void GCodeAnalyzer::_calc_gcode_preview_extrusion_layers(GCodePreviewData& preview_data)
+{
+    struct Helper
+    {
+        static GCodePreviewData::Extrusion::Layer& get_layer_at_z(GCodePreviewData::Extrusion::LayersList& layers, float z)
+        {
+            for (GCodePreviewData::Extrusion::Layer& layer : layers)
+            {
+                // if layer found, return it
+                if (layer.z == z)
+                    return layer;
+            }
+
+            // if layer not found, create and return it
+            layers.emplace_back(z, ExtrusionPaths());
+            return layers.back();
+        }
+
+        static void store_polyline(const Polyline& polyline, const Metadata& data, float z, GCodePreviewData& preview_data)
+        {
+            // if the polyline is valid, create the extrusion path from it and store it
+            if (polyline.is_valid())
+            {
+                ExtrusionPath path(data.extrusion_role, data.mm3_per_mm, data.width, data.height);
+                path.polyline = polyline;
+                path.feedrate = data.feedrate;
+                path.extruder_id = data.extruder_id;
+
+                get_layer_at_z(preview_data.extrusion.layers, z).paths.push_back(path);
+            }
+        }
+    };
+
+    TypeToMovesMap::iterator extrude_moves = m_moves_map.find(GCodeMove::Extrude);
+    if (extrude_moves == m_moves_map.end())
+        return;
+
+    Metadata data;
+    float z = FLT_MAX;
+    Polyline polyline;
+    Pointf3 position(FLT_MAX, FLT_MAX, FLT_MAX);
+    GCodePreviewData::Range height_range;
+    GCodePreviewData::Range width_range;
+    GCodePreviewData::Range feedrate_range;
+
+    // constructs the polylines while traversing the moves
+    for (const GCodeMove& move : extrude_moves->second)
+    {
+        if ((data != move.data) || (data.feedrate != move.data.feedrate) || (z != move.start_position.z) || (position != move.start_position))
+        {
+            // store current polyline
+            polyline.remove_duplicate_points();
+            Helper::store_polyline(polyline, data, z, preview_data);
+
+            // reset current polyline
+            polyline = Polyline();
+
+            // add both vertices of the move
+            polyline.append(Point(scale_(move.start_position.x), scale_(move.start_position.y)));
+            polyline.append(Point(scale_(move.end_position.x), scale_(move.end_position.y)));
+
+            // update current values
+            data = move.data;
+            z = move.start_position.z;
+            height_range.update_from(move.data.height);
+            width_range.update_from(move.data.width);
+            feedrate_range.update_from(move.data.feedrate);
+        }
+        else
+            // append end vertex of the move to current polyline
+            polyline.append(Point(scale_(move.end_position.x), scale_(move.end_position.y)));
+
+        // update current values
+        position = move.end_position;
+    }
+
+    // store last polyline
+    polyline.remove_duplicate_points();
+    Helper::store_polyline(polyline, data, z, preview_data);
+
+    // updates preview ranges data
+    preview_data.extrusion.ranges.height.set_from(height_range);
+    preview_data.extrusion.ranges.width.set_from(width_range);
+    preview_data.extrusion.ranges.feedrate.set_from(feedrate_range);
+}
+
+void GCodeAnalyzer::_calc_gcode_preview_travel(GCodePreviewData& preview_data)
+{
+    struct Helper
+    {
+        static void store_polyline(const Polyline3& polyline, GCodePreviewData::Travel::EType type, GCodePreviewData::Travel::Polyline::EDirection direction, 
+            float feedrate, unsigned int extruder_id, GCodePreviewData& preview_data)
+        {
+            // if the polyline is valid, store it
+            if (polyline.is_valid())
+                preview_data.travel.polylines.emplace_back(type, direction, feedrate, extruder_id, polyline);
+        }
+    };
+
+    TypeToMovesMap::iterator travel_moves = m_moves_map.find(GCodeMove::Move);
+    if (travel_moves == m_moves_map.end())
+        return;
+
+    Polyline3 polyline;
+    Pointf3 position(FLT_MAX, FLT_MAX, FLT_MAX);
+    GCodePreviewData::Travel::EType type = GCodePreviewData::Travel::Num_Types;
+    GCodePreviewData::Travel::Polyline::EDirection direction = GCodePreviewData::Travel::Polyline::Num_Directions;
+    float feedrate = FLT_MAX;
+    unsigned int extruder_id = -1;
+
+    // constructs the polylines while traversing the moves
+    for (const GCodeMove& move : travel_moves->second)
+    {
+        GCodePreviewData::Travel::EType move_type = (move.delta_extruder < 0.0f) ? GCodePreviewData::Travel::Retract : ((move.delta_extruder > 0.0f) ? GCodePreviewData::Travel::Extrude : GCodePreviewData::Travel::Move);
+        GCodePreviewData::Travel::Polyline::EDirection move_direction = ((move.start_position.x != move.end_position.x) || (move.start_position.y != move.end_position.y)) ? GCodePreviewData::Travel::Polyline::Generic : GCodePreviewData::Travel::Polyline::Vertical;
+
+        if ((type != move_type) || (direction != move_direction) || (feedrate != move.data.feedrate) || (position != move.start_position) || (extruder_id != move.data.extruder_id))
+        {
+            // store current polyline
+            polyline.remove_duplicate_points();
+            Helper::store_polyline(polyline, type, direction, feedrate, extruder_id, preview_data);
+
+            // reset current polyline
+            polyline = Polyline3();
+
+            // add both vertices of the move
+            polyline.append(Point3(scale_(move.start_position.x), scale_(move.start_position.y), scale_(move.start_position.z)));
+            polyline.append(Point3(scale_(move.end_position.x), scale_(move.end_position.y), scale_(move.end_position.z)));
+        }
+        else
+            // append end vertex of the move to current polyline
+            polyline.append(Point3(scale_(move.end_position.x), scale_(move.end_position.y), scale_(move.end_position.z)));
+
+        // update current values
+        position = move.end_position;
+        type = move_type;
+        feedrate = move.data.feedrate;
+        extruder_id = move.data.extruder_id;
+    }
+
+    // store last polyline
+    polyline.remove_duplicate_points();
+    Helper::store_polyline(polyline, type, direction, feedrate, extruder_id, preview_data);
+}
+
+void GCodeAnalyzer::_calc_gcode_preview_retractions(GCodePreviewData& preview_data)
+{
+    TypeToMovesMap::iterator retraction_moves = m_moves_map.find(GCodeMove::Retract);
+    if (retraction_moves == m_moves_map.end())
+        return;
+
+    for (const GCodeMove& move : retraction_moves->second)
+    {
+        // store position
+        Point3 position(scale_(move.start_position.x), scale_(move.start_position.y), scale_(move.start_position.z));
+        preview_data.retraction.positions.emplace_back(position, move.data.width, move.data.height);
+    }
+}
+
+void GCodeAnalyzer::_calc_gcode_preview_unretractions(GCodePreviewData& preview_data)
+{
+    TypeToMovesMap::iterator unretraction_moves = m_moves_map.find(GCodeMove::Unretract);
+    if (unretraction_moves == m_moves_map.end())
+        return;
+
+    for (const GCodeMove& move : unretraction_moves->second)
+    {
+        // store position
+        Point3 position(scale_(move.start_position.x), scale_(move.start_position.y), scale_(move.start_position.z));
+        preview_data.unretraction.positions.emplace_back(position, move.data.width, move.data.height);
+    }
+}
+
+GCodePreviewData::Color operator + (const GCodePreviewData::Color& c1, const GCodePreviewData::Color& c2)
+{
+    return GCodePreviewData::Color(clamp(0.0f, 1.0f, c1.rgba[0] + c2.rgba[0]),
+        clamp(0.0f, 1.0f, c1.rgba[1] + c2.rgba[1]),
+        clamp(0.0f, 1.0f, c1.rgba[2] + c2.rgba[2]),
+        clamp(0.0f, 1.0f, c1.rgba[3] + c2.rgba[3]));
+}
+
+GCodePreviewData::Color operator * (float f, const GCodePreviewData::Color& color)
+{
+    return GCodePreviewData::Color(clamp(0.0f, 1.0f, f * color.rgba[0]),
+        clamp(0.0f, 1.0f, f * color.rgba[1]),
+        clamp(0.0f, 1.0f, f * color.rgba[2]),
+        clamp(0.0f, 1.0f, f * color.rgba[3]));
 }
 
 } // namespace Slic3r
diff --git a/xs/src/libslic3r/GCode/Analyzer.hpp b/xs/src/libslic3r/GCode/Analyzer.hpp
index 9e84e33c4..7939d432d 100644
--- a/xs/src/libslic3r/GCode/Analyzer.hpp
+++ b/xs/src/libslic3r/GCode/Analyzer.hpp
@@ -1,152 +1,227 @@
-#ifndef slic3r_GCode_PressureEqualizer_hpp_
-#define slic3r_GCode_PressureEqualizer_hpp_
+#ifndef slic3r_GCode_Analyzer_hpp_
+#define slic3r_GCode_Analyzer_hpp_
 
 #include "../libslic3r.h"
 #include "../PrintConfig.hpp"
 #include "../ExtrusionEntity.hpp"
 
+#include "Point.hpp"
+#include "GCodeReader.hpp"
+
 namespace Slic3r {
 
-enum GCodeMoveType
-{
-    GCODE_MOVE_TYPE_NOOP,
-    GCODE_MOVE_TYPE_RETRACT,
-    GCODE_MOVE_TYPE_UNRETRACT,
-    GCODE_MOVE_TYPE_TOOL_CHANGE,
-    GCODE_MOVE_TYPE_MOVE,
-    GCODE_MOVE_TYPE_EXTRUDE,
-};
+class GCodePreviewData;
 
-// For visualization purposes, for the purposes of the G-code analysis and timing.
-// The size of this structure is 56B.
-// Keep the size of this structure as small as possible, because all moves of a complete print
-// may be held in RAM.
-struct GCodeMove
-{
-    bool        moving_xy(const float* pos_start)   const { return fabs(pos_end[0] - pos_start[0]) > 0.f || fabs(pos_end[1] - pos_start[1]) > 0.f; }
-    bool        moving_xy()                         const { return moving_xy(get_pos_start()); }
-    bool        moving_z (const float* pos_start)   const { return fabs(pos_end[2] - pos_start[2]) > 0.f; }
-    bool        moving_z ()                         const { return moving_z(get_pos_start()); }
-    bool        extruding(const float* pos_start)   const { return moving_xy() && pos_end[3] > pos_start[3]; }
-    bool        extruding()                         const { return extruding(get_pos_start()); }
-    bool        retracting(const float* pos_start)  const { return pos_end[3] < pos_start[3]; }
-    bool        retracting()                        const { return retracting(get_pos_start()); }    
-    bool        deretracting(const float* pos_start)  const { return ! moving_xy() && pos_end[3] > pos_start[3]; }
-    bool        deretracting()                      const { return deretracting(get_pos_start()); }
-
-    float       dist_xy2(const float* pos_start)    const { return (pos_end[0] - pos_start[0]) * (pos_end[0] - pos_start[0]) + (pos_end[1] - pos_start[1]) * (pos_end[1] - pos_start[1]); }
-    float       dist_xy2()                          const { return dist_xy2(get_pos_start()); }
-    float       dist_xyz2(const float* pos_start)   const { return (pos_end[0] - pos_start[0]) * (pos_end[0] - pos_start[0]) + (pos_end[1] - pos_start[1]) * (pos_end[1] - pos_start[1]) + (pos_end[2] - pos_start[2]) * (pos_end[2] - pos_start[2]); }
-    float       dist_xyz2()                         const { return dist_xyz2(get_pos_start()); }
-
-    float       dist_xy(const float* pos_start)     const { return sqrt(dist_xy2(pos_start)); }
-    float       dist_xy()                           const { return dist_xy(get_pos_start()); }
-    float       dist_xyz(const float* pos_start)    const { return sqrt(dist_xyz2(pos_start)); }
-    float       dist_xyz()                          const { return dist_xyz(get_pos_start()); }
-
-    float       dist_e(const float* pos_start)      const { return fabs(pos_end[3] - pos_start[3]); }
-    float       dist_e()                            const { return dist_e(get_pos_start()); }
-
-    float       feedrate()                          const { return pos_end[4]; }
-    float       time(const float* pos_start)        const { return dist_xyz(pos_start) / feedrate(); }
-    float       time()                              const { return time(get_pos_start()); }
-    float       time_inv(const float* pos_start)    const { return feedrate() / dist_xyz(pos_start); }
-    float       time_inv()                          const { return time_inv(get_pos_start()); }
-
-    const float*    get_pos_start() const { assert(type != GCODE_MOVE_TYPE_NOOP); return this[-1].pos_end; }
-
-    // Pack the enums to conserve space. With C++x11 the allocation size could be declared for enums, but for old C++ this is the only portable way.
-    // GCodeLineType
-    uint8_t         type;
-    // Index of the active extruder.
-    uint8_t         extruder_id;
-    // ExtrusionRole
-    uint8_t         extrusion_role;
-    // For example, is it a bridge flow? Is the fan on?
-    uint8_t         flags;
-    // X,Y,Z,E,F. Storing the state of the currently active extruder only.
-    float           pos_end[5];
-    // Extrusion width, height for this segment in um.
-    uint16_t        extrusion_width;
-    uint16_t        extrusion_height;
-};
-
-typedef std::vector<GCodeMove> GCodeMoves;
-
-struct GCodeLayer
-{
-    // Index of an object printed.
-    size_t                  object_idx;
-    // Index of an object instance printed.
-    size_t                  object_instance_idx;
-    // Index of the layer printed.
-    size_t                  layer_idx;
-    // Top z coordinate of the layer printed.
-    float                   layer_z_top;
-
-    // Moves over this layer. The 0th move is always of type GCODELINETYPE_NOOP and
-    // it sets the initial position and tool for the layer.
-    GCodeMoves              moves;
-
-    // Indices into m_moves, where the tool changes happen.
-    // This is useful, if one wants to display just only a piece of the path quickly.
-    std::vector<size_t>     tool_changes;
-};
-
-typedef std::vector<GCodeLayer*> GCodeLayerPtrs;
-
-class GCodeMovesDB
-{
-public:
-    GCodeMovesDB() {};
-    ~GCodeMovesDB() { reset(); }
-    void reset();
-    GCodeLayerPtrs      m_layers;
-};
-
-// Processes a G-code to extract moves and their types.
-// This information is then used to render the print simulation colored by the extrusion type
-// or various speeds.
-// The GCodeAnalyzer is employed as a G-Code filter. It reads the G-code as it is generated,
-// parses the comments generated by Slic3r just for the analyzer, and removes these comments.
 class GCodeAnalyzer
 {
 public:
-    GCodeAnalyzer(const Slic3r::GCodeConfig *config);
-    ~GCodeAnalyzer();
+    static const std::string Extrusion_Role_Tag;
+    static const std::string Mm3_Per_Mm_Tag;
+    static const std::string Width_Tag;
+    static const std::string Height_Tag;
 
-    void reset();
+    static const double Default_mm3_per_mm;
+    static const float Default_Width;
+    static const float Default_Height;
 
-    // Process a next batch of G-code lines. Flush the internal buffers if asked for.
-    const char* process(const char *szGCode, bool flush);
-    // Length of the buffer returned by process().
-    size_t get_output_buffer_length() const { return output_buffer_length; }
+    enum EUnits : unsigned char
+    {
+        Millimeters,
+        Inches
+    };
+
+    enum EAxis : unsigned char
+    {
+        X,
+        Y,
+        Z,
+        E,
+        Num_Axis
+    };
+
+    enum EPositioningType : unsigned char
+    {
+        Absolute,
+        Relative
+    };
+
+    struct Metadata
+    {
+        ExtrusionRole extrusion_role;
+        unsigned int extruder_id;
+        double mm3_per_mm;
+        float width;     // mm
+        float height;    // mm
+        float feedrate;  // mm/s
+
+        Metadata();
+        Metadata(ExtrusionRole extrusion_role, unsigned int extruder_id, double mm3_per_mm, float width, float height, float feedrate);
+
+        bool operator != (const Metadata& other) const;
+    };
+
+    struct GCodeMove
+    {
+        enum EType : unsigned char
+        {
+            Noop,
+            Retract,
+            Unretract,
+            Tool_change,
+            Move,
+            Extrude,
+            Num_Types
+        };
+
+        EType type;
+        Metadata data;
+        Pointf3 start_position;
+        Pointf3 end_position;
+        float delta_extruder;
+
+        GCodeMove(EType type, ExtrusionRole extrusion_role, unsigned int extruder_id, double mm3_per_mm, float width, float height, float feedrate, const Pointf3& start_position, const Pointf3& end_position, float delta_extruder);
+        GCodeMove(EType type, const Metadata& data, const Pointf3& start_position, const Pointf3& end_position, float delta_extruder);
+    };
+
+    typedef std::vector<GCodeMove> GCodeMovesList;
+    typedef std::map<GCodeMove::EType, GCodeMovesList> TypeToMovesMap;
 
 private:
-    // Keeps the reference, does not own the config.
-    const Slic3r::GCodeConfig      *m_config;
+    struct State
+    {
+        EUnits units;
+        EPositioningType positioning_xyz_type;
+        EPositioningType positioning_e_type;
+        Metadata data;
+        Pointf3 start_position;
+        float start_extrusion;
+        float position[Num_Axis];
+    };
 
-    // Internal data.
-    // X,Y,Z,E,F
-    float                           m_current_pos[5];
-    size_t                          m_current_extruder;
-    ExtrusionRole                   m_current_extrusion_role;
-    uint16_t                        m_current_extrusion_width;
-    uint16_t                        m_current_extrusion_height;
-    bool                            m_retracted;
+private:
+    State m_state;
+    GCodeReader m_parser;
+    TypeToMovesMap m_moves_map;
 
-    GCodeMovesDB                   *m_moves;
+    // The output of process_layer()
+    std::string m_process_output;
 
-    // Output buffer will only grow. It will not be reallocated over and over.
-    std::vector<char>               output_buffer;
-    size_t                          output_buffer_length;
+public:
+    GCodeAnalyzer();
 
-    bool process_line(const char *line, const size_t len);
+    // Reinitialize the analyzer
+    void reset();
 
-    // Push the text to the end of the output_buffer.
-    void push_to_output(const char *text, const size_t len, bool add_eol = true);
+    // Adds the gcode contained in the given string to the analysis and returns it after removing the workcodes
+    const std::string& process_gcode(const std::string& gcode);
+
+    // Calculates all data needed for gcode visualization
+    void calc_gcode_preview_data(GCodePreviewData& preview_data);
+
+    static bool is_valid_extrusion_role(ExtrusionRole role);
+
+private:
+    // Processes the given gcode line
+    void _process_gcode_line(GCodeReader& reader, const GCodeReader::GCodeLine& line);
+
+    // Move
+    void _processG1(const GCodeReader::GCodeLine& line);
+
+    // Firmware controlled Retract
+    void _processG22(const GCodeReader::GCodeLine& line);
+
+    // Firmware controlled Unretract
+    void _processG23(const GCodeReader::GCodeLine& line);
+
+    // Set to Absolute Positioning
+    void _processG90(const GCodeReader::GCodeLine& line);
+
+    // Set to Relative Positioning
+    void _processG91(const GCodeReader::GCodeLine& line);
+
+    // Set Position
+    void _processG92(const GCodeReader::GCodeLine& line);
+
+    // Set extruder to absolute mode
+    void _processM82(const GCodeReader::GCodeLine& line);
+
+    // Set extruder to relative mode
+    void _processM83(const GCodeReader::GCodeLine& line);
+
+    // Processes T line (Select Tool)
+    void _processT(const GCodeReader::GCodeLine& line);
+
+    // Processes the tags
+    // Returns true if any tag has been processed
+    bool _process_tags(const GCodeReader::GCodeLine& line);
+
+    // Processes extrusion role tag
+    void _process_extrusion_role_tag(const std::string& comment, size_t pos);
+
+    // Processes mm3_per_mm tag
+    void _process_mm3_per_mm_tag(const std::string& comment, size_t pos);
+
+    // Processes width tag
+    void _process_width_tag(const std::string& comment, size_t pos);
+
+    // Processes height tag
+    void _process_height_tag(const std::string& comment, size_t pos);
+
+    void _set_units(EUnits units);
+    EUnits _get_units() const;
+
+    void _set_positioning_xyz_type(EPositioningType type);
+    EPositioningType _get_positioning_xyz_type() const;
+
+    void _set_positioning_e_type(EPositioningType type);
+    EPositioningType _get_positioning_e_type() const;
+
+    void _set_extrusion_role(ExtrusionRole extrusion_role);
+    ExtrusionRole _get_extrusion_role() const;
+
+    void _set_extruder_id(unsigned int id);
+    unsigned int _get_extruder_id() const;
+
+    void _set_mm3_per_mm(double value);
+    double _get_mm3_per_mm() const;
+
+    void _set_width(float width);
+    float _get_width() const;
+
+    void _set_height(float height);
+    float _get_height() const;
+
+    void _set_feedrate(float feedrate_mm_sec);
+    float _get_feedrate() const;
+
+    void _set_axis_position(EAxis axis, float position);
+    float _get_axis_position(EAxis axis) const;
+
+    // Sets axes position to zero
+    void _reset_axes_position();
+
+    void _set_start_position(const Pointf3& position);
+    const Pointf3& _get_start_position() const;
+
+    void _set_start_extrusion(float extrusion);
+    float _get_start_extrusion() const;
+    float _get_delta_extrusion() const;
+
+    // Returns current xyz position (from m_state.position[])
+    Pointf3 _get_end_position() const;
+
+    // Adds a new move with the given data
+    void _store_move(GCodeMove::EType type);
+
+    // Checks if the given int is a valid extrusion role (contained into enum ExtrusionRole)
+    bool _is_valid_extrusion_role(int value) const;
+
+    void _calc_gcode_preview_extrusion_layers(GCodePreviewData& preview_data);
+    void _calc_gcode_preview_travel(GCodePreviewData& preview_data);
+    void _calc_gcode_preview_retractions(GCodePreviewData& preview_data);
+    void _calc_gcode_preview_unretractions(GCodePreviewData& preview_data);
 };
 
 } // namespace Slic3r
 
-#endif /* slic3r_GCode_PressureEqualizer_hpp_ */
+#endif /* slic3r_GCode_Analyzer_hpp_ */
diff --git a/xs/src/libslic3r/GCode/PreviewData.cpp b/xs/src/libslic3r/GCode/PreviewData.cpp
new file mode 100644
index 000000000..5a23d332d
--- /dev/null
+++ b/xs/src/libslic3r/GCode/PreviewData.cpp
@@ -0,0 +1,408 @@
+#include "Analyzer.hpp"
+#include "PreviewData.hpp"
+#include <float.h>
+
+namespace Slic3r {
+
+const GCodePreviewData::Color GCodePreviewData::Color::Dummy(0.0f, 0.0f, 0.0f, 0.0f);
+
+GCodePreviewData::Color::Color()
+{
+    rgba[0] = 1.0f;
+    rgba[1] = 1.0f;
+    rgba[2] = 1.0f;
+    rgba[3] = 1.0f;
+}
+
+GCodePreviewData::Color::Color(float r, float g, float b, float a)
+{
+    rgba[0] = r;
+    rgba[1] = g;
+    rgba[2] = b;
+    rgba[3] = a;
+}
+
+std::vector<unsigned char> GCodePreviewData::Color::as_bytes() const
+{
+    std::vector<unsigned char> ret;
+    for (unsigned int i = 0; i < 4; ++i)
+    {
+        ret.push_back((unsigned char)(255.0f * rgba[i]));
+    }
+    return ret;
+}
+
+GCodePreviewData::Extrusion::Layer::Layer(float z, const ExtrusionPaths& paths)
+    : z(z)
+    , paths(paths)
+{
+}
+
+GCodePreviewData::Travel::Polyline::Polyline(EType type, EDirection direction, float feedrate, unsigned int extruder_id, const Polyline3& polyline)
+    : type(type)
+    , direction(direction)
+    , feedrate(feedrate)
+    , extruder_id(extruder_id)
+    , polyline(polyline)
+{
+}
+
+const GCodePreviewData::Color GCodePreviewData::Range::Default_Colors[Colors_Count] =
+{
+    Color(0.043f, 0.173f, 0.478f, 1.0f),
+    Color(0.075f, 0.349f, 0.522f, 1.0f),
+    Color(0.110f, 0.533f, 0.569f, 1.0f),
+    Color(0.016f, 0.839f, 0.059f, 1.0f),
+    Color(0.667f, 0.949f, 0.000f, 1.0f),
+    Color(0.988f, 0.975f, 0.012f, 1.0f),
+    Color(0.961f, 0.808f, 0.039f, 1.0f),
+    Color(0.890f, 0.533f, 0.125f, 1.0f),
+    Color(0.820f, 0.408f, 0.188f, 1.0f),
+    Color(0.761f, 0.322f, 0.235f, 1.0f)
+};
+
+GCodePreviewData::Range::Range()
+{
+    reset();
+}
+
+void GCodePreviewData::Range::reset()
+{
+    min = FLT_MAX;
+    max = -FLT_MAX;
+}
+
+bool GCodePreviewData::Range::empty() const
+{
+    return min == max;
+}
+
+void GCodePreviewData::Range::update_from(float value)
+{
+    min = std::min(min, value);
+    max = std::max(max, value);
+}
+
+void GCodePreviewData::Range::set_from(const Range& other)
+{
+    min = other.min;
+    max = other.max;
+}
+
+float GCodePreviewData::Range::step_size() const
+{
+    return (max - min) / (float)Colors_Count;
+}
+
+const GCodePreviewData::Color& GCodePreviewData::Range::get_color_at_max() const
+{
+    return colors[Colors_Count - 1];
+}
+
+const GCodePreviewData::Color& GCodePreviewData::Range::get_color_at(float value) const
+{
+    return empty() ? get_color_at_max() : colors[clamp((unsigned int)0, Colors_Count - 1, (unsigned int)((value - min) / step_size()))];
+}
+
+GCodePreviewData::LegendItem::LegendItem(const std::string& text, const GCodePreviewData::Color& color)
+    : text(text)
+    , color(color)
+{
+}
+
+const GCodePreviewData::Color GCodePreviewData::Extrusion::Default_Extrusion_Role_Colors[Num_Extrusion_Roles] =
+{
+    Color(0.0f, 0.0f, 0.0f, 1.0f),   // erNone
+    Color(1.0f, 0.0f, 0.0f, 1.0f),   // erPerimeter
+    Color(0.0f, 1.0f, 0.0f, 1.0f),   // erExternalPerimeter
+    Color(0.0f, 0.0f, 1.0f, 1.0f),   // erOverhangPerimeter
+    Color(1.0f, 1.0f, 0.0f, 1.0f),   // erInternalInfill
+    Color(1.0f, 0.0f, 1.0f, 1.0f),   // erSolidInfill
+    Color(0.0f, 1.0f, 1.0f, 1.0f),   // erTopSolidInfill
+    Color(0.5f, 0.5f, 0.5f, 1.0f),   // erBridgeInfill
+    Color(1.0f, 1.0f, 1.0f, 1.0f),   // erGapFill
+    Color(0.5f, 0.0f, 0.0f, 1.0f),   // erSkirt
+    Color(0.0f, 0.5f, 0.0f, 1.0f),   // erSupportMaterial
+    Color(0.0f, 0.0f, 0.5f, 1.0f),   // erSupportMaterialInterface
+    Color(0.7f, 0.89f, 0.67f, 1.0f), // erWipeTower
+    Color(0.0f, 0.0f, 0.0f, 1.0f)    // erMixed
+};
+
+// todo: merge with Slic3r::ExtrusionRole2String() from GCode.cpp
+const std::string GCodePreviewData::Extrusion::Default_Extrusion_Role_Names[Num_Extrusion_Roles]
+{
+    "None",
+    "Perimeter",
+    "External perimeter",
+    "Overhang perimeter",
+    "Internal infill",
+    "Solid infill",
+    "Top solid infill",
+    "Bridge infill",
+    "Gap fill",
+    "Skirt",
+    "Support material",
+    "Support material interface",
+    "Wipe tower",
+    "Mixed"
+};
+
+const GCodePreviewData::Extrusion::EViewType GCodePreviewData::Extrusion::Default_View_Type = GCodePreviewData::Extrusion::FeatureType;
+
+void GCodePreviewData::Extrusion::set_default()
+{
+    view_type = Default_View_Type;
+
+    ::memcpy((void*)role_colors, (const void*)Default_Extrusion_Role_Colors, Num_Extrusion_Roles * sizeof(Color));
+    ::memcpy((void*)ranges.height.colors, (const void*)Range::Default_Colors, Range::Colors_Count * sizeof(Color));
+    ::memcpy((void*)ranges.width.colors, (const void*)Range::Default_Colors, Range::Colors_Count * sizeof(Color));
+    ::memcpy((void*)ranges.feedrate.colors, (const void*)Range::Default_Colors, Range::Colors_Count * sizeof(Color));
+
+    for (unsigned int i = 0; i < Num_Extrusion_Roles; ++i)
+    {
+        role_names[i] = Default_Extrusion_Role_Names[i];
+    }
+
+    role_flags = 0;
+    for (unsigned int i = 0; i < Num_Extrusion_Roles; ++i)
+    {
+        role_flags |= 1 << i;
+    }
+}
+
+bool GCodePreviewData::Extrusion::is_role_flag_set(ExtrusionRole role) const
+{
+    return is_role_flag_set(role_flags, role);
+}
+
+bool GCodePreviewData::Extrusion::is_role_flag_set(unsigned int flags, ExtrusionRole role)
+{
+    return GCodeAnalyzer::is_valid_extrusion_role(role) && (flags & (1 << (role - erPerimeter))) != 0;
+}
+
+const float GCodePreviewData::Travel::Default_Width = 0.075f;
+const float GCodePreviewData::Travel::Default_Height = 0.075f;
+const GCodePreviewData::Color GCodePreviewData::Travel::Default_Type_Colors[Num_Types] =
+{
+    Color(0.0f, 0.0f, 0.75f, 1.0f), // Move
+    Color(0.0f, 0.75f, 0.0f, 1.0f), // Extrude
+    Color(0.75f, 0.0f, 0.0f, 1.0f), // Retract
+};
+
+void GCodePreviewData::Travel::set_default()
+{
+    width = Default_Width;
+    height = Default_Height;
+    ::memcpy((void*)type_colors, (const void*)Default_Type_Colors, Num_Types * sizeof(Color));
+    is_visible = false;
+}
+
+const GCodePreviewData::Color GCodePreviewData::Retraction::Default_Color = GCodePreviewData::Color(1.0f, 1.0f, 1.0f, 1.0f);
+
+GCodePreviewData::Retraction::Position::Position(const Point3& position, float width, float height)
+    : position(position)
+    , width(width)
+    , height(height)
+{
+}
+
+void GCodePreviewData::Retraction::set_default()
+{
+    color = Default_Color;
+    is_visible = false;
+}
+
+void GCodePreviewData::Shell::set_default()
+{
+    is_visible = false;
+}
+
+GCodePreviewData::GCodePreviewData()
+{
+    set_default();
+}
+
+void GCodePreviewData::set_default()
+{
+    extrusion.set_default();
+    travel.set_default();
+    retraction.set_default();
+    unretraction.set_default();
+    shell.set_default();
+}
+
+void GCodePreviewData::reset()
+{
+    extrusion.layers.clear();
+    travel.polylines.clear();
+    retraction.positions.clear();
+    unretraction.positions.clear();
+}
+
+bool GCodePreviewData::empty() const
+{
+    return extrusion.layers.empty() && travel.polylines.empty() && retraction.positions.empty() && unretraction.positions.empty();
+}
+
+const GCodePreviewData::Color& GCodePreviewData::get_extrusion_role_color(ExtrusionRole role) const
+{
+    return extrusion.role_colors[role];
+}
+
+const GCodePreviewData::Color& GCodePreviewData::get_extrusion_height_color(float height) const
+{
+    return extrusion.ranges.height.get_color_at(height);
+}
+
+const GCodePreviewData::Color& GCodePreviewData::get_extrusion_width_color(float width) const
+{
+    return extrusion.ranges.width.get_color_at(width);
+}
+
+const GCodePreviewData::Color& GCodePreviewData::get_extrusion_feedrate_color(float feedrate) const
+{
+    return extrusion.ranges.feedrate.get_color_at(feedrate);
+}
+
+void GCodePreviewData::set_extrusion_role_color(const std::string& role_name, float red, float green, float blue, float alpha)
+{
+    for (unsigned int i = 0; i < Extrusion::Num_Extrusion_Roles; ++i)
+    {
+        if (role_name == extrusion.role_names[i])
+        {
+            extrusion.role_colors[i] = Color(red, green, blue, alpha);
+            break;
+        }
+    }
+}
+
+void GCodePreviewData::set_extrusion_paths_colors(const std::vector<std::string>& colors)
+{
+    unsigned int size = (unsigned int)colors.size();
+
+    if (size % 2 != 0)
+        return;
+
+    for (unsigned int i = 0; i < size; i += 2)
+    {
+        const std::string& color_str = colors[i + 1];
+
+        if (color_str.size() == 6)
+        {
+            bool valid = true;
+            for (int c = 0; c < 6; ++c)
+            {
+                if (::isxdigit(color_str[c]) == 0)
+                {
+                    valid = false;
+                    break;
+                }
+            }
+
+            if (valid)
+            {
+                unsigned int color;
+                std::stringstream ss;
+                ss << std::hex << color_str;
+                ss >> color;
+
+                float den = 1.0f / 255.0f;
+
+                float r = (float)((color & 0xFF0000) >> 16) * den;
+                float g = (float)((color & 0x00FF00) >> 8) * den;
+                float b = (float)(color & 0x0000FF) * den;
+
+                this->set_extrusion_role_color(colors[i], r, g, b, 1.0f);
+            }
+        }
+    }
+}
+
+std::string GCodePreviewData::get_legend_title() const
+{
+    switch (extrusion.view_type)
+    {
+    case Extrusion::FeatureType:
+        return "Feature type";
+    case Extrusion::Height:
+        return "Height (mm)";
+    case Extrusion::Width:
+        return "Width (mm)";
+    case Extrusion::Feedrate:
+        return "Speed (mm/s)";
+    case Extrusion::Tool:
+        return "Tool";
+    }
+
+    return "";
+}
+
+GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std::vector<float>& tool_colors) const
+{
+    struct Helper
+    {
+        static void FillListFromRange(LegendItemsList& list, const Range& range, unsigned int decimals, float scale_factor)
+        {
+            list.reserve(Range::Colors_Count);
+            float step = range.step_size();
+            for (unsigned int i = 0; i < Range::Colors_Count; ++i)
+            {
+                char buf[32];
+                sprintf(buf, "%.*f/%.*f", decimals, scale_factor * (range.min + (float)i * step), decimals, scale_factor * (range.min + (float)(i + 1) * step));
+                list.emplace_back(buf, range.colors[i]);
+            }
+        }
+    };
+
+    LegendItemsList items;
+
+    switch (extrusion.view_type)
+    {
+    case Extrusion::FeatureType:
+        {
+            items.reserve(erMixed - erPerimeter + 1);
+            for (unsigned int i = (unsigned int)erPerimeter; i < (unsigned int)erMixed; ++i)
+            {
+                items.emplace_back(extrusion.role_names[i], extrusion.role_colors[i]);
+            }
+
+            break;
+        }
+    case Extrusion::Height:
+        {
+            Helper::FillListFromRange(items, extrusion.ranges.height, 3, 1.0f);            
+            break;
+        }
+    case Extrusion::Width:
+        {
+            Helper::FillListFromRange(items, extrusion.ranges.width, 3, 1.0f);
+            break;
+        }
+    case Extrusion::Feedrate:
+        {
+            Helper::FillListFromRange(items, extrusion.ranges.feedrate, 0, 1.0f);
+            break;
+        }
+    case Extrusion::Tool:
+        {
+            unsigned int tools_colors_count = tool_colors.size() / 4;
+            items.reserve(tools_colors_count);
+            for (unsigned int i = 0; i < tools_colors_count; ++i)
+            {
+                char buf[32];
+                sprintf(buf, "Extruder %d", i + 1);
+
+                GCodePreviewData::Color color;
+                ::memcpy((void*)color.rgba, (const void*)(tool_colors.data() + i * 4), 4 * sizeof(float));
+
+                items.emplace_back(buf, color);
+            }
+
+            break;
+        }
+    }
+
+    return items;
+}
+
+} // namespace Slic3r
diff --git a/xs/src/libslic3r/GCode/PreviewData.hpp b/xs/src/libslic3r/GCode/PreviewData.hpp
new file mode 100644
index 000000000..9fb2dc464
--- /dev/null
+++ b/xs/src/libslic3r/GCode/PreviewData.hpp
@@ -0,0 +1,205 @@
+#ifndef slic3r_GCode_PreviewData_hpp_
+#define slic3r_GCode_PreviewData_hpp_
+
+#include "../libslic3r.h"
+#include "../ExtrusionEntity.hpp"
+
+#include "Point.hpp"
+
+namespace Slic3r {
+
+class GCodePreviewData
+{
+public:
+    struct Color
+    {
+        float rgba[4];
+
+        Color();
+        Color(float r, float g, float b, float a);
+
+        std::vector<unsigned char> as_bytes() const;
+
+        static const Color Dummy;
+    };
+
+    struct Range
+    {
+        static const unsigned int Colors_Count = 10;
+        static const Color Default_Colors[Colors_Count];
+
+        Color colors[Colors_Count];
+        float min;
+        float max;
+
+        Range();
+
+        void reset();
+        bool empty() const;
+        void update_from(float value);
+        void set_from(const Range& other);
+        float step_size() const;
+
+        const Color& get_color_at(float value) const;
+        const Color& get_color_at_max() const;
+    };
+
+    struct LegendItem
+    {
+        std::string text;
+        Color color;
+
+        LegendItem(const std::string& text, const Color& color);
+    };
+
+    typedef std::vector<LegendItem> LegendItemsList;
+
+    struct Extrusion
+    {
+        enum EViewType : unsigned char
+        {
+            FeatureType,
+            Height,
+            Width,
+            Feedrate,
+            Tool,
+            Num_View_Types
+        };
+
+        static const unsigned int Num_Extrusion_Roles = (unsigned int)erMixed + 1;
+        static const Color Default_Extrusion_Role_Colors[Num_Extrusion_Roles];
+        static const std::string Default_Extrusion_Role_Names[Num_Extrusion_Roles];
+        static const EViewType Default_View_Type;
+
+        struct Ranges
+        {
+            Range height;
+            Range width;
+            Range feedrate;
+        };
+
+        struct Layer
+        {
+            float z;
+            ExtrusionPaths paths;
+
+            Layer(float z, const ExtrusionPaths& paths);
+        };
+
+        typedef std::vector<Layer> LayersList;
+
+        EViewType view_type;
+        Color role_colors[Num_Extrusion_Roles];
+        std::string role_names[Num_Extrusion_Roles];
+        Ranges ranges;
+        LayersList layers;
+        unsigned int role_flags;
+
+        void set_default();
+        bool is_role_flag_set(ExtrusionRole role) const;
+
+        static bool is_role_flag_set(unsigned int flags, ExtrusionRole role);
+    };
+
+    struct Travel
+    {
+        enum EType : unsigned char
+        {
+            Move,
+            Extrude,
+            Retract,
+            Num_Types
+        };
+
+        static const float Default_Width;
+        static const float Default_Height;
+        static const Color Default_Type_Colors[Num_Types];
+
+        struct Polyline
+        {
+            enum EDirection
+            {
+                Vertical,
+                Generic,
+                Num_Directions
+            };
+
+            EType type;
+            EDirection direction;
+            float feedrate;
+            unsigned int extruder_id;
+            Polyline3 polyline;
+
+            Polyline(EType type, EDirection direction, float feedrate, unsigned int extruder_id, const Polyline3& polyline);
+        };
+
+        typedef std::vector<Polyline> PolylinesList;
+
+        PolylinesList polylines;
+        float width;
+        float height;
+        Color type_colors[Num_Types];
+        bool is_visible;
+
+        void set_default();
+    };
+
+    struct Retraction
+    {
+        static const Color Default_Color;
+
+        struct Position
+        {
+            Point3 position;
+            float width;
+            float height;
+
+            Position(const Point3& position, float width, float height);
+        };
+
+        typedef std::vector<Position> PositionsList;
+
+        PositionsList positions;
+        Color color;
+        bool is_visible;
+
+        void set_default();
+    };
+
+    struct Shell
+    {
+        bool is_visible;
+
+        void set_default();
+    };
+
+    Extrusion extrusion;
+    Travel travel;
+    Retraction retraction;
+    Retraction unretraction;
+    Shell shell;
+
+    GCodePreviewData();
+
+    void set_default();
+    void reset();
+    bool empty() const;
+
+    const Color& get_extrusion_role_color(ExtrusionRole role) const;
+    const Color& get_extrusion_height_color(float height) const;
+    const Color& get_extrusion_width_color(float width) const;
+    const Color& get_extrusion_feedrate_color(float feedrate) const;
+
+    void set_extrusion_role_color(const std::string& role_name, float red, float green, float blue, float alpha);
+    void set_extrusion_paths_colors(const std::vector<std::string>& colors);
+
+    std::string get_legend_title() const;
+    LegendItemsList get_legend_items(const std::vector<float>& tool_colors) const;
+};
+
+GCodePreviewData::Color operator + (const GCodePreviewData::Color& c1, const GCodePreviewData::Color& c2);
+GCodePreviewData::Color operator * (float f, const GCodePreviewData::Color& color);
+
+} // namespace Slic3r
+
+#endif /* slic3r_GCode_PreviewData_hpp_ */
diff --git a/xs/src/libslic3r/GCode/SpiralVase.cpp b/xs/src/libslic3r/GCode/SpiralVase.cpp
index fd300067f..8e8ae3075 100644
--- a/xs/src/libslic3r/GCode/SpiralVase.cpp
+++ b/xs/src/libslic3r/GCode/SpiralVase.cpp
@@ -4,17 +4,7 @@
 
 namespace Slic3r {
 
-std::string
-_format_z(float z)
-{
-    std::ostringstream ss;
-    ss << std::fixed << std::setprecision(3)
-       << z;
-    return ss.str();
-}
-
-std::string
-SpiralVase::process_layer(const std::string &gcode)
+std::string SpiralVase::process_layer(const std::string &gcode)
 {
     /*  This post-processor relies on several assumptions:
         - all layers are processed through it, including those that are not supposed
@@ -27,7 +17,7 @@ SpiralVase::process_layer(const std::string &gcode)
     // If we're not going to modify G-code, just feed it to the reader
     // in order to update positions.
     if (!this->enable) {
-        this->_reader.parse(gcode, {});
+        this->_reader.parse_buffer(gcode);
         return gcode;
     }
     
@@ -38,16 +28,17 @@ SpiralVase::process_layer(const std::string &gcode)
     bool set_z = false;
     
     {
+        //FIXME Performance warning: This copies the GCodeConfig of the reader.
         GCodeReader r = this->_reader;  // clone
-        r.parse(gcode, [&total_layer_length, &layer_height, &z, &set_z]
-            (GCodeReader &, const GCodeReader::GCodeLine &line) {
-            if (line.cmd == "G1") {
-                if (line.extruding()) {
-                    total_layer_length += line.dist_XY();
-                } else if (line.has('Z')) {
-                    layer_height += line.dist_Z();
+        r.parse_buffer(gcode, [&total_layer_length, &layer_height, &z, &set_z]
+            (GCodeReader &reader, const GCodeReader::GCodeLine &line) {
+            if (line.cmd_is("G1")) {
+                if (line.extruding(reader)) {
+                    total_layer_length += line.dist_XY(reader);
+                } else if (line.has(Z)) {
+                    layer_height += line.dist_Z(reader);
                     if (!set_z) {
-                        z = line.new_Z();
+                        z = line.new_Z(reader);
                         set_z = true;
                     }
                 }
@@ -59,23 +50,23 @@ SpiralVase::process_layer(const std::string &gcode)
     z -= layer_height;
     
     std::string new_gcode;
-    this->_reader.parse(gcode, [&new_gcode, &z, &layer_height, &total_layer_length]
-        (GCodeReader &, GCodeReader::GCodeLine line) {
-        if (line.cmd == "G1") {
-            if (line.has('Z')) {
+    this->_reader.parse_buffer(gcode, [&new_gcode, &z, &layer_height, &total_layer_length]
+        (GCodeReader &reader, GCodeReader::GCodeLine line) {
+        if (line.cmd_is("G1")) {
+            if (line.has_z()) {
                 // If this is the initial Z move of the layer, replace it with a
                 // (redundant) move to the last Z of previous layer.
-                line.set('Z', _format_z(z));
-                new_gcode += line.raw + '\n';
+                line.set(reader, Z, z);
+                new_gcode += line.raw() + '\n';
                 return;
             } else {
-                float dist_XY = line.dist_XY();
+                float dist_XY = line.dist_XY(reader);
                 if (dist_XY > 0) {
                     // horizontal move
-                    if (line.extruding()) {
+                    if (line.extruding(reader)) {
                         z += dist_XY * layer_height / total_layer_length;
-                        line.set('Z', _format_z(z));
-                        new_gcode += line.raw + '\n';
+                        line.set(reader, Z, z);
+                        new_gcode += line.raw() + '\n';
                     }
                     return;
                 
@@ -87,7 +78,7 @@ SpiralVase::process_layer(const std::string &gcode)
                 }
             }
         }
-        new_gcode += line.raw + '\n';
+        new_gcode += line.raw() + '\n';
     });
     
     return new_gcode;
diff --git a/xs/src/libslic3r/GCode/SpiralVase.hpp b/xs/src/libslic3r/GCode/SpiralVase.hpp
index 234642524..60aa668d8 100644
--- a/xs/src/libslic3r/GCode/SpiralVase.hpp
+++ b/xs/src/libslic3r/GCode/SpiralVase.hpp
@@ -13,7 +13,7 @@ class SpiralVase {
     SpiralVase(const PrintConfig &config)
         : enable(false), _config(&config)
     {
-        this->_reader.Z = this->_config->z_offset;
+        this->_reader.z() = this->_config->z_offset;
         this->_reader.apply_config(*this->_config);
     };
     std::string process_layer(const std::string &gcode);
diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp
index c409b5f20..adb19eba9 100644
--- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp
+++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp
@@ -21,6 +21,8 @@ TODO LIST
 #include <iostream>
 #include <vector>
 
+#include "Analyzer.hpp"
+
 #if defined(__linux) || defined(__GNUC__ )
 #include <strings.h>
 #endif /* __linux */
@@ -510,6 +512,11 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime(
 		.travel(cleaning_box.ld, 7200)
 		.set_extruder_trimpot(750); 			// Increase the extruder driver current to allow fast ramming.
 
+    // adds tag for analyzer
+    char buf[32];
+    sprintf(buf, ";%s%d\n", GCodeAnalyzer::Extrusion_Role_Tag.c_str(), erWipeTower);
+    writer.append(buf);
+
 	if (purpose == PURPOSE_EXTRUDE || purpose == PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE) {
 		for (size_t idx_tool = 0; idx_tool < tools.size(); ++ idx_tool) {
 			unsigned int tool = tools[idx_tool];
@@ -658,6 +665,11 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo
 		writer.set_initial_position(initial_position);
 	}
 
+    // adds tag for analyzer
+    char buf[32];
+    sprintf(buf, ";%s%d\n", GCodeAnalyzer::Extrusion_Role_Tag.c_str(), erWipeTower);
+    writer.append(buf);
+
 	if (purpose == PURPOSE_EXTRUDE || purpose == PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE) {
 		// Increase the extruder driver current to allow fast ramming.
 		writer.set_extruder_trimpot(750);
@@ -735,6 +747,11 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::toolchange_Brim(Purpose purpose, b
 	else 
 		writer.set_initial_position(initial_position);
 
+    // adds tag for analyzer
+    char buf[32];
+    sprintf(buf, ";%s%d\n", GCodeAnalyzer::Extrusion_Role_Tag.c_str(), erWipeTower);
+    writer.append(buf);
+
 	if (purpose == PURPOSE_EXTRUDE || purpose == PURPOSE_MOVE_TO_TOWER_AND_EXTRUDE) {
 
 		writer.extrude_explicit(wipeTower_box.ld - xy(m_perimeter_width * 6.f, 0), // Prime the extruder left of the wipe tower.
diff --git a/xs/src/libslic3r/GCodeReader.cpp b/xs/src/libslic3r/GCodeReader.cpp
index 453cc9f94..965b7ef8e 100644
--- a/xs/src/libslic3r/GCodeReader.cpp
+++ b/xs/src/libslic3r/GCodeReader.cpp
@@ -4,6 +4,8 @@
 #include <fstream>
 #include <iostream>
 
+#include <Shiny/Shiny.h>
+
 namespace Slic3r {
 
 void GCodeReader::apply_config(const GCodeConfig &config)
@@ -18,66 +20,89 @@ void GCodeReader::apply_config(const DynamicPrintConfig &config)
     m_extrusion_axis = m_config.get_extrusion_axis()[0];
 }
 
-void GCodeReader::parse(const std::string &gcode, callback_t callback)
+const char* GCodeReader::parse_line_internal(const char *ptr, GCodeLine &gline, std::pair<const char*, const char*> &command)
 {
-    std::istringstream ss(gcode);
-    std::string line;
-    while (std::getline(ss, line))
-        this->parse_line(line, callback);
-}
-
-void GCodeReader::parse_line(std::string line, callback_t callback)
-{
-    GCodeLine gline(this);
-    gline.raw = line;
-    if (this->verbose)
-        std::cout << line << std::endl;
-    
-    // strip comment
-    {
-        size_t pos = line.find(';');
-        if (pos != std::string::npos) {
-            gline.comment = line.substr(pos+1);
-            line.erase(pos);
-        }
-    }
+    PROFILE_FUNC();
     
     // command and args
+    const char *c = ptr;
     {
-        std::vector<std::string> args;
-        boost::split(args, line, boost::is_any_of(" "));
-        
-        // first one is cmd
-        gline.cmd = args.front();
-        args.erase(args.begin());
-        
-        for (std::string &arg : args) {
-            if (arg.size() < 2) continue;
-            gline.args.insert(std::make_pair(arg[0], arg.substr(1)));
+        PROFILE_BLOCK(command_and_args);
+        // Skip the whitespaces.
+        command.first = skip_whitespaces(c);
+        // Skip the command.
+        c = command.second = skip_word(command.first);
+        // Up to the end of line or comment.
+		while (! is_end_of_gcode_line(*c)) {
+            // Skip whitespaces.
+            c = skip_whitespaces(c);
+			if (is_end_of_gcode_line(*c))
+				break;
+            // Check the name of the axis.
+            Axis axis = NUM_AXES;
+            switch (*c) {
+            case 'X': axis = X; break;
+            case 'Y': axis = Y; break;
+            case 'Z': axis = Z; break;
+            case 'F': axis = F; break;
+            default:
+                if (*c == m_extrusion_axis)
+                    axis = E;
+                break;
+            }
+            if (axis != NUM_AXES) {
+                // Try to parse the numeric value.
+                char   *pend = nullptr;
+                double  v = strtod(++ c, &pend);
+                if (pend != nullptr && is_end_of_word(*pend)) {
+                    // The axis value has been parsed correctly.
+                    gline.m_axis[int(axis)] = float(v);
+                    gline.m_mask |= 1 << int(axis);
+                    c = pend;
+                } else
+                    // Skip the rest of the word.
+                    c = skip_word(c);
+            } else
+                // Skip the rest of the word.
+                c = skip_word(c);
         }
     }
     
-    // convert extrusion axis
-    if (m_extrusion_axis != 'E') {
-        const auto it = gline.args.find(m_extrusion_axis);
-        if (it != gline.args.end()) {
-            std::swap(gline.args['E'], it->second);
-            gline.args.erase(it);
-        }
+    if (gline.has(E) && m_config.use_relative_e_distances)
+        m_position[E] = 0;
+
+    // Skip the rest of the line.
+    for (; ! is_end_of_line(*c); ++ c);
+
+    // Copy the raw string including the comment, without the trailing newlines.
+    if (c > ptr) {
+        PROFILE_BLOCK(copy_raw_string);
+        gline.m_raw.assign(ptr, c);
     }
-    
-    if (gline.has('E') && m_config.use_relative_e_distances)
-        this->E = 0;
-    
-    if (callback) callback(*this, gline);
-    
-    // update coordinates
-    if (gline.cmd == "G0" || gline.cmd == "G1" || gline.cmd == "G92") {
-        this->X = gline.new_X();
-        this->Y = gline.new_Y();
-        this->Z = gline.new_Z();
-        this->E = gline.new_E();
-        this->F = gline.new_F();
+
+    // Skip the trailing newlines.
+	if (*c == '\r')
+		++ c;
+	if (*c == '\n')
+		++ c;
+
+    if (m_verbose)
+        std::cout << gline.m_raw << std::endl;
+
+    return c;
+}
+
+void GCodeReader::update_coordinates(GCodeLine &gline, std::pair<const char*, const char*> &command)
+{
+    PROFILE_FUNC();
+    if (*command.first == 'G') {
+        int cmd_len = int(command.second - command.first);
+        if ((cmd_len == 2 && (command.first[1] == '0' || command.first[1] == '1')) ||
+            (cmd_len == 3 &&  command.first[1] == '9' && command.first[2] == '2')) {
+            for (size_t i = 0; i < NUM_AXES; ++ i)
+                if (gline.has(Axis(i)))
+                    this->m_position[i] = gline.value(Axis(i));
+        }
     }
 }
 
@@ -89,22 +114,64 @@ void GCodeReader::parse_file(const std::string &file, callback_t callback)
         this->parse_line(line, callback);
 }
 
-void GCodeReader::GCodeLine::set(char arg, std::string value)
+bool GCodeReader::GCodeLine::has_value(char axis, float &value) const
 {
-    const std::string space(" ");
-    if (this->has(arg)) {
-        size_t pos = this->raw.find(space + arg)+2;
-        size_t end = this->raw.find(' ', pos+1);
-        this->raw = this->raw.replace(pos, end-pos, value);
-    } else {
-        size_t pos = this->raw.find(' ');
-        if (pos == std::string::npos) {
-            this->raw += space + arg + value;
-        } else {
-            this->raw = this->raw.replace(pos, 0, space + arg + value);
+    const char *c = m_raw.c_str();
+    // Skip the whitespaces.
+    c = skip_whitespaces(c);
+    // Skip the command.
+    c = skip_word(c);
+    // Up to the end of line or comment.
+    while (! is_end_of_gcode_line(*c)) {
+        // Skip whitespaces.
+        c = skip_whitespaces(c);
+        if (is_end_of_gcode_line(*c))
+            break;
+        // Check the name of the axis.
+        if (*c == axis) {
+            // Try to parse the numeric value.
+            char   *pend = nullptr;
+            double  v = strtod(++ c, &pend);
+            if (pend != nullptr && is_end_of_word(*pend)) {
+                // The axis value has been parsed correctly.
+                value = float(v);
+                return true;
+            }
         }
+        // Skip the rest of the word.
+        c = skip_word(c);
     }
-    this->args[arg] = value;
+    return false;
+}
+
+void GCodeReader::GCodeLine::set(const GCodeReader &reader, const Axis axis, const float new_value, const int decimal_digits)
+{
+    std::ostringstream ss;
+    ss << std::fixed << std::setprecision(decimal_digits) << new_value;
+
+    char match[3] = " X";
+    if (int(axis) < 3)
+        match[1] += int(axis);
+    else if (axis == F)
+        match[1] = 'F';
+    else {
+        assert(axis == E);
+        match[1] = reader.extrusion_axis();
+    }
+
+    if (this->has(axis)) {
+        size_t pos = m_raw.find(match)+2;
+        size_t end = m_raw.find(' ', pos+1);
+        m_raw = m_raw.replace(pos, end-pos, ss.str());
+    } else {
+        size_t pos = m_raw.find(' ');
+        if (pos == std::string::npos)
+            m_raw += std::string(match) + ss.str();
+        else
+            m_raw = m_raw.replace(pos, 0, std::string(match) + ss.str());
+    }
+    m_axis[axis] = new_value;
+    m_mask |= 1 << int(axis);
 }
 
 }
diff --git a/xs/src/libslic3r/GCodeReader.hpp b/xs/src/libslic3r/GCodeReader.hpp
index 1792d6cde..102cbd27a 100644
--- a/xs/src/libslic3r/GCodeReader.hpp
+++ b/xs/src/libslic3r/GCodeReader.hpp
@@ -11,54 +11,127 @@
 namespace Slic3r {
 
 class GCodeReader {
-public:    
+public:
     class GCodeLine {
     public:
-        GCodeReader* reader;
-        std::string raw;
-        std::string cmd;
-        std::string comment;
-        std::map<char,std::string> args;
-        
-        GCodeLine(GCodeReader* _reader) : reader(_reader) {};
-        
-        bool  has(char arg) const { return this->args.count(arg) > 0; };
-        float get_float(char arg) const { return float(atof(this->args.at(arg).c_str())); };
-        float new_X() const { return this->has('X') ? float(atof(this->args.at('X').c_str())) : this->reader->X; };
-        float new_Y() const { return this->has('Y') ? float(atof(this->args.at('Y').c_str())) : this->reader->Y; };
-        float new_Z() const { return this->has('Z') ? float(atof(this->args.at('Z').c_str())) : this->reader->Z; };
-        float new_E() const { return this->has('E') ? float(atof(this->args.at('E').c_str())) : this->reader->E; };
-        float new_F() const { return this->has('F') ? float(atof(this->args.at('F').c_str())) : this->reader->F; };
-        float dist_X() const { return this->new_X() - this->reader->X; };
-        float dist_Y() const { return this->new_Y() - this->reader->Y; };
-        float dist_Z() const { return this->new_Z() - this->reader->Z; };
-        float dist_E() const { return this->new_E() - this->reader->E; };
-        float dist_XY() const {
-            float x = this->dist_X();
-            float y = this->dist_Y();
+        GCodeLine() { reset(); }
+        void reset() { m_mask = 0; memset(m_axis, 0, sizeof(m_axis)); m_raw.clear(); }
+
+        const std::string&  raw() const { return m_raw; }
+        const std::string   cmd() const { 
+            const char *cmd = GCodeReader::skip_whitespaces(m_raw.c_str());
+            return std::string(cmd, GCodeReader::skip_word(cmd));
+        }
+        const std::string   comment() const
+            { size_t pos = m_raw.find(';'); return (pos == std::string::npos) ? "" : m_raw.substr(pos + 1); }
+
+        bool  has(Axis axis) const { return (m_mask & (1 << int(axis))) != 0; }
+        float value(Axis axis) const { return m_axis[axis]; }
+        bool  has_value(char axis, float &value) const;
+        float new_Z(const GCodeReader &reader) const { return this->has(Z) ? this->z() : reader.z(); }
+        float new_E(const GCodeReader &reader) const { return this->has(E) ? this->e() : reader.e(); }
+        float new_F(const GCodeReader &reader) const { return this->has(F) ? this->f() : reader.f(); }
+        float dist_X(const GCodeReader &reader) const { return this->has(X) ? (this->x() - reader.x()) : 0; }
+        float dist_Y(const GCodeReader &reader) const { return this->has(Y) ? (this->y() - reader.y()) : 0; }
+        float dist_Z(const GCodeReader &reader) const { return this->has(Z) ? (this->z() - reader.z()) : 0; }
+        float dist_E(const GCodeReader &reader) const { return this->has(E) ? (this->e() - reader.e()) : 0; }
+        float dist_XY(const GCodeReader &reader) const {
+            float x = this->has(X) ? (this->x() - reader.x()) : 0;
+            float y = this->has(Y) ? (this->y() - reader.y()) : 0;
             return sqrt(x*x + y*y);
-        };
-        bool extruding()  const { return this->cmd == "G1" && this->dist_E() > 0; };
-        bool retracting() const { return this->cmd == "G1" && this->dist_E() < 0; };
-        bool travel()     const { return this->cmd == "G1" && ! this->has('E'); };
-        void set(char arg, std::string value);
+        }
+        bool cmd_is(const char *cmd_test) const {
+            const char *cmd = GCodeReader::skip_whitespaces(m_raw.c_str());
+            int len = strlen(cmd_test); 
+            return strncmp(cmd, cmd_test, len) == 0 && GCodeReader::is_end_of_word(cmd[len]);
+        }
+        bool extruding(const GCodeReader &reader)  const { return this->cmd_is("G1") && this->dist_E(reader) > 0; }
+        bool retracting(const GCodeReader &reader) const { return this->cmd_is("G1") && this->dist_E(reader) < 0; }
+        bool travel()     const { return this->cmd_is("G1") && ! this->has(E); }
+        void set(const GCodeReader &reader, const Axis axis, const float new_value, const int decimal_digits = 3);
+
+        bool  has_x() const { return this->has(X); }
+        bool  has_y() const { return this->has(Y); }
+        bool  has_z() const { return this->has(Z); }
+        bool  has_e() const { return this->has(E); }
+        bool  has_f() const { return this->has(F); }
+        float x() const { return m_axis[X]; }
+        float y() const { return m_axis[Y]; }
+        float z() const { return m_axis[Z]; }
+        float e() const { return m_axis[E]; }
+        float f() const { return m_axis[F]; }
+
+    private:
+        std::string      m_raw;
+        float            m_axis[NUM_AXES];
+        uint32_t         m_mask;
+        friend class GCodeReader;
     };
+
     typedef std::function<void(GCodeReader&, const GCodeLine&)> callback_t;
     
-    float X, Y, Z, E, F;
-    bool verbose;
-    callback_t callback; 
-    
-    GCodeReader() : X(0), Y(0), Z(0), E(0), F(0), verbose(false), m_extrusion_axis('E') {};
+    GCodeReader() : m_verbose(false), m_extrusion_axis('E') { memset(m_position, 0, sizeof(m_position)); }
     void apply_config(const GCodeConfig &config);
     void apply_config(const DynamicPrintConfig &config);
-    void parse(const std::string &gcode, callback_t callback);
-    void parse_line(std::string line, callback_t callback);
+
+    template<typename Callback>
+    void parse_buffer(const std::string &buffer, Callback callback)
+    {
+        const char *ptr = buffer.c_str();
+        GCodeLine gline;
+        while (*ptr != 0) {
+            gline.reset();
+            ptr = this->parse_line(ptr, gline, callback);
+        }
+    }
+
+    void parse_buffer(const std::string &buffer)
+        { this->parse_buffer(buffer, [](GCodeReader&, const GCodeReader::GCodeLine&){}); }
+
+    template<typename Callback>
+    const char* parse_line(const char *ptr, GCodeLine &gline, Callback &callback)
+    {
+        std::pair<const char*, const char*> cmd;
+        const char *end = parse_line_internal(ptr, gline, cmd);
+        callback(*this, gline);
+        update_coordinates(gline, cmd);
+        return end;
+    }
+
+    template<typename Callback>
+    void parse_line(const std::string &line, Callback callback)
+        { GCodeLine gline; this->parse_line(line.c_str(), gline, callback); }
+
     void parse_file(const std::string &file, callback_t callback);
-    
+
+    float& x()       { return m_position[X]; }
+    float  x() const { return m_position[X]; }
+    float& y()       { return m_position[Y]; }
+    float  y() const { return m_position[Y]; }
+    float& z()       { return m_position[Z]; }
+    float  z() const { return m_position[Z]; }
+    float& e()       { return m_position[E]; }
+    float  e() const { return m_position[E]; }
+    float& f()       { return m_position[F]; }
+    float  f() const { return m_position[F]; }
+
+    char   extrusion_axis() const { return m_extrusion_axis; }
+
 private:
+    const char* parse_line_internal(const char *ptr, GCodeLine &gline, std::pair<const char*, const char*> &command);
+    void        update_coordinates(GCodeLine &gline, std::pair<const char*, const char*> &command);
+
+    static bool         is_whitespace(char c)           { return c == ' ' || c == '\t'; }
+    static bool         is_end_of_line(char c)          { return c == '\r' || c == '\n' || c == 0; }
+    static bool         is_end_of_gcode_line(char c)    { return c == ';' || is_end_of_line(c); }
+    static bool         is_end_of_word(char c)          { return is_whitespace(c) || is_end_of_gcode_line(c); }
+    static const char*  skip_whitespaces(const char *c) { for (; is_whitespace(*c); ++ c); return c; }
+    static const char*  skip_word(const char *c)        { for (; ! is_end_of_word(*c); ++ c); return c; }
+
     GCodeConfig m_config;
-    char m_extrusion_axis;
+    char        m_extrusion_axis;
+    float       m_position[NUM_AXES];
+    bool        m_verbose;
 };
 
 } /* namespace Slic3r */
diff --git a/xs/src/libslic3r/GCodeSender.cpp b/xs/src/libslic3r/GCodeSender.cpp
index 504171288..bbeaf836d 100644
--- a/xs/src/libslic3r/GCodeSender.cpp
+++ b/xs/src/libslic3r/GCodeSender.cpp
@@ -7,16 +7,36 @@
 #include <boost/date_time/posix_time/posix_time.hpp>
 #include <boost/lexical_cast.hpp>
 
-#if defined(__APPLE__) || defined(__linux) || defined(__OpenBSD__)
+#if defined(__APPLE__) || defined(__OpenBSD__)
 #include <termios.h>
 #endif
-#if __APPLE__
+#ifdef __APPLE__
 #include <sys/ioctl.h>
 #include <IOKit/serial/ioss.h>
 #endif
-#ifdef __linux
+#ifdef __linux__
 #include <sys/ioctl.h>
-#include <linux/serial.h>
+#include <fcntl.h>
+#include "/usr/include/asm-generic/ioctls.h"
+
+/* The following definitions are kindly borrowed from:
+   /usr/include/asm-generic/termbits.h
+   Unfortunately we cannot just include that one because
+   it would redefine the "struct termios" already defined
+   the <termios.h> already included by Boost.ASIO. */
+#define K_NCCS 19
+struct termios2 {
+	tcflag_t c_iflag;
+	tcflag_t c_oflag;
+	tcflag_t c_cflag;
+	tcflag_t c_lflag;
+	cc_t c_line;
+	cc_t c_cc[K_NCCS];
+	speed_t c_ispeed;
+	speed_t c_ospeed;
+};
+#define BOTHER CBAUDEX
+
 #endif
 
 //#define DEBUG_SERIAL
@@ -47,26 +67,26 @@ GCodeSender::connect(std::string devname, unsigned int baud_rate)
     this->set_error_status(false);
     try {
         this->serial.open(devname);
+        
+        this->serial.set_option(boost::asio::serial_port_base::parity(boost::asio::serial_port_base::parity::odd));
+        this->serial.set_option(boost::asio::serial_port_base::character_size(boost::asio::serial_port_base::character_size(8)));
+        this->serial.set_option(boost::asio::serial_port_base::flow_control(boost::asio::serial_port_base::flow_control::none));
+        this->serial.set_option(boost::asio::serial_port_base::stop_bits(boost::asio::serial_port_base::stop_bits::one));
+        this->set_baud_rate(baud_rate);
+    
+        this->serial.close();
+        this->serial.open(devname);
+        this->serial.set_option(boost::asio::serial_port_base::parity(boost::asio::serial_port_base::parity::none));
+    
+        // set baud rate again because set_option overwrote it
+        this->set_baud_rate(baud_rate);
+        this->open = true;
+        this->reset();
     } catch (boost::system::system_error &) {
         this->set_error_status(true);
         return false;
     }
     
-    this->serial.set_option(boost::asio::serial_port_base::parity(boost::asio::serial_port_base::parity::odd));
-    this->serial.set_option(boost::asio::serial_port_base::character_size(boost::asio::serial_port_base::character_size(8)));
-    this->serial.set_option(boost::asio::serial_port_base::flow_control(boost::asio::serial_port_base::flow_control::none));
-    this->serial.set_option(boost::asio::serial_port_base::stop_bits(boost::asio::serial_port_base::stop_bits::one));
-    this->set_baud_rate(baud_rate);
-    
-    this->serial.close();
-    this->serial.open(devname);
-    this->serial.set_option(boost::asio::serial_port_base::parity(boost::asio::serial_port_base::parity::none));
-    
-    // set baud rate again because set_option overwrote it
-    this->set_baud_rate(baud_rate);
-    this->open = true;
-    this->reset();
-
     // a reset firmware expect line numbers to start again from 1
     this->sent = 0;
     this->last_sent.clear();
@@ -84,6 +104,11 @@ GCodeSender::connect(std::string devname, unsigned int baud_rate)
     boost::thread t(boost::bind(&boost::asio::io_service::run, &this->io));
     this->background_thread.swap(t);
     
+    // always send a M105 to check for connection because firmware might be silent on connect
+    //FIXME Vojtech: This is being sent too early, leading to line number synchronization issues,
+    // from which the GCodeSender never recovers.
+    // this->send("M105", true);
+    
     return true;
 }
 
@@ -104,27 +129,17 @@ GCodeSender::set_baud_rate(unsigned int baud_rate)
         ioctl(handle, IOSSIOSPEED, &newSpeed);
         ::tcsetattr(handle, TCSANOW, &ios);
 #elif __linux
-        termios ios;
-        ::tcgetattr(handle, &ios);
-        ::cfsetispeed(&ios, B38400);
-        ::cfsetospeed(&ios, B38400);
-        ::tcflush(handle, TCIFLUSH);
-        ::tcsetattr(handle, TCSANOW, &ios);
-
-        struct serial_struct ss;
-        ioctl(handle, TIOCGSERIAL, &ss);
-        ss.flags = (ss.flags & ~ASYNC_SPD_MASK) | ASYNC_SPD_CUST;
-        ss.custom_divisor = (ss.baud_base + (baud_rate / 2)) / baud_rate;
-        //cout << "bbase " << ss.baud_base << " div " << ss.custom_divisor;
-        long closestSpeed = ss.baud_base / ss.custom_divisor;
-        //cout << " Closest speed " << closestSpeed << endl;
-        ss.reserved_char[0] = 0;
-        if (closestSpeed < baud_rate * 98 / 100 || closestSpeed > baud_rate * 102 / 100) {
-            printf("Failed to set baud rate\n");
-        }
-
-        ioctl(handle, TIOCSSERIAL, &ss);
-		printf("< set_baud_rate: %u\n", baud_rate);
+        termios2 ios;
+        if (ioctl(handle, TCGETS2, &ios))
+            printf("Error in TCGETS2: %s\n", strerror(errno));
+        ios.c_ispeed = ios.c_ospeed = baud_rate;
+        ios.c_cflag &= ~CBAUD;
+        ios.c_cflag |= BOTHER | CLOCAL | CREAD;
+        ios.c_cc[VMIN] = 1; // Minimum of characters to read, prevents eof errors when 0 bytes are read
+        ios.c_cc[VTIME] = 1;
+        if (ioctl(handle, TCSETS2, &ios))
+            printf("Error in TCSETS2: %s\n", strerror(errno));
+		
 #elif __OpenBSD__
 		struct termios ios;
 		::tcgetattr(handle, &ios);
@@ -154,6 +169,7 @@ GCodeSender::disconnect()
     */
     
 #ifdef DEBUG_SERIAL
+    fs << "DISCONNECTED" << std::endl << std::flush;
     fs.close();
 #endif
 }
@@ -292,17 +308,20 @@ GCodeSender::on_read(const boost::system::error_code& error,
 {
     this->set_error_status(false);
     if (error) {
+        #ifdef __APPLE__
         if (error.value() == 45) {
             // OS X bug: http://osdir.com/ml/lib.boost.asio.user/2008-08/msg00004.html
             this->do_read();
-        } else {
-            // printf("ERROR: [%d] %s\n", error.value(), error.message().c_str());
-            // error can be true even because the serial port was closed.
-            // In this case it is not a real error, so ignore.
-            if (this->open) {
-                this->do_close();
-                this->set_error_status(true);
-            }
+            return;
+        }
+        #endif
+    
+        // printf("ERROR: [%d] %s\n", error.value(), error.message().c_str());
+        // error can be true even because the serial port was closed.
+        // In this case it is not a real error, so ignore.
+        if (this->open) {
+            this->do_close();
+            this->set_error_status(true);
         }
         return;
     }
@@ -339,7 +358,8 @@ GCodeSender::on_read(const boost::system::error_code& error,
             // extract the first number from line
             boost::algorithm::trim_left_if(line, !boost::algorithm::is_digit());
             size_t toresend = boost::lexical_cast<size_t>(line.substr(0, line.find_first_not_of("0123456789")));
-            if (toresend >= this->sent - this->last_sent.size()) {
+            ++ toresend; // N is 0-based
+            if (toresend >= this->sent - this->last_sent.size() && toresend < this->last_sent.size()) {
                 {
                     boost::lock_guard<boost::mutex> l(this->queue_mutex);
                     
@@ -457,8 +477,8 @@ GCodeSender::do_send()
     if (line.empty()) return;
     
     // compute full line
-    this->sent++;
     std::string full_line = "N" + boost::lexical_cast<std::string>(this->sent) + " " + line;
+    ++ this->sent;
     
     // calculate checksum
     int cs = 0;
diff --git a/xs/src/libslic3r/GCodeTimeEstimator.cpp b/xs/src/libslic3r/GCodeTimeEstimator.cpp
index c6fa353b4..22821a708 100644
--- a/xs/src/libslic3r/GCodeTimeEstimator.cpp
+++ b/xs/src/libslic3r/GCodeTimeEstimator.cpp
@@ -2,77 +2,1066 @@
 #include <boost/bind.hpp>
 #include <cmath>
 
+#include <Shiny/Shiny.h>
+
+static const float MMMIN_TO_MMSEC = 1.0f / 60.0f;
+static const float MILLISEC_TO_SEC = 0.001f;
+static const float INCHES_TO_MM = 25.4f;
+static const float DEFAULT_FEEDRATE = 1500.0f; // from Prusa Firmware (Marlin_main.cpp)
+static const float DEFAULT_ACCELERATION = 1500.0f; // Prusa Firmware 1_75mm_MK2
+static const float DEFAULT_RETRACT_ACCELERATION = 1500.0f; // Prusa Firmware 1_75mm_MK2
+static const float DEFAULT_AXIS_MAX_FEEDRATE[] = { 500.0f, 500.0f, 12.0f, 120.0f }; // Prusa Firmware 1_75mm_MK2
+static const float DEFAULT_AXIS_MAX_ACCELERATION[] = { 9000.0f, 9000.0f, 500.0f, 10000.0f }; // Prusa Firmware 1_75mm_MK2
+static const float DEFAULT_AXIS_MAX_JERK[] = { 10.0f, 10.0f, 0.2f, 2.5f }; // from Prusa Firmware (Configuration.h)
+static const float DEFAULT_MINIMUM_FEEDRATE = 0.0f; // from Prusa Firmware (Configuration_adv.h)
+static const float DEFAULT_MINIMUM_TRAVEL_FEEDRATE = 0.0f; // from Prusa Firmware (Configuration_adv.h)
+static const float DEFAULT_EXTRUDE_FACTOR_OVERRIDE_PERCENTAGE = 1.0f; // 100 percent
+
+static const float PREVIOUS_FEEDRATE_THRESHOLD = 0.0001f;
+
 namespace Slic3r {
 
-void
-GCodeTimeEstimator::parse(const std::string &gcode)
-{
-    GCodeReader::parse(gcode, boost::bind(&GCodeTimeEstimator::_parser, this, _1, _2));
-}
+    void GCodeTimeEstimator::Feedrates::reset()
+    {
+        feedrate = 0.0f;
+        safe_feedrate = 0.0f;
+        ::memset(axis_feedrate, 0, Num_Axis * sizeof(float));
+        ::memset(abs_axis_feedrate, 0, Num_Axis * sizeof(float));
+    }
 
-void
-GCodeTimeEstimator::parse_file(const std::string &file)
-{
-    GCodeReader::parse_file(file, boost::bind(&GCodeTimeEstimator::_parser, this, _1, _2));
-}
+    float GCodeTimeEstimator::Block::Trapezoid::acceleration_time(float acceleration) const
+    {
+        return acceleration_time_from_distance(feedrate.entry, accelerate_until, acceleration);
+    }
 
-void
-GCodeTimeEstimator::_parser(GCodeReader&, const GCodeReader::GCodeLine &line)
-{
-    // std::cout << "[" << this->time << "] " << line.raw << std::endl;
-    if (line.cmd == "G1") {
-        const float dist_XY = line.dist_XY();
-        const float new_F = line.new_F();
-        
-        if (dist_XY > 0) {
-            //this->time += dist_XY / new_F * 60;
-            this->time += _accelerated_move(dist_XY, new_F/60, this->acceleration);
-        } else {
-            //this->time += std::abs(line.dist_E()) / new_F * 60;
-            this->time += _accelerated_move(std::abs(line.dist_E()), new_F/60, this->acceleration);
+    float GCodeTimeEstimator::Block::Trapezoid::cruise_time() const
+    {
+        return (feedrate.cruise != 0.0f) ? cruise_distance() / feedrate.cruise : 0.0f;
+    }
+
+    float GCodeTimeEstimator::Block::Trapezoid::deceleration_time(float acceleration) const
+    {
+        return acceleration_time_from_distance(feedrate.cruise, (distance - decelerate_after), -acceleration);
+    }
+
+    float GCodeTimeEstimator::Block::Trapezoid::cruise_distance() const
+    {
+        return decelerate_after - accelerate_until;
+    }
+
+    float GCodeTimeEstimator::Block::Trapezoid::acceleration_time_from_distance(float initial_feedrate, float distance, float acceleration)
+    {
+        return (acceleration != 0.0f) ? (speed_from_distance(initial_feedrate, distance, acceleration) - initial_feedrate) / acceleration : 0.0f;
+    }
+
+    float GCodeTimeEstimator::Block::Trapezoid::speed_from_distance(float initial_feedrate, float distance, float acceleration)
+    {
+        // to avoid invalid negative numbers due to numerical imprecision 
+        float value = std::max(0.0f, sqr(initial_feedrate) + 2.0f * acceleration * distance);
+        return ::sqrt(value);
+    }
+
+    float GCodeTimeEstimator::Block::move_length() const
+    {
+        float length = ::sqrt(sqr(delta_pos[X]) + sqr(delta_pos[Y]) + sqr(delta_pos[Z]));
+        return (length > 0.0f) ? length : std::abs(delta_pos[E]);
+    }
+
+    float GCodeTimeEstimator::Block::is_extruder_only_move() const
+    {
+        return (delta_pos[X] == 0.0f) && (delta_pos[Y] == 0.0f) && (delta_pos[Z] == 0.0f) && (delta_pos[E] != 0.0f);
+    }
+
+    float GCodeTimeEstimator::Block::is_travel_move() const
+    {
+        return delta_pos[E] == 0.0f;
+    }
+
+    float GCodeTimeEstimator::Block::acceleration_time() const
+    {
+        return trapezoid.acceleration_time(acceleration);
+    }
+
+    float GCodeTimeEstimator::Block::cruise_time() const
+    {
+        return trapezoid.cruise_time();
+    }
+
+    float GCodeTimeEstimator::Block::deceleration_time() const
+    {
+        return trapezoid.deceleration_time(acceleration);
+    }
+
+    float GCodeTimeEstimator::Block::cruise_distance() const
+    {
+        return trapezoid.cruise_distance();
+    }
+
+    void GCodeTimeEstimator::Block::calculate_trapezoid()
+    {
+        float distance = move_length();
+
+        trapezoid.distance = distance;
+        trapezoid.feedrate = feedrate;
+
+        float accelerate_distance = estimate_acceleration_distance(feedrate.entry, feedrate.cruise, acceleration);
+        float decelerate_distance = estimate_acceleration_distance(feedrate.cruise, feedrate.exit, -acceleration);
+        float cruise_distance = distance - accelerate_distance - decelerate_distance;
+
+        // Not enough space to reach the nominal feedrate.
+        // This means no cruising, and we'll have to use intersection_distance() to calculate when to abort acceleration 
+        // and start braking in order to reach the exit_feedrate exactly at the end of this block.
+        if (cruise_distance < 0.0f)
+        {
+            accelerate_distance = clamp(0.0f, distance, intersection_distance(feedrate.entry, feedrate.exit, acceleration, distance));
+            cruise_distance = 0.0f;
+            trapezoid.feedrate.cruise = Trapezoid::speed_from_distance(feedrate.entry, accelerate_distance, acceleration);
         }
-        //this->time += std::abs(line.dist_Z()) / new_F * 60;
-        this->time += _accelerated_move(std::abs(line.dist_Z()), new_F/60, this->acceleration);
-    } else if (line.cmd == "M204" && line.has('S')) {
-        this->acceleration = line.get_float('S');
-    } else if (line.cmd == "G4") { // swell
-        if (line.has('S')) {
-            this->time += line.get_float('S');
-        } else if (line.has('P')) {
-            this->time += line.get_float('P')/1000;
+
+        trapezoid.accelerate_until = accelerate_distance;
+        trapezoid.decelerate_after = accelerate_distance + cruise_distance;
+    }
+
+    float GCodeTimeEstimator::Block::max_allowable_speed(float acceleration, float target_velocity, float distance)
+    {
+        // to avoid invalid negative numbers due to numerical imprecision 
+        float value = std::max(0.0f, sqr(target_velocity) - 2.0f * acceleration * distance);
+        return ::sqrt(value);
+    }
+
+    float GCodeTimeEstimator::Block::estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration)
+    {
+        return (acceleration == 0.0f) ? 0.0f : (sqr(target_rate) - sqr(initial_rate)) / (2.0f * acceleration);
+    }
+
+    float GCodeTimeEstimator::Block::intersection_distance(float initial_rate, float final_rate, float acceleration, float distance)
+    {
+        return (acceleration == 0.0f) ? 0.0f : (2.0f * acceleration * distance - sqr(initial_rate) + sqr(final_rate)) / (4.0f * acceleration);
+    }
+
+    GCodeTimeEstimator::GCodeTimeEstimator()
+    {
+        reset();
+        set_default();
+    }
+
+    void GCodeTimeEstimator::calculate_time_from_text(const std::string& gcode)
+    {
+        reset();
+
+        _parser.parse_buffer(gcode,
+            [this](GCodeReader &reader, const GCodeReader::GCodeLine &line)
+        { this->_process_gcode_line(reader, line); });
+
+        _calculate_time();
+
+        _reset_blocks();
+        _reset();
+    }
+
+    void GCodeTimeEstimator::calculate_time_from_file(const std::string& file)
+    {
+        reset();
+
+        _parser.parse_file(file, boost::bind(&GCodeTimeEstimator::_process_gcode_line, this, _1, _2));
+        _calculate_time();
+
+        _reset_blocks();
+        _reset();
+    }
+
+    void GCodeTimeEstimator::calculate_time_from_lines(const std::vector<std::string>& gcode_lines)
+    {
+        reset();
+
+        auto action = [this](GCodeReader &reader, const GCodeReader::GCodeLine &line)
+        { this->_process_gcode_line(reader, line); };
+        for (const std::string& line : gcode_lines)
+            _parser.parse_line(line, action);
+        _calculate_time();
+
+        _reset_blocks();
+        _reset();
+    }
+
+    void GCodeTimeEstimator::add_gcode_line(const std::string& gcode_line)
+    {
+        PROFILE_FUNC();
+        _parser.parse_line(gcode_line, 
+            [this](GCodeReader &reader, const GCodeReader::GCodeLine &line)
+        { this->_process_gcode_line(reader, line); });
+    }
+
+    void GCodeTimeEstimator::add_gcode_block(const char *ptr)
+    {
+        PROFILE_FUNC();
+        GCodeReader::GCodeLine gline;
+        auto action = [this](GCodeReader &reader, const GCodeReader::GCodeLine &line)
+        { this->_process_gcode_line(reader, line); };
+        for (; *ptr != 0;) {
+            gline.reset();
+            ptr = _parser.parse_line(ptr, gline, action);
+        }
+    }
+
+    void GCodeTimeEstimator::calculate_time()
+    {
+        PROFILE_FUNC();
+        _calculate_time();
+        _reset_blocks();
+        _reset();
+    }
+
+    void GCodeTimeEstimator::set_axis_position(EAxis axis, float position)
+    {
+        _state.axis[axis].position = position;
+    }
+
+    void GCodeTimeEstimator::set_axis_max_feedrate(EAxis axis, float feedrate_mm_sec)
+    {
+        _state.axis[axis].max_feedrate = feedrate_mm_sec;
+    }
+
+    void GCodeTimeEstimator::set_axis_max_acceleration(EAxis axis, float acceleration)
+    {
+        _state.axis[axis].max_acceleration = acceleration;
+    }
+
+    void GCodeTimeEstimator::set_axis_max_jerk(EAxis axis, float jerk)
+    {
+        _state.axis[axis].max_jerk = jerk;
+    }
+
+    float GCodeTimeEstimator::get_axis_position(EAxis axis) const
+    {
+        return _state.axis[axis].position;
+    }
+
+    float GCodeTimeEstimator::get_axis_max_feedrate(EAxis axis) const
+    {
+        return _state.axis[axis].max_feedrate;
+    }
+
+    float GCodeTimeEstimator::get_axis_max_acceleration(EAxis axis) const
+    {
+        return _state.axis[axis].max_acceleration;
+    }
+
+    float GCodeTimeEstimator::get_axis_max_jerk(EAxis axis) const
+    {
+        return _state.axis[axis].max_jerk;
+    }
+
+    void GCodeTimeEstimator::set_feedrate(float feedrate_mm_sec)
+    {
+        _state.feedrate = feedrate_mm_sec;
+    }
+
+    float GCodeTimeEstimator::get_feedrate() const
+    {
+        return _state.feedrate;
+    }
+
+    void GCodeTimeEstimator::set_acceleration(float acceleration_mm_sec2)
+    {
+        _state.acceleration = acceleration_mm_sec2;
+    }
+
+    float GCodeTimeEstimator::get_acceleration() const
+    {
+        return _state.acceleration;
+    }
+
+    void GCodeTimeEstimator::set_retract_acceleration(float acceleration_mm_sec2)
+    {
+        _state.retract_acceleration = acceleration_mm_sec2;
+    }
+
+    float GCodeTimeEstimator::get_retract_acceleration() const
+    {
+        return _state.retract_acceleration;
+    }
+
+    void GCodeTimeEstimator::set_minimum_feedrate(float feedrate_mm_sec)
+    {
+        _state.minimum_feedrate = feedrate_mm_sec;
+    }
+
+    float GCodeTimeEstimator::get_minimum_feedrate() const
+    {
+        return _state.minimum_feedrate;
+    }
+
+    void GCodeTimeEstimator::set_minimum_travel_feedrate(float feedrate_mm_sec)
+    {
+        _state.minimum_travel_feedrate = feedrate_mm_sec;
+    }
+
+    float GCodeTimeEstimator::get_minimum_travel_feedrate() const
+    {
+        return _state.minimum_travel_feedrate;
+    }
+
+    void GCodeTimeEstimator::set_extrude_factor_override_percentage(float percentage)
+    {
+        _state.extrude_factor_override_percentage = percentage;
+    }
+
+    float GCodeTimeEstimator::get_extrude_factor_override_percentage() const
+    {
+        return _state.extrude_factor_override_percentage;
+    }
+
+    void GCodeTimeEstimator::set_dialect(GCodeFlavor dialect)
+    {
+        _state.dialect = dialect;
+    }
+
+    GCodeFlavor GCodeTimeEstimator::get_dialect() const
+    {
+        return _state.dialect;
+    }
+
+    void GCodeTimeEstimator::set_units(GCodeTimeEstimator::EUnits units)
+    {
+        _state.units = units;
+    }
+
+    GCodeTimeEstimator::EUnits GCodeTimeEstimator::get_units() const
+    {
+        return _state.units;
+    }
+
+    void GCodeTimeEstimator::set_positioning_xyz_type(GCodeTimeEstimator::EPositioningType type)
+    {
+        _state.positioning_xyz_type = type;
+    }
+
+    GCodeTimeEstimator::EPositioningType GCodeTimeEstimator::get_positioning_xyz_type() const
+    {
+        return _state.positioning_xyz_type;
+    }
+
+    void GCodeTimeEstimator::set_positioning_e_type(GCodeTimeEstimator::EPositioningType type)
+    {
+        _state.positioning_e_type = type;
+    }
+
+    GCodeTimeEstimator::EPositioningType GCodeTimeEstimator::get_positioning_e_type() const
+    {
+        return _state.positioning_e_type;
+    }
+
+    void GCodeTimeEstimator::add_additional_time(float timeSec)
+    {
+        _state.additional_time += timeSec;
+    }
+
+    void GCodeTimeEstimator::set_additional_time(float timeSec)
+    {
+        _state.additional_time = timeSec;
+    }
+
+    float GCodeTimeEstimator::get_additional_time() const
+    {
+        return _state.additional_time;
+    }
+
+    void GCodeTimeEstimator::set_default()
+    {
+        set_units(Millimeters);
+        set_dialect(gcfRepRap);
+        set_positioning_xyz_type(Absolute);
+        set_positioning_e_type(Relative);
+
+        set_feedrate(DEFAULT_FEEDRATE);
+        set_acceleration(DEFAULT_ACCELERATION);
+        set_retract_acceleration(DEFAULT_RETRACT_ACCELERATION);
+        set_minimum_feedrate(DEFAULT_MINIMUM_FEEDRATE);
+        set_minimum_travel_feedrate(DEFAULT_MINIMUM_TRAVEL_FEEDRATE);
+        set_extrude_factor_override_percentage(DEFAULT_EXTRUDE_FACTOR_OVERRIDE_PERCENTAGE);
+
+        for (unsigned char a = X; a < Num_Axis; ++a)
+        {
+            EAxis axis = (EAxis)a;
+            set_axis_max_feedrate(axis, DEFAULT_AXIS_MAX_FEEDRATE[a]);
+            set_axis_max_acceleration(axis, DEFAULT_AXIS_MAX_ACCELERATION[a]);
+            set_axis_max_jerk(axis, DEFAULT_AXIS_MAX_JERK[a]);
+        }
+    }
+
+    void GCodeTimeEstimator::reset()
+    {
+        _time = 0.0f;
+        _reset_blocks();
+        _reset();
+    }
+
+    float GCodeTimeEstimator::get_time() const
+    {
+        return _time;
+    }
+
+    std::string GCodeTimeEstimator::get_time_hms() const
+    {
+        float timeinsecs = get_time();
+        int hours = (int)(timeinsecs / 3600.0f);
+        timeinsecs -= (float)hours * 3600.0f;
+        int minutes = (int)(timeinsecs / 60.0f);
+        timeinsecs -= (float)minutes * 60.0f;
+
+        char buffer[64];
+        if (hours > 0)
+            ::sprintf(buffer, "%dh %dm %ds", hours, minutes, (int)timeinsecs);
+        else if (minutes > 0)
+            ::sprintf(buffer, "%dm %ds", minutes, (int)timeinsecs);
+        else
+            ::sprintf(buffer, "%ds", (int)timeinsecs);
+
+        return buffer;
+    }
+
+    void GCodeTimeEstimator::_reset()
+    {
+        _curr.reset();
+        _prev.reset();
+
+        set_axis_position(X, 0.0f);
+        set_axis_position(Y, 0.0f);
+        set_axis_position(Z, 0.0f);
+
+        set_additional_time(0.0f);
+    }
+
+    void GCodeTimeEstimator::_reset_blocks()
+    {
+        _blocks.clear();
+    }
+
+    void GCodeTimeEstimator::_calculate_time()
+    {
+        _forward_pass();
+        _reverse_pass();
+        _recalculate_trapezoids();
+
+        _time += get_additional_time();
+
+        for (const Block& block : _blocks)
+        {
+            _time += block.acceleration_time();
+            _time += block.cruise_time();
+            _time += block.deceleration_time();
+        }
+    }
+
+    void GCodeTimeEstimator::_process_gcode_line(GCodeReader&, const GCodeReader::GCodeLine& line)
+    {
+        PROFILE_FUNC();
+        std::string cmd = line.cmd();
+        if (cmd.length() > 1)
+        {
+            switch (::toupper(cmd[0]))
+            {
+            case 'G':
+                {
+                    switch (::atoi(&cmd[1]))
+                    {
+                    case 1: // Move
+                        {
+                            _processG1(line);
+                            break;
+                        }
+                    case 4: // Dwell
+                        {
+                            _processG4(line);
+                            break;
+                        }
+                    case 20: // Set Units to Inches
+                        {
+                            _processG20(line);
+                            break;
+                        }
+                    case 21: // Set Units to Millimeters
+                        {
+                            _processG21(line);
+                            break;
+                        }
+                    case 28: // Move to Origin (Home)
+                        {
+                            _processG28(line);
+                            break;
+                        }
+                    case 90: // Set to Absolute Positioning
+                        {
+                            _processG90(line);
+                            break;
+                        }
+                    case 91: // Set to Relative Positioning
+                        {
+                            _processG91(line);
+                            break;
+                        }
+                    case 92: // Set Position
+                        {
+                            _processG92(line);
+                            break;
+                        }
+                    }
+
+                    break;
+                }
+            case 'M':
+                {
+                    switch (::atoi(&cmd[1]))
+                    {
+                    case 1: // Sleep or Conditional stop
+                        {
+                            _processM1(line);
+                            break;
+                        }
+                    case 82: // Set extruder to absolute mode
+                        {
+                            _processM82(line);
+                            break;
+                        }
+                    case 83: // Set extruder to relative mode
+                        {
+                            _processM83(line);
+                            break;
+                        }
+                    case 109: // Set Extruder Temperature and Wait
+                        {
+                            _processM109(line);
+                            break;
+                        }
+                    case 201: // Set max printing acceleration
+                        {
+                            _processM201(line);
+                            break;
+                        }
+                    case 203: // Set maximum feedrate
+                        {
+                            _processM203(line);
+                            break;
+                        }
+                    case 204: // Set default acceleration
+                        {
+                            _processM204(line);
+                            break;
+                        }
+                    case 205: // Advanced settings
+                        {
+                            _processM205(line);
+                            break;
+                        }
+                    case 221: // Set extrude factor override percentage
+                        {
+                            _processM221(line);
+                            break;
+                        }
+                    case 566: // Set allowable instantaneous speed change
+                        {
+                            _processM566(line);
+                            break;
+                        }
+                    }
+
+                    break;
+                }
+            }
+        }
+    }
+
+    // Returns the new absolute position on the given axis in dependence of the given parameters
+    float axis_absolute_position_from_G1_line(GCodeTimeEstimator::EAxis axis, const GCodeReader::GCodeLine& lineG1, GCodeTimeEstimator::EUnits units, GCodeTimeEstimator::EPositioningType type, float current_absolute_position)
+    {
+        float lengthsScaleFactor = (units == GCodeTimeEstimator::Inches) ? INCHES_TO_MM : 1.0f;
+        if (lineG1.has(Slic3r::Axis(axis)))
+        {
+            float ret = lineG1.value(Slic3r::Axis(axis)) * lengthsScaleFactor;
+            return (type == GCodeTimeEstimator::Absolute) ? ret : current_absolute_position + ret;
+        }
+        else
+            return current_absolute_position;
+    }
+
+    void GCodeTimeEstimator::_processG1(const GCodeReader::GCodeLine& line)
+    {
+        // updates axes positions from line
+        EUnits units = get_units();
+        float new_pos[Num_Axis];
+        for (unsigned char a = X; a < Num_Axis; ++a)
+        {
+            new_pos[a] = axis_absolute_position_from_G1_line((EAxis)a, line, units, (a == E) ? get_positioning_e_type() : get_positioning_xyz_type(), get_axis_position((EAxis)a));
+        }
+
+        // updates feedrate from line, if present
+        if (line.has_f())
+            set_feedrate(std::max(line.f() * MMMIN_TO_MMSEC, get_minimum_feedrate()));
+
+        // fills block data
+        Block block;
+
+        // calculates block movement deltas
+        float max_abs_delta = 0.0f;
+        for (unsigned char a = X; a < Num_Axis; ++a)
+        {
+            block.delta_pos[a] = new_pos[a] - get_axis_position((EAxis)a);
+            max_abs_delta = std::max(max_abs_delta, std::abs(block.delta_pos[a]));
+        }
+
+        // is it a move ?
+        if (max_abs_delta == 0.0f)
+            return;
+
+        // calculates block feedrate
+        _curr.feedrate = std::max(get_feedrate(), block.is_travel_move() ? get_minimum_travel_feedrate() : get_minimum_feedrate());
+
+        float distance = block.move_length();
+        float invDistance = 1.0f / distance;
+
+        float min_feedrate_factor = 1.0f;
+        for (unsigned char a = X; a < Num_Axis; ++a)
+        {
+            _curr.axis_feedrate[a] = _curr.feedrate * block.delta_pos[a] * invDistance;
+            if (a == E)
+                _curr.axis_feedrate[a] *= get_extrude_factor_override_percentage();
+
+            _curr.abs_axis_feedrate[a] = std::abs(_curr.axis_feedrate[a]);
+            if (_curr.abs_axis_feedrate[a] > 0.0f)
+                min_feedrate_factor = std::min(min_feedrate_factor, get_axis_max_feedrate((EAxis)a) / _curr.abs_axis_feedrate[a]);
+        }
+    
+        block.feedrate.cruise = min_feedrate_factor * _curr.feedrate;
+
+        for (unsigned char a = X; a < Num_Axis; ++a)
+        {
+            _curr.axis_feedrate[a] *= min_feedrate_factor;
+            _curr.abs_axis_feedrate[a] *= min_feedrate_factor;
+        }
+
+        // calculates block acceleration
+        float acceleration = block.is_extruder_only_move() ? get_retract_acceleration() : get_acceleration();
+
+        for (unsigned char a = X; a < Num_Axis; ++a)
+        {
+            float axis_max_acceleration = get_axis_max_acceleration((EAxis)a);
+            if (acceleration * std::abs(block.delta_pos[a]) * invDistance > axis_max_acceleration)
+                acceleration = axis_max_acceleration;
+        }
+
+        block.acceleration = acceleration;
+
+        // calculates block exit feedrate
+        _curr.safe_feedrate = block.feedrate.cruise;
+
+        for (unsigned char a = X; a < Num_Axis; ++a)
+        {
+            float axis_max_jerk = get_axis_max_jerk((EAxis)a);
+            if (_curr.abs_axis_feedrate[a] > axis_max_jerk)
+                _curr.safe_feedrate = std::min(_curr.safe_feedrate, axis_max_jerk);
+        }
+
+        block.feedrate.exit = _curr.safe_feedrate;
+
+        // calculates block entry feedrate
+        float vmax_junction = _curr.safe_feedrate;
+        if (!_blocks.empty() && (_prev.feedrate > PREVIOUS_FEEDRATE_THRESHOLD))
+        {
+            bool prev_speed_larger = _prev.feedrate > block.feedrate.cruise;
+            float smaller_speed_factor = prev_speed_larger ? (block.feedrate.cruise / _prev.feedrate) : (_prev.feedrate / block.feedrate.cruise);
+            // Pick the smaller of the nominal speeds. Higher speed shall not be achieved at the junction during coasting.
+            vmax_junction = prev_speed_larger ? block.feedrate.cruise : _prev.feedrate;
+
+            float v_factor = 1.0f;
+            bool limited = false;
+
+            for (unsigned char a = X; a < Num_Axis; ++a)
+            {
+                // Limit an axis. We have to differentiate coasting from the reversal of an axis movement, or a full stop.
+                float v_exit = _prev.axis_feedrate[a];
+                float v_entry = _curr.axis_feedrate[a];
+
+                if (prev_speed_larger)
+                    v_exit *= smaller_speed_factor;
+
+                if (limited)
+                {
+                    v_exit *= v_factor;
+                    v_entry *= v_factor;
+                }
+
+                // Calculate the jerk depending on whether the axis is coasting in the same direction or reversing a direction.
+                float jerk =
+                    (v_exit > v_entry) ?
+                    (((v_entry > 0.0f) || (v_exit < 0.0f)) ?
+                    // coasting
+                    (v_exit - v_entry) :
+                    // axis reversal
+                    std::max(v_exit, -v_entry)) :
+                    // v_exit <= v_entry
+                    (((v_entry < 0.0f) || (v_exit > 0.0f)) ?
+                    // coasting
+                    (v_entry - v_exit) :
+                    // axis reversal
+                    std::max(-v_exit, v_entry));
+
+                float axis_max_jerk = get_axis_max_jerk((EAxis)a);
+                if (jerk > axis_max_jerk)
+                {
+                    v_factor *= axis_max_jerk / jerk;
+                    limited = true;
+                }
+            }
+
+            if (limited)
+                vmax_junction *= v_factor;
+
+            // Now the transition velocity is known, which maximizes the shared exit / entry velocity while
+            // respecting the jerk factors, it may be possible, that applying separate safe exit / entry velocities will achieve faster prints.
+            float vmax_junction_threshold = vmax_junction * 0.99f;
+
+            // Not coasting. The machine will stop and start the movements anyway, better to start the segment from start.
+            if ((_prev.safe_feedrate > vmax_junction_threshold) && (_curr.safe_feedrate > vmax_junction_threshold))
+                vmax_junction = _curr.safe_feedrate;
+        }
+
+        float v_allowable = Block::max_allowable_speed(-acceleration, _curr.safe_feedrate, distance);
+        block.feedrate.entry = std::min(vmax_junction, v_allowable);
+
+        block.max_entry_speed = vmax_junction;
+        block.flags.nominal_length = (block.feedrate.cruise <= v_allowable);
+        block.flags.recalculate = true;
+        block.safe_feedrate = _curr.safe_feedrate;
+
+        // calculates block trapezoid
+        block.calculate_trapezoid();
+
+        // updates previous
+        _prev = _curr;
+
+        // updates axis positions
+        for (unsigned char a = X; a < Num_Axis; ++a)
+        {
+            set_axis_position((EAxis)a, new_pos[a]);
+        }
+
+        // adds block to blocks list
+        _blocks.emplace_back(block);
+    }
+
+    void GCodeTimeEstimator::_processG4(const GCodeReader::GCodeLine& line)
+    {
+        GCodeFlavor dialect = get_dialect();
+
+        float value;
+        if (line.has_value('P', value))
+            add_additional_time(value * MILLISEC_TO_SEC);
+
+        // see: http://reprap.org/wiki/G-code#G4:_Dwell
+        if ((dialect == gcfRepetier) ||
+            (dialect == gcfMarlin) ||
+            (dialect == gcfSmoothie) ||
+            (dialect == gcfRepRap))
+        {
+            if (line.has_value('S', value))
+                add_additional_time(value);
+        }
+
+        _simulate_st_synchronize();
+    }
+
+    void GCodeTimeEstimator::_processG20(const GCodeReader::GCodeLine& line)
+    {
+        set_units(Inches);
+    }
+
+    void GCodeTimeEstimator::_processG21(const GCodeReader::GCodeLine& line)
+    {
+        set_units(Millimeters);
+    }
+
+    void GCodeTimeEstimator::_processG28(const GCodeReader::GCodeLine& line)
+    {
+        // TODO
+    }
+
+    void GCodeTimeEstimator::_processG90(const GCodeReader::GCodeLine& line)
+    {
+        set_positioning_xyz_type(Absolute);
+    }
+
+    void GCodeTimeEstimator::_processG91(const GCodeReader::GCodeLine& line)
+    {
+        // TODO: THERE ARE DIALECT VARIANTS
+
+        set_positioning_xyz_type(Relative);
+    }
+
+    void GCodeTimeEstimator::_processG92(const GCodeReader::GCodeLine& line)
+    {
+        float lengthsScaleFactor = (get_units() == Inches) ? INCHES_TO_MM : 1.0f;
+        bool anyFound = false;
+
+        if (line.has_x())
+        {
+            set_axis_position(X, line.x() * lengthsScaleFactor);
+            anyFound = true;
+        }
+
+        if (line.has_y())
+        {
+            set_axis_position(Y, line.y() * lengthsScaleFactor);
+            anyFound = true;
+        }
+
+        if (line.has_z())
+        {
+            set_axis_position(Z, line.z() * lengthsScaleFactor);
+            anyFound = true;
+        }
+
+        if (line.has_e())
+        {
+            set_axis_position(E, line.e() * lengthsScaleFactor);
+            anyFound = true;
+        }
+        else
+            _simulate_st_synchronize();
+
+        if (!anyFound)
+        {
+            for (unsigned char a = X; a < Num_Axis; ++a)
+            {
+                set_axis_position((EAxis)a, 0.0f);
+            }
+        }
+    }
+
+    void GCodeTimeEstimator::_processM1(const GCodeReader::GCodeLine& line)
+    {
+        _simulate_st_synchronize();
+    }
+
+    void GCodeTimeEstimator::_processM82(const GCodeReader::GCodeLine& line)
+    {
+        set_positioning_e_type(Absolute);
+    }
+
+    void GCodeTimeEstimator::_processM83(const GCodeReader::GCodeLine& line)
+    {
+        set_positioning_e_type(Relative);
+    }
+
+    void GCodeTimeEstimator::_processM109(const GCodeReader::GCodeLine& line)
+    {
+        // TODO
+    }
+
+    void GCodeTimeEstimator::_processM201(const GCodeReader::GCodeLine& line)
+    {
+        GCodeFlavor dialect = get_dialect();
+
+        // see http://reprap.org/wiki/G-code#M201:_Set_max_printing_acceleration
+        float factor = ((dialect != gcfRepRap) && (get_units() == GCodeTimeEstimator::Inches)) ? INCHES_TO_MM : 1.0f;
+
+        if (line.has_x())
+            set_axis_max_acceleration(X, line.x() * factor);
+
+        if (line.has_y())
+            set_axis_max_acceleration(Y, line.y() * factor);
+
+        if (line.has_z())
+            set_axis_max_acceleration(Z, line.z() * factor);
+
+        if (line.has_e())
+            set_axis_max_acceleration(E, line.e() * factor);
+    }
+
+    void GCodeTimeEstimator::_processM203(const GCodeReader::GCodeLine& line)
+    {
+        GCodeFlavor dialect = get_dialect();
+
+        // see http://reprap.org/wiki/G-code#M203:_Set_maximum_feedrate
+        if (dialect == gcfRepetier)
+            return;
+
+        // see http://reprap.org/wiki/G-code#M203:_Set_maximum_feedrate
+        float factor = (dialect == gcfMarlin) ? 1.0f : MMMIN_TO_MMSEC;
+
+        if (line.has_x())
+            set_axis_max_feedrate(X, line.x() * factor);
+
+        if (line.has_y())
+            set_axis_max_feedrate(Y, line.y() * factor);
+
+        if (line.has_z())
+            set_axis_max_feedrate(Z, line.z() * factor);
+
+        if (line.has_e())
+            set_axis_max_feedrate(E, line.e() * factor);
+    }
+
+    void GCodeTimeEstimator::_processM204(const GCodeReader::GCodeLine& line)
+    {
+        float value;
+        if (line.has_value('S', value))
+            set_acceleration(value);
+
+        if (line.has_value('T', value))
+            set_retract_acceleration(value);
+    }
+
+    void GCodeTimeEstimator::_processM205(const GCodeReader::GCodeLine& line)
+    {
+        if (line.has_x())
+        {
+            float max_jerk = line.x();
+            set_axis_max_jerk(X, max_jerk);
+            set_axis_max_jerk(Y, max_jerk);
+        }
+
+        if (line.has_y())
+            set_axis_max_jerk(Y, line.y());
+
+        if (line.has_z())
+            set_axis_max_jerk(Z, line.z());
+
+        if (line.has_e())
+            set_axis_max_jerk(E, line.e());
+
+        float value;
+        if (line.has_value('S', value))
+            set_minimum_feedrate(value);
+
+        if (line.has_value('T', value))
+            set_minimum_travel_feedrate(value);
+    }
+
+    void GCodeTimeEstimator::_processM221(const GCodeReader::GCodeLine& line)
+    {
+        float value_s;
+        float value_t;
+        if (line.has_value('S', value_s) && !line.has_value('T', value_t))
+            set_extrude_factor_override_percentage(value_s * 0.01f);
+    }
+
+    void GCodeTimeEstimator::_processM566(const GCodeReader::GCodeLine& line)
+    {
+        if (line.has_x())
+            set_axis_max_jerk(X, line.x() * MMMIN_TO_MMSEC);
+
+        if (line.has_y())
+            set_axis_max_jerk(Y, line.y() * MMMIN_TO_MMSEC);
+
+        if (line.has_z())
+            set_axis_max_jerk(Z, line.z() * MMMIN_TO_MMSEC);
+
+        if (line.has_e())
+            set_axis_max_jerk(E, line.e() * MMMIN_TO_MMSEC);
+    }
+
+    void GCodeTimeEstimator::_simulate_st_synchronize()
+    {
+        _calculate_time();
+        _reset_blocks();
+    }
+
+    void GCodeTimeEstimator::_forward_pass()
+    {
+        if (_blocks.size() > 1)
+        {
+            for (unsigned int i = 0; i < (unsigned int)_blocks.size() - 1; ++i)
+            {
+                _planner_forward_pass_kernel(_blocks[i], _blocks[i + 1]);
+            }
+        }
+    }
+
+    void GCodeTimeEstimator::_reverse_pass()
+    {
+        if (_blocks.size() > 1)
+        {
+            for (int i = (int)_blocks.size() - 1; i >= 1;  --i)
+            {
+                _planner_reverse_pass_kernel(_blocks[i - 1], _blocks[i]);
+            }
+        }
+    }
+
+    void GCodeTimeEstimator::_planner_forward_pass_kernel(Block& prev, Block& curr)
+    {
+        // If the previous block is an acceleration block, but it is not long enough to complete the
+        // full speed change within the block, we need to adjust the entry speed accordingly. Entry
+        // speeds have already been reset, maximized, and reverse planned by reverse planner.
+        // If nominal length is true, max junction speed is guaranteed to be reached. No need to recheck.
+        if (!prev.flags.nominal_length)
+        {
+            if (prev.feedrate.entry < curr.feedrate.entry)
+            {
+                float entry_speed = std::min(curr.feedrate.entry, Block::max_allowable_speed(-prev.acceleration, prev.feedrate.entry, prev.move_length()));
+
+                // Check for junction speed change
+                if (curr.feedrate.entry != entry_speed)
+                {
+                    curr.feedrate.entry = entry_speed;
+                    curr.flags.recalculate = true;
+                }
+            }
+        }
+    }
+
+    void GCodeTimeEstimator::_planner_reverse_pass_kernel(Block& curr, Block& next)
+    {
+        // If entry speed is already at the maximum entry speed, no need to recheck. Block is cruising.
+        // If not, block in state of acceleration or deceleration. Reset entry speed to maximum and
+        // check for maximum allowable speed reductions to ensure maximum possible planned speed.
+        if (curr.feedrate.entry != curr.max_entry_speed)
+        {
+            // If nominal length true, max junction speed is guaranteed to be reached. Only compute
+            // for max allowable speed if block is decelerating and nominal length is false.
+            if (!curr.flags.nominal_length && (curr.max_entry_speed > next.feedrate.entry))
+                curr.feedrate.entry = std::min(curr.max_entry_speed, Block::max_allowable_speed(-curr.acceleration, next.feedrate.entry, curr.move_length()));
+            else
+                curr.feedrate.entry = curr.max_entry_speed;
+
+            curr.flags.recalculate = true;
+        }
+    }
+
+    void GCodeTimeEstimator::_recalculate_trapezoids()
+    {
+        Block* curr = nullptr;
+        Block* next = nullptr;
+
+        for (Block& b : _blocks)
+        {
+            curr = next;
+            next = &b;
+
+            if (curr != nullptr)
+            {
+                // Recalculate if current block entry or exit junction speed has changed.
+                if (curr->flags.recalculate || next->flags.recalculate)
+                {
+                    // NOTE: Entry and exit factors always > 0 by all previous logic operations.
+                    Block block = *curr;
+                    block.feedrate.exit = next->feedrate.entry;
+                    block.calculate_trapezoid();
+                    curr->trapezoid = block.trapezoid;
+                    curr->flags.recalculate = false; // Reset current only to ensure next trapezoid is computed
+                }
+            }
+        }
+
+        // Last/newest block in buffer. Always recalculated.
+        if (next != nullptr)
+        {
+            Block block = *next;
+            block.feedrate.exit = next->safe_feedrate;
+            block.calculate_trapezoid();
+            next->trapezoid = block.trapezoid;
+            next->flags.recalculate = false;
         }
     }
 }
-
-// Wildly optimistic acceleration "bell" curve modeling.
-// Returns an estimate of how long the move with a given accel
-// takes in seconds.
-// It is assumed that the movement is smooth and uniform.
-float
-GCodeTimeEstimator::_accelerated_move(double length, double v, double acceleration) 
-{
-    // for half of the move, there are 2 zones, where the speed is increasing/decreasing and 
-    // where the speed is constant.
-    // Since the slowdown is assumed to be uniform, calculate the average velocity for half of the 
-    // expected displacement.
-    // final velocity v = a*t => a * (dx / 0.5v) => v^2 = 2*a*dx
-    // v_avg = 0.5v => 2*v_avg = v
-    // d_x = v_avg*t => t = d_x / v_avg
-    acceleration = (acceleration == 0.0 ? 4000.0 : acceleration); // Set a default accel to use for print time in case it's 0 somehow.
-    auto half_length = length / 2.0;
-    auto t_init = v / acceleration; // time to final velocity
-    auto dx_init = (0.5*v*t_init); // Initial displacement for the time to get to final velocity
-    auto t = 0.0;
-    if (half_length >= dx_init) {
-        half_length -= (0.5*v*t_init);
-        t += t_init;
-        t += (half_length / v); // rest of time is at constant speed.
-    } else {
-        // If too much displacement for the expected final velocity, we don't hit the max, so reduce 
-        // the average velocity to fit the displacement we actually are looking for.
-        t += std::sqrt(std::abs(length) * 2.0 * acceleration) / acceleration;
-    }
-    return 2.0*t; // cut in half before, so double to get full time spent.
-}
-
-}
diff --git a/xs/src/libslic3r/GCodeTimeEstimator.hpp b/xs/src/libslic3r/GCodeTimeEstimator.hpp
index dd301c929..fb41a2753 100644
--- a/xs/src/libslic3r/GCodeTimeEstimator.hpp
+++ b/xs/src/libslic3r/GCodeTimeEstimator.hpp
@@ -2,22 +2,323 @@
 #define slic3r_GCodeTimeEstimator_hpp_
 
 #include "libslic3r.h"
+#include "PrintConfig.hpp"
 #include "GCodeReader.hpp"
 
 namespace Slic3r {
 
-class GCodeTimeEstimator : public GCodeReader {
+    //
+    // Some of the algorithms used by class GCodeTimeEstimator were inpired by
+    // Cura Engine's class TimeEstimateCalculator
+    // https://github.com/Ultimaker/CuraEngine/blob/master/src/timeEstimate.h
+    //
+    class GCodeTimeEstimator
+    {
     public:
-    float time = 0;  // in seconds
-    
-    void parse(const std::string &gcode);
-    void parse_file(const std::string &file);
-    
-    protected:
-    float acceleration = 9000;
-    void _parser(GCodeReader&, const GCodeReader::GCodeLine &line);
-    static float _accelerated_move(double length, double v, double acceleration);
-};
+        enum EUnits : unsigned char
+        {
+            Millimeters,
+            Inches
+        };
+
+        enum EAxis : unsigned char
+        {
+            X,
+            Y,
+            Z,
+            E,
+            Num_Axis
+        };
+
+        enum EPositioningType : unsigned char
+        {
+            Absolute,
+            Relative
+        };
+
+    private:
+        struct Axis
+        {
+            float position;         // mm
+            float max_feedrate;     // mm/s
+            float max_acceleration; // mm/s^2
+            float max_jerk;         // mm/s
+        };
+
+        struct Feedrates
+        {
+            float feedrate;                    // mm/s
+            float axis_feedrate[Num_Axis];     // mm/s
+            float abs_axis_feedrate[Num_Axis]; // mm/s
+            float safe_feedrate;               // mm/s
+
+            void reset();
+        };
+
+        struct State
+        {
+            GCodeFlavor dialect;
+            EUnits units;
+            EPositioningType positioning_xyz_type;
+            EPositioningType positioning_e_type;
+            Axis axis[Num_Axis];
+            float feedrate;                     // mm/s
+            float acceleration;                 // mm/s^2
+            float retract_acceleration;         // mm/s^2
+            float additional_time;              // s
+            float minimum_feedrate;             // mm/s
+            float minimum_travel_feedrate;      // mm/s
+            float extrude_factor_override_percentage; 
+        };
+
+    public:
+        struct Block
+        {
+            struct FeedrateProfile
+            {
+                float entry;  // mm/s
+                float cruise; // mm/s
+                float exit;   // mm/s
+            };
+
+            struct Trapezoid
+            {
+                float distance;         // mm
+                float accelerate_until; // mm
+                float decelerate_after; // mm
+                FeedrateProfile feedrate;
+
+                float acceleration_time(float acceleration) const;
+                float cruise_time() const;
+                float deceleration_time(float acceleration) const;
+                float cruise_distance() const;
+
+                // This function gives the time needed to accelerate from an initial speed to reach a final distance.
+                static float acceleration_time_from_distance(float initial_feedrate, float distance, float acceleration);
+
+                // This function gives the final speed while accelerating at the given constant acceleration from the given initial speed along the given distance.
+                static float speed_from_distance(float initial_feedrate, float distance, float acceleration);
+            };
+
+            struct Flags
+            {
+                bool recalculate;
+                bool nominal_length;
+            };
+
+            Flags flags;
+
+            float delta_pos[Num_Axis]; // mm
+            float acceleration;        // mm/s^2
+            float max_entry_speed;     // mm/s
+            float safe_feedrate;       // mm/s
+
+            FeedrateProfile feedrate;
+            Trapezoid trapezoid;
+
+            // Returns the length of the move covered by this block, in mm
+            float move_length() const;
+
+            // Returns true if this block is a retract/unretract move only
+            float is_extruder_only_move() const;
+
+            // Returns true if this block is a move with no extrusion
+            float is_travel_move() const;
+
+            // Returns the time spent accelerating toward cruise speed, in seconds
+            float acceleration_time() const;
+
+            // Returns the time spent at cruise speed, in seconds
+            float cruise_time() const;
+
+            // Returns the time spent decelerating from cruise speed, in seconds
+            float deceleration_time() const;
+
+            // Returns the distance covered at cruise speed, in mm
+            float cruise_distance() const;
+
+            // Calculates this block's trapezoid
+            void calculate_trapezoid();
+
+            // Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the 
+            // acceleration within the allotted distance.
+            static float max_allowable_speed(float acceleration, float target_velocity, float distance);
+
+            // Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the given acceleration:
+            static float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration);
+
+            // This function gives you the point at which you must start braking (at the rate of -acceleration) if 
+            // you started at speed initial_rate and accelerated until this point and want to end at the final_rate after
+            // a total travel of distance. This can be used to compute the intersection point between acceleration and
+            // deceleration in the cases where the trapezoid has no plateau (i.e. never reaches maximum speed)
+            static float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance);
+        };
+
+        typedef std::vector<Block> BlocksList;
+
+    private:
+        GCodeReader _parser;
+        State _state;
+        Feedrates _curr;
+        Feedrates _prev;
+        BlocksList _blocks;
+        float _time; // s
+
+    public:
+        GCodeTimeEstimator();
+
+        // Calculates the time estimate from the given gcode in string format
+        void calculate_time_from_text(const std::string& gcode);
+
+        // Calculates the time estimate from the gcode contained in the file with the given filename
+        void calculate_time_from_file(const std::string& file);
+
+        // Calculates the time estimate from the gcode contained in given list of gcode lines
+        void calculate_time_from_lines(const std::vector<std::string>& gcode_lines);
+
+        // Adds the given gcode line
+        void add_gcode_line(const std::string& gcode_line);
+
+        void add_gcode_block(const char *ptr);
+        void add_gcode_block(const std::string &str) { this->add_gcode_block(str.c_str()); }
+
+        // Calculates the time estimate from the gcode lines added using add_gcode_line()
+        void calculate_time();
+
+        // Set current position on the given axis with the given value
+        void set_axis_position(EAxis axis, float position);
+
+        void set_axis_max_feedrate(EAxis axis, float feedrate_mm_sec);
+        void set_axis_max_acceleration(EAxis axis, float acceleration);
+        void set_axis_max_jerk(EAxis axis, float jerk);
+
+        // Returns current position on the given axis
+        float get_axis_position(EAxis axis) const;
+
+        float get_axis_max_feedrate(EAxis axis) const;
+        float get_axis_max_acceleration(EAxis axis) const;
+        float get_axis_max_jerk(EAxis axis) const;
+
+        void set_feedrate(float feedrate_mm_sec);
+        float get_feedrate() const;
+
+        void set_acceleration(float acceleration_mm_sec2);
+        float get_acceleration() const;
+
+        void set_retract_acceleration(float acceleration_mm_sec2);
+        float get_retract_acceleration() const;
+
+        void set_minimum_feedrate(float feedrate_mm_sec);
+        float get_minimum_feedrate() const;
+
+        void set_minimum_travel_feedrate(float feedrate_mm_sec);
+        float get_minimum_travel_feedrate() const;
+
+        void set_extrude_factor_override_percentage(float percentage);
+        float get_extrude_factor_override_percentage() const;
+
+        void set_dialect(GCodeFlavor dialect);
+        GCodeFlavor get_dialect() const;
+
+        void set_units(EUnits units);
+        EUnits get_units() const;
+
+        void set_positioning_xyz_type(EPositioningType type);
+        EPositioningType get_positioning_xyz_type() const;
+
+        void set_positioning_e_type(EPositioningType type);
+        EPositioningType get_positioning_e_type() const;
+
+        void add_additional_time(float timeSec);
+        void set_additional_time(float timeSec);
+        float get_additional_time() const;
+
+        void set_default();
+
+        // Call this method before to start adding lines using add_gcode_line() when reusing an instance of GCodeTimeEstimator
+        void reset();
+
+        // Returns the estimated time, in seconds
+        float get_time() const;
+
+        // Returns the estimated time, in format HHh MMm SSs
+        std::string get_time_hms() const;
+
+    private:
+        void _reset();
+        void _reset_blocks();
+
+        // Calculates the time estimate
+        void _calculate_time();
+
+        // Processes the given gcode line
+        void _process_gcode_line(GCodeReader&, const GCodeReader::GCodeLine& line);
+
+        // Move
+        void _processG1(const GCodeReader::GCodeLine& line);
+
+        // Dwell
+        void _processG4(const GCodeReader::GCodeLine& line);
+
+        // Set Units to Inches
+        void _processG20(const GCodeReader::GCodeLine& line);
+
+        // Set Units to Millimeters
+        void _processG21(const GCodeReader::GCodeLine& line);
+
+        // Move to Origin (Home)
+        void _processG28(const GCodeReader::GCodeLine& line);
+
+        // Set to Absolute Positioning
+        void _processG90(const GCodeReader::GCodeLine& line);
+
+        // Set to Relative Positioning
+        void _processG91(const GCodeReader::GCodeLine& line);
+
+        // Set Position
+        void _processG92(const GCodeReader::GCodeLine& line);
+
+        // Sleep or Conditional stop
+        void _processM1(const GCodeReader::GCodeLine& line);
+
+        // Set extruder to absolute mode
+        void _processM82(const GCodeReader::GCodeLine& line);
+
+        // Set extruder to relative mode
+        void _processM83(const GCodeReader::GCodeLine& line);
+
+        // Set Extruder Temperature and Wait
+        void _processM109(const GCodeReader::GCodeLine& line);
+
+        // Set max printing acceleration
+        void _processM201(const GCodeReader::GCodeLine& line);
+
+        // Set maximum feedrate
+        void _processM203(const GCodeReader::GCodeLine& line);
+
+        // Set default acceleration
+        void _processM204(const GCodeReader::GCodeLine& line);
+
+        // Advanced settings
+        void _processM205(const GCodeReader::GCodeLine& line);
+
+        // Set extrude factor override percentage
+        void _processM221(const GCodeReader::GCodeLine& line);
+
+        // Set allowable instantaneous speed change
+        void _processM566(const GCodeReader::GCodeLine& line);
+
+        // Simulates firmware st_synchronize() call
+        void _simulate_st_synchronize();
+
+        void _forward_pass();
+        void _reverse_pass();
+
+        void _planner_forward_pass_kernel(Block& prev, Block& curr);
+        void _planner_reverse_pass_kernel(Block& curr, Block& next);
+
+        void _recalculate_trapezoids();
+    };
 
 } /* namespace Slic3r */
 
diff --git a/xs/src/libslic3r/GCodeWriter.cpp b/xs/src/libslic3r/GCodeWriter.cpp
index abf55114b..cbe94f317 100644
--- a/xs/src/libslic3r/GCodeWriter.cpp
+++ b/xs/src/libslic3r/GCodeWriter.cpp
@@ -42,7 +42,7 @@ std::string GCodeWriter::preamble()
         gcode << "G21 ; set units to millimeters\n";
         gcode << "G90 ; use absolute coordinates\n";
     }
-    if (FLAVOR_IS(gcfRepRap) || FLAVOR_IS(gcfTeacup) || FLAVOR_IS(gcfRepetier) || FLAVOR_IS(gcfSmoothie)) {
+    if (FLAVOR_IS(gcfRepRap) || FLAVOR_IS(gcfMarlin) || FLAVOR_IS(gcfTeacup) || FLAVOR_IS(gcfRepetier) || FLAVOR_IS(gcfSmoothie)) {
         if (this->config.use_relative_e_distances) {
             gcode << "M83 ; use relative distances for extrusion\n";
         } else {
diff --git a/xs/src/libslic3r/Line.cpp b/xs/src/libslic3r/Line.cpp
index c7afc80c7..e9d5d7742 100644
--- a/xs/src/libslic3r/Line.cpp
+++ b/xs/src/libslic3r/Line.cpp
@@ -218,6 +218,16 @@ Line::ccw(const Point& point) const
     return point.ccw(*this);
 }
 
+double Line3::length() const
+{
+    return a.distance_to(b);
+}
+
+Vector3 Line3::vector() const
+{
+    return Vector3(b.x - a.x, b.y - a.y, b.z - a.z);
+}
+
 Pointf3
 Linef3::intersect_plane(double z) const
 {
diff --git a/xs/src/libslic3r/Line.hpp b/xs/src/libslic3r/Line.hpp
index 1be508f11..4826017ab 100644
--- a/xs/src/libslic3r/Line.hpp
+++ b/xs/src/libslic3r/Line.hpp
@@ -7,10 +7,12 @@
 namespace Slic3r {
 
 class Line;
+class Line3;
 class Linef3;
 class Polyline;
 class ThickLine;
 typedef std::vector<Line> Lines;
+typedef std::vector<Line3> Lines3;
 typedef std::vector<ThickLine> ThickLines;
 
 class Line
@@ -56,6 +58,19 @@ class ThickLine : public Line
     ThickLine(Point _a, Point _b) : Line(_a, _b), a_width(0), b_width(0) {};
 };
 
+class Line3
+{
+public:
+    Point3 a;
+    Point3 b;
+
+    Line3() {}
+    Line3(const Point3& _a, const Point3& _b) : a(_a), b(_b) {}
+
+    double length() const;
+    Vector3 vector() const;
+};
+
 class Linef
 {
     public:
diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp
index 88a0b8279..f65707ccb 100644
--- a/xs/src/libslic3r/Model.cpp
+++ b/xs/src/libslic3r/Model.cpp
@@ -5,6 +5,7 @@
 #include "Format/OBJ.hpp"
 #include "Format/PRUS.hpp"
 #include "Format/STL.hpp"
+#include "Format/3mf.hpp"
 
 #include <float.h>
 
@@ -46,16 +47,16 @@ Model Model::read_from_file(const std::string &input_file, bool add_default_inst
         result = load_stl(input_file.c_str(), &model);
     else if (boost::algorithm::iends_with(input_file, ".obj"))
         result = load_obj(input_file.c_str(), &model);
-    else if (boost::algorithm::iends_with(input_file, ".amf") ||
-               boost::algorithm::iends_with(input_file, ".amf.xml"))
-        result = load_amf(input_file.c_str(), &model);
+    else if (!boost::algorithm::iends_with(input_file, ".zip.amf") && (boost::algorithm::iends_with(input_file, ".amf") ||
+        boost::algorithm::iends_with(input_file, ".amf.xml")))
+        result = load_amf(input_file.c_str(), nullptr, &model);
 #ifdef SLIC3R_PRUS
     else if (boost::algorithm::iends_with(input_file, ".prusa"))
         result = load_prus(input_file.c_str(), &model);
 #endif /* SLIC3R_PRUS */
     else
         throw std::runtime_error("Unknown file format. Input file must have .stl, .obj, .amf(.xml) or .prusa extension.");
-    
+
     if (! result)
         throw std::runtime_error("Loading of a model file failed.");
 
@@ -71,6 +72,33 @@ Model Model::read_from_file(const std::string &input_file, bool add_default_inst
     return model;
 }
 
+Model Model::read_from_archive(const std::string &input_file, PresetBundle* bundle, bool add_default_instances)
+{
+    Model model;
+
+    bool result = false;
+    if (boost::algorithm::iends_with(input_file, ".3mf"))
+        result = load_3mf(input_file.c_str(), bundle, &model);
+    else if (boost::algorithm::iends_with(input_file, ".zip.amf"))
+        result = load_amf(input_file.c_str(), bundle, &model);
+    else
+        throw std::runtime_error("Unknown file format. Input file must have .3mf or .zip.amf extension.");
+
+    if (!result)
+        throw std::runtime_error("Loading of a model file failed.");
+
+    if (model.objects.empty())
+        throw std::runtime_error("The supplied file couldn't be read because it's empty");
+
+    for (ModelObject *o : model.objects)
+        o->input_file = input_file;
+
+    if (add_default_instances)
+        model.add_default_instances();
+
+    return model;
+}
+
 ModelObject* Model::add_object()
 {
     this->objects.emplace_back(new ModelObject(this));
@@ -115,6 +143,23 @@ void Model::delete_object(size_t idx)
     this->objects.erase(i);
 }
 
+void Model::delete_object(ModelObject* object)
+{
+    if (object == nullptr)
+        return;
+
+    for (ModelObjectPtrs::iterator it = objects.begin(); it != objects.end(); ++it)
+    {
+        ModelObject* obj = *it;
+        if (obj == object)
+        {
+            delete obj;
+            objects.erase(it);
+            return;
+        }
+    }
+}
+
 void Model::clear_objects()
 {
     for (ModelObject *o : this->objects)
@@ -607,6 +652,20 @@ void ModelObject::rotate(float angle, const Axis &axis)
     this->invalidate_bounding_box();
 }
 
+void ModelObject::transform(const float* matrix3x4)
+{
+    if (matrix3x4 == nullptr)
+        return;
+
+    for (ModelVolume* v : volumes)
+    {
+        v->mesh.transform(matrix3x4);
+    }
+
+    origin_translation = Pointf3(0.0f, 0.0f, 0.0f);
+    invalidate_bounding_box();
+}
+
 void ModelObject::mirror(const Axis &axis)
 {
     for (ModelVolume *v : this->volumes)
diff --git a/xs/src/libslic3r/Model.hpp b/xs/src/libslic3r/Model.hpp
index 636dfa1f4..cf9bfd85a 100644
--- a/xs/src/libslic3r/Model.hpp
+++ b/xs/src/libslic3r/Model.hpp
@@ -19,6 +19,7 @@ class ModelInstance;
 class ModelMaterial;
 class ModelObject;
 class ModelVolume;
+class PresetBundle;
 
 typedef std::string t_model_material_id;
 typedef std::string t_model_material_attribute;
@@ -119,6 +120,7 @@ public:
     void translate(coordf_t x, coordf_t y, coordf_t z);
     void scale(const Pointf3 &versor);
     void rotate(float angle, const Axis &axis);
+    void transform(const float* matrix3x4);
     void mirror(const Axis &axis);
     size_t materials_count() const;
     size_t facets_count() const;
@@ -238,12 +240,14 @@ public:
     ~Model() { this->clear_objects(); this->clear_materials(); }
 
     static Model read_from_file(const std::string &input_file, bool add_default_instances = true);
+    static Model read_from_archive(const std::string &input_file, PresetBundle* bundle, bool add_default_instances = true);
 
     ModelObject* add_object();
     ModelObject* add_object(const char *name, const char *path, const TriangleMesh &mesh);
     ModelObject* add_object(const char *name, const char *path, TriangleMesh &&mesh);
     ModelObject* add_object(const ModelObject &other, bool copy_volumes = true);
     void delete_object(size_t idx);
+    void delete_object(ModelObject* object);
     void clear_objects();
     
     ModelMaterial* add_material(t_model_material_id material_id);
diff --git a/xs/src/libslic3r/MultiPoint.cpp b/xs/src/libslic3r/MultiPoint.cpp
index 7929747a0..2e65492cd 100644
--- a/xs/src/libslic3r/MultiPoint.cpp
+++ b/xs/src/libslic3r/MultiPoint.cpp
@@ -214,6 +214,61 @@ MultiPoint::_douglas_peucker(const Points &points, const double tolerance)
     return results;
 }
 
+void MultiPoint3::translate(double x, double y)
+{
+    for (Point3& p : points)
+    {
+        p.translate(x, y);
+    }
+}
+
+void MultiPoint3::translate(const Point& vector)
+{
+    translate(vector.x, vector.y);
+}
+
+double MultiPoint3::length() const
+{
+    Lines3 lines = this->lines();
+    double len = 0.0;
+    for (const Line3& line : lines)
+    {
+        len += line.length();
+    }
+    return len;
+}
+
+BoundingBox3 MultiPoint3::bounding_box() const
+{
+    return BoundingBox3(points);
+}
+
+bool MultiPoint3::remove_duplicate_points()
+{
+    size_t j = 0;
+    for (size_t i = 1; i < points.size(); ++i)
+    {
+        if (points[j].coincides_with(points[i]))
+        {
+            // Just increase index i.
+        }
+        else
+        {
+            ++j;
+            if (j < i)
+                points[j] = points[i];
+        }
+    }
+
+    if (++j < points.size())
+    {
+        points.erase(points.begin() + j, points.end());
+        return true;
+    }
+
+    return false;
+}
+
 BoundingBox get_extents(const MultiPoint &mp)
 { 
     return BoundingBox(mp.points);
diff --git a/xs/src/libslic3r/MultiPoint.hpp b/xs/src/libslic3r/MultiPoint.hpp
index 3d1346e4c..0970e9a67 100644
--- a/xs/src/libslic3r/MultiPoint.hpp
+++ b/xs/src/libslic3r/MultiPoint.hpp
@@ -10,6 +10,7 @@
 namespace Slic3r {
 
 class BoundingBox;
+class BoundingBox3;
 
 class MultiPoint
 {
@@ -79,6 +80,25 @@ public:
     static Points _douglas_peucker(const Points &points, const double tolerance);
 };
 
+class MultiPoint3
+{
+public:
+    Points3 points;
+
+    void append(const Point3& point) { this->points.push_back(point); }
+
+    void translate(double x, double y);
+    void translate(const Point& vector);
+    virtual Lines3 lines() const = 0;
+    double length() const;
+    bool is_valid() const { return this->points.size() >= 2; }
+
+    BoundingBox3 bounding_box() const;
+
+    // Remove exact duplicates, return true if any duplicate has been removed.
+    bool remove_duplicate_points();
+};
+
 extern BoundingBox get_extents(const MultiPoint &mp);
 extern BoundingBox get_extents_rotated(const std::vector<Point> &points, double angle);
 extern BoundingBox get_extents_rotated(const MultiPoint &mp, double angle);
diff --git a/xs/src/libslic3r/PerimeterGenerator.cpp b/xs/src/libslic3r/PerimeterGenerator.cpp
index bffd46d0f..ea9c73fa4 100644
--- a/xs/src/libslic3r/PerimeterGenerator.cpp
+++ b/xs/src/libslic3r/PerimeterGenerator.cpp
@@ -483,8 +483,9 @@ PerimeterGenerator::_variable_width(const ThickPolylines &polylines, ExtrusionRo
             if (path.polyline.points.empty()) {
                 path.polyline.append(line.a);
                 path.polyline.append(line.b);
-                
-                flow.width = unscale(w);
+                // Convert from spacing to extrusion width based on the extrusion model
+                // of a square extrusion ended with semi circles.
+                flow.width = unscale(w) + flow.height * (1. - 0.25 * PI);
                 #ifdef SLIC3R_DEBUG
                 printf("  filling %f gap\n", flow.width);
                 #endif
diff --git a/xs/src/libslic3r/PlaceholderParser.cpp b/xs/src/libslic3r/PlaceholderParser.cpp
index bcd011da2..62b516935 100644
--- a/xs/src/libslic3r/PlaceholderParser.cpp
+++ b/xs/src/libslic3r/PlaceholderParser.cpp
@@ -3,6 +3,7 @@
 #include <ctime>
 #include <iomanip>
 #include <sstream>
+#include <map>
 #ifdef _MSC_VER
     #include <stdlib.h>  // provides **_environ
 #else
@@ -520,6 +521,9 @@ namespace client
         bool                     just_boolean_expression = false;
         std::string              error_message;
 
+        // Table to translate symbol tag to a human readable error message.
+        static std::map<std::string, std::string> tag_to_error_message;
+
         static void             evaluate_full_macro(const MyContext *ctx, bool &result) { result = ! ctx->just_boolean_expression; }
 
         const ConfigOption*     resolve_symbol(const std::string &opt_key) const
@@ -619,7 +623,7 @@ namespace client
             expr<Iterator>                  &output)
         {
             if (opt.opt->is_vector())
-                ctx->throw_exception("Referencing a scalar variable in a vector context", opt.it_range);
+                ctx->throw_exception("Referencing a vector variable when scalar is expected", opt.it_range);
             switch (opt.opt->type()) {
             case coFloat:   output.set_d(opt.opt->getFloat());   break;
             case coInt:     output.set_i(opt.opt->getInt());     break;
@@ -644,7 +648,7 @@ namespace client
             expr<Iterator>                  &output)
         {
             if (opt.opt->is_scalar())
-                ctx->throw_exception("Referencing a vector variable in a scalar context", opt.it_range);
+                ctx->throw_exception("Referencing a scalar variable when vector is expected", opt.it_range);
             const ConfigOptionVectorBase *vec = static_cast<const ConfigOptionVectorBase*>(opt.opt);
             if (vec->empty())
                 ctx->throw_exception("Indexing an empty vector variable", opt.it_range);
@@ -707,9 +711,16 @@ namespace client
                 msg += ": ";
                 msg += info.tag.substr(1);
             } else {
-                // A generic error report based on the nonterminal or terminal symbol name.
-                msg += ". Expecting tag ";
-                msg += info.tag;
+                auto it = tag_to_error_message.find(info.tag);
+                if (it == tag_to_error_message.end()) {
+                    // A generic error report based on the nonterminal or terminal symbol name.
+                    msg += ". Expecting tag ";
+                    msg += info.tag;
+                } else {
+                    // Use the human readable error message.
+                    msg += ". ";
+                    msg + it->second;
+                }
             }
             msg += '\n';
             msg += error_line;
@@ -720,6 +731,31 @@ namespace client
         }
     };
 
+    // Table to translate symbol tag to a human readable error message.
+    std::map<std::string, std::string> MyContext::tag_to_error_message = {
+        { "eoi",                        "Unknown syntax error" },
+        { "start",                      "Unknown syntax error" },
+        { "text",                       "Invalid text." },
+        { "text_block",                 "Invalid text block." },
+        { "macro",                      "Invalid macro." },
+        { "if_else_output",             "Not an {if}{else}{endif} macro." },
+        { "switch_output",              "Not a {switch} macro." },
+        { "legacy_variable_expansion",  "Expecting a legacy variable expansion format" },
+        { "identifier",                 "Expecting an identifier." },
+        { "conditional_expression",     "Expecting a conditional expression." },
+        { "logical_or_expression",      "Expecting a boolean expression." },
+        { "logical_and_expression",     "Expecting a boolean expression." },
+        { "equality_expression",        "Expecting an expression." },
+        { "bool_expr_eval",             "Expecting a boolean expression."},
+        { "relational_expression",      "Expecting an expression." },
+        { "additive_expression",        "Expecting an expression." },
+        { "multiplicative_expression",  "Expecting an expression." },
+        { "unary_expression",           "Expecting an expression." },
+        { "scalar_variable_reference",  "Expecting a scalar variable reference."},
+        { "variable_reference",         "Expecting a variable reference."},
+        { "regular_expression",         "Expecting a regular expression."}
+    };
+
     // For debugging the boost::spirit parsers. Print out the string enclosed in it_range.
     template<typename Iterator>
     std::ostream& operator<<(std::ostream& os, const boost::iterator_range<Iterator> &it_range)
@@ -822,7 +858,8 @@ namespace client
             spirit::int_type            int_;
             spirit::double_type         double_;
             spirit::ascii::string_type  string;
-            spirit::repository::qi::iter_pos_type iter_pos;
+			spirit::eoi_type			eoi;
+			spirit::repository::qi::iter_pos_type iter_pos;
             auto                        kw = spirit::repository::qi::distinct(qi::copy(alnum | '_'));
 
             qi::_val_type               _val;
@@ -843,7 +880,7 @@ namespace client
             start = eps[px::bind(&MyContext::evaluate_full_macro, _r1, _a)] >
                 (       eps(_a==true) > text_block(_r1) [_val=_1]
                     |   conditional_expression(_r1) [ px::bind(&expr<Iterator>::evaluate_boolean_to_string, _1, _val) ]
-                );
+				) > eoi;
             start.name("start");
             qi::on_error<qi::fail>(start, px::bind(&MyContext::process_error_message<Iterator>, _r1, _4, _1, _2, _3));
 
@@ -866,7 +903,7 @@ namespace client
             // The macro expansion may contain numeric or string expressions, ifs and cases.
             macro =
                     (kw["if"]     > if_else_output(_r1) [_val = _1])
-                |   (kw["switch"] > switch_output(_r1)  [_val = _1])
+//                |   (kw["switch"] > switch_output(_r1)  [_val = _1])
                 |   additive_expression(_r1) [ px::bind(&expr<Iterator>::to_string2, _1, _val) ];
             macro.name("macro");
 
@@ -908,14 +945,17 @@ namespace client
             conditional_expression =
                 logical_or_expression(_r1)                [_val = _1]
                 >> -('?' > conditional_expression(_r1) > ':' > conditional_expression(_r1)) [px::bind(&expr<Iterator>::ternary_op, _val, _1, _2)];
+            conditional_expression.name("conditional_expression");
 
             logical_or_expression = 
                 logical_and_expression(_r1)                [_val = _1]
                 >> *(   ((kw["or"] | "||") > logical_and_expression(_r1) ) [px::bind(&expr<Iterator>::logical_or, _val, _1)] );
+            logical_or_expression.name("logical_or_expression");
 
             logical_and_expression = 
                 equality_expression(_r1)                   [_val = _1]
                 >> *(   ((kw["and"] | "&&") > equality_expression(_r1) ) [px::bind(&expr<Iterator>::logical_and, _val, _1)] );
+            logical_and_expression.name("logical_and_expression");
 
             equality_expression =
                 relational_expression(_r1)                   [_val = _1]
@@ -934,11 +974,12 @@ namespace client
 
             relational_expression = 
                     additive_expression(_r1)                [_val  = _1]
-                >> *(   (lit('<') > additive_expression(_r1) ) [px::bind(&expr<Iterator>::lower,   _val, _1)]
-                    |   (lit('>') > additive_expression(_r1) ) [px::bind(&expr<Iterator>::greater, _val, _1)]
-                    |   ("<="     > additive_expression(_r1) ) [px::bind(&expr<Iterator>::leq,     _val, _1)]
+                >> *(   ("<="     > additive_expression(_r1) ) [px::bind(&expr<Iterator>::leq,     _val, _1)]
                     |   (">="     > additive_expression(_r1) ) [px::bind(&expr<Iterator>::geq,     _val, _1)]
+                    |   (lit('<') > additive_expression(_r1) ) [px::bind(&expr<Iterator>::lower,   _val, _1)]
+                    |   (lit('>') > additive_expression(_r1) ) [px::bind(&expr<Iterator>::greater, _val, _1)]
                     );
+            relational_expression.name("relational_expression");
 
             additive_expression =
                 multiplicative_expression(_r1)                       [_val  = _1]
@@ -1020,7 +1061,7 @@ namespace client
                 debug(text_block);
                 debug(macro);
                 debug(if_else_output);
-                debug(switch_output);
+//                debug(switch_output);
                 debug(legacy_variable_expansion);
                 debug(identifier);
                 debug(conditional_expression);
@@ -1079,7 +1120,7 @@ namespace client
         qi::rule<Iterator, OptWithPos<Iterator>(const MyContext*), spirit::ascii::space_type> variable_reference;
 
         qi::rule<Iterator, std::string(const MyContext*), qi::locals<bool, bool>, spirit::ascii::space_type> if_else_output;
-        qi::rule<Iterator, std::string(const MyContext*), qi::locals<expr<Iterator>, bool, std::string>, spirit::ascii::space_type> switch_output;
+//        qi::rule<Iterator, std::string(const MyContext*), qi::locals<expr<Iterator>, bool, std::string>, spirit::ascii::space_type> switch_output;
 
         qi::symbols<char> keywords;
     };
@@ -1102,7 +1143,7 @@ static std::string process_macro(const std::string &templ, client::MyContext &co
     // Accumulator for the processed template.
     std::string                 output;
     bool res = phrase_parse(iter, end, macro_processor_instance(&context), space, output);
-    if (! context.error_message.empty()) {
+	if (!context.error_message.empty()) {
         if (context.error_message.back() != '\n' && context.error_message.back() != '\r')
             context.error_message += '\n';
         throw std::runtime_error(context.error_message);
diff --git a/xs/src/libslic3r/Point.hpp b/xs/src/libslic3r/Point.hpp
index 77e07bec8..6c9096a3d 100644
--- a/xs/src/libslic3r/Point.hpp
+++ b/xs/src/libslic3r/Point.hpp
@@ -14,14 +14,17 @@ class Line;
 class Linef;
 class MultiPoint;
 class Point;
+class Point3;
 class Pointf;
 class Pointf3;
 typedef Point Vector;
+typedef Point3 Vector3;
 typedef Pointf Vectorf;
 typedef Pointf3 Vectorf3;
 typedef std::vector<Point> Points;
 typedef std::vector<Point*> PointPtrs;
 typedef std::vector<const Point*> PointConstPtrs;
+typedef std::vector<Point3> Points3;
 typedef std::vector<Pointf> Pointfs;
 typedef std::vector<Pointf3> Pointf3s;
 
@@ -32,8 +35,7 @@ public:
     coord_t x;
     coord_t y;
     Point(coord_t _x = 0, coord_t _y = 0): x(_x), y(_y) {};
-    Point(int _x, int _y): x(_x), y(_y) {};
-    Point(long long _x, long long _y): x(coord_t(_x)), y(coord_t(_y)) {};  // for Clipper
+    Point(int64_t _x, int64_t _y): x(coord_t(_x)), y(coord_t(_y)) {};  // for Clipper
     Point(double x, double y);
     static Point new_scale(coordf_t x, coordf_t y) { return Point(coord_t(scale_(x)), coord_t(scale_(y))); }
 
@@ -186,10 +188,11 @@ public:
     static Point3 new_scale(coordf_t x, coordf_t y, coordf_t z) { return Point3(coord_t(scale_(x)), coord_t(scale_(y)), coord_t(scale_(z))); }
     bool operator==(const Point3 &rhs) const { return this->x == rhs.x && this->y == rhs.y && this->z == rhs.z; }
     bool operator!=(const Point3 &rhs) const { return ! (*this == rhs); }
+    bool coincides_with(const Point3& rhs) const { return this->x == rhs.x && this->y == rhs.y && this->z == rhs.z; }
 private:
     // Hide the following inherited methods:
-    bool operator==(const Point &rhs);
-    bool operator!=(const Point &rhs);
+    bool operator==(const Point &rhs) const;
+    bool operator!=(const Point &rhs) const;
 };
 
 std::ostream& operator<<(std::ostream &stm, const Pointf &pointf);
@@ -244,6 +247,7 @@ public:
     static Pointf3 new_unscale(coord_t x, coord_t y, coord_t z) {
         return Pointf3(unscale(x), unscale(y), unscale(z));
     };
+    static Pointf3 new_unscale(const Point3& p) { return Pointf3(unscale(p.x), unscale(p.y), unscale(p.z)); }
     void scale(double factor);
     void translate(const Vectorf3 &vector);
     void translate(double x, double y, double z);
@@ -256,10 +260,23 @@ public:
 
 private:
     // Hide the following inherited methods:
-    bool operator==(const Pointf &rhs);
-    bool operator!=(const Pointf &rhs);
+    bool operator==(const Pointf &rhs) const;
+    bool operator!=(const Pointf &rhs) const;
 };
 
+inline Pointf3 operator+(const Pointf3& p1, const Pointf3& p2) { return Pointf3(p1.x + p2.x, p1.y + p2.y, p1.z + p2.z); }
+inline Pointf3 operator-(const Pointf3& p1, const Pointf3& p2) { return Pointf3(p1.x - p2.x, p1.y - p2.y, p1.z - p2.z); }
+inline Pointf3 operator-(const Pointf3& p) { return Pointf3(-p.x, -p.y, -p.z); }
+inline Pointf3 operator*(double scalar, const Pointf3& p) { return Pointf3(scalar * p.x, scalar * p.y, scalar * p.z); }
+inline Pointf3 operator*(const Pointf3& p, double scalar) { return Pointf3(scalar * p.x, scalar * p.y, scalar * p.z); }
+inline Pointf3 cross(const Pointf3& v1, const Pointf3& v2) { return Pointf3(v1.y * v2.z - v1.z * v2.y, v1.z * v2.x - v1.x * v2.z, v1.x * v2.y - v1.y * v2.x); }
+inline coordf_t dot(const Pointf3& v1, const Pointf3& v2) { return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; }
+inline Pointf3 normalize(const Pointf3& v)
+{
+    coordf_t len = ::sqrt(sqr(v.x) + sqr(v.y) + sqr(v.z));
+    return (len != 0.0) ? 1.0 / len * v : Pointf3(0.0, 0.0, 0.0);
+}
+
 template<typename TO> inline TO convert_to(const Point &src) { return TO(typename TO::coord_type(src.x), typename TO::coord_type(src.y)); }
 template<typename TO> inline TO convert_to(const Pointf &src) { return TO(typename TO::coord_type(src.x), typename TO::coord_type(src.y)); }
 template<typename TO> inline TO convert_to(const Point3 &src) { return TO(typename TO::coord_type(src.x), typename TO::coord_type(src.y), typename TO::coord_type(src.z)); }
@@ -271,23 +288,6 @@ template<typename TO> inline TO convert_to(const Pointf3 &src) { return TO(typen
 #include <boost/version.hpp>
 #include <boost/polygon/polygon.hpp>
 namespace boost { namespace polygon {
-    template <>
-    struct geometry_concept<coord_t> { typedef coordinate_concept type; };
-    
-/* Boost.Polygon already defines a specialization for coordinate_traits<long> as of 1.60:
-   https://github.com/boostorg/polygon/commit/0ac7230dd1f8f34cb12b86c8bb121ae86d3d9b97 */
-#if BOOST_VERSION < 106000
-    template <>
-    struct coordinate_traits<coord_t> {
-        typedef coord_t coordinate_type;
-        typedef long double area_type;
-        typedef long long manhattan_area_type;
-        typedef unsigned long long unsigned_area_type;
-        typedef long long coordinate_difference;
-        typedef long double coordinate_distance;
-    };
-#endif
-
     template <>
     struct geometry_concept<Slic3r::Point> { typedef point_concept type; };
    
diff --git a/xs/src/libslic3r/Polygon.hpp b/xs/src/libslic3r/Polygon.hpp
index f36abc185..1a02d78b7 100644
--- a/xs/src/libslic3r/Polygon.hpp
+++ b/xs/src/libslic3r/Polygon.hpp
@@ -24,6 +24,12 @@ public:
     explicit Polygon(const Points &points): MultiPoint(points) {}
     Polygon(const Polygon &other) : MultiPoint(other.points) {}
     Polygon(Polygon &&other) : MultiPoint(std::move(other.points)) {}
+	static Polygon new_scale(std::vector<Pointf> points) { 
+		Points int_points;
+		for (auto pt : points)
+			int_points.push_back(Point::new_scale(pt.x, pt.y));
+		return Polygon(int_points);
+	}
     Polygon& operator=(const Polygon &other) { points = other.points; return *this; }
     Polygon& operator=(Polygon &&other) { points = std::move(other.points); return *this; }
 
diff --git a/xs/src/libslic3r/Polyline.cpp b/xs/src/libslic3r/Polyline.cpp
index 672777ce1..3432506c6 100644
--- a/xs/src/libslic3r/Polyline.cpp
+++ b/xs/src/libslic3r/Polyline.cpp
@@ -278,4 +278,18 @@ ThickPolyline::reverse()
     std::swap(this->endpoints.first, this->endpoints.second);
 }
 
+Lines3 Polyline3::lines() const
+{
+    Lines3 lines;
+    if (points.size() >= 2)
+    {
+        lines.reserve(points.size() - 1);
+        for (Points3::const_iterator it = points.begin(); it != points.end() - 1; ++it)
+        {
+            lines.emplace_back(*it, *(it + 1));
+        }
+    }
+    return lines;
+}
+
 }
diff --git a/xs/src/libslic3r/Polyline.hpp b/xs/src/libslic3r/Polyline.hpp
index ac59c6378..b64743d84 100644
--- a/xs/src/libslic3r/Polyline.hpp
+++ b/xs/src/libslic3r/Polyline.hpp
@@ -21,6 +21,14 @@ public:
     Polyline(Polyline &&other) : MultiPoint(std::move(other.points)) {}
     Polyline& operator=(const Polyline &other) { points = other.points; return *this; }
     Polyline& operator=(Polyline &&other) { points = std::move(other.points); return *this; }
+	static Polyline new_scale(std::vector<Pointf> points) {
+		Polyline pl;
+		Points int_points;
+		for (auto pt : points)
+			int_points.push_back(Point::new_scale(pt.x, pt.y));
+		pl.append(int_points);
+		return pl;
+    }
     
     void append(const Point &point) { this->points.push_back(point); }
     void append(const Points &src) { this->append(src.begin(), src.end()); }
@@ -129,6 +137,14 @@ class ThickPolyline : public Polyline {
     void reverse();
 };
 
+class Polyline3 : public MultiPoint3
+{
+public:
+    virtual Lines3 lines() const;
+};
+
+typedef std::vector<Polyline3> Polylines3;
+
 }
 
 #endif
diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp
index 64f4d6046..1c63dbf60 100644
--- a/xs/src/libslic3r/Print.cpp
+++ b/xs/src/libslic3r/Print.cpp
@@ -568,8 +568,8 @@ std::string Print::validate() const
             if (std::abs(dmr - 0.4) > EPSILON)
                 return "The Wipe Tower is currently only supported for the 0.4mm nozzle diameter.";
         #endif
-        if (this->config.gcode_flavor != gcfRepRap)
-            return "The Wipe Tower is currently only supported for the RepRap (Marlin / Sprinter) G-code flavor.";
+        if (this->config.gcode_flavor != gcfRepRap && this->config.gcode_flavor != gcfMarlin)
+            return "The Wipe Tower is currently only supported for the Marlin and RepRap/Sprinter G-code flavors.";
         if (! this->config.use_relative_e_distances)
             return "The Wipe Tower is currently only supported with the relative extruder addressing (use_relative_e_distances=1).";
         SlicingParameters slicing_params0 = this->objects.front()->slicing_parameters();
@@ -998,7 +998,8 @@ void Print::_make_wipe_tower()
             // Find the position in this->objects.first()->support_layers to insert these new support layers.
             double wipe_tower_new_layer_print_z_first = m_tool_ordering.layer_tools()[idx_begin].print_z;
             SupportLayerPtrs::iterator it_layer = this->objects.front()->support_layers.begin();
-            for (; (*it_layer)->print_z - EPSILON < wipe_tower_new_layer_print_z_first; ++ it_layer) ;
+            SupportLayerPtrs::iterator it_end   = this->objects.front()->support_layers.end();
+            for (; it_layer != it_end && (*it_layer)->print_z - EPSILON < wipe_tower_new_layer_print_z_first; ++ it_layer);
             // Find the stopper of the sequence of wipe tower layers, which do not have a counterpart in an object or a support layer.
             for (size_t i = idx_begin; i < idx_end; ++ i) {
                 ToolOrdering::LayerTools &lt = const_cast<ToolOrdering::LayerTools&>(m_tool_ordering.layer_tools()[i]);
@@ -1006,9 +1007,9 @@ void Print::_make_wipe_tower()
                     break;
                 lt.has_support = true;
                 // Insert the new support layer.
-                //FIXME the support layer ID is duplicated, but Vojtech hopes it is not being used anywhere anyway.
                 double height    = lt.print_z - m_tool_ordering.layer_tools()[i-1].print_z;
-                auto  *new_layer = new SupportLayer((*it_layer)->id(), this->objects.front(), 
+                //FIXME the support layer ID is set to -1, as Vojtech hopes it is not being used anyway.
+                auto  *new_layer = new SupportLayer(size_t(-1), this->objects.front(),
                     height, lt.print_z, lt.print_z - 0.5 * height);
                 it_layer = this->objects.front()->support_layers.insert(it_layer, new_layer);
                 ++ it_layer;
diff --git a/xs/src/libslic3r/Print.hpp b/xs/src/libslic3r/Print.hpp
index c4093b795..c56e64c6c 100644
--- a/xs/src/libslic3r/Print.hpp
+++ b/xs/src/libslic3r/Print.hpp
@@ -233,8 +233,9 @@ public:
     PrintRegionPtrs regions;
     PlaceholderParser placeholder_parser;
     // TODO: status_cb
+    std::string                     estimated_print_time;
     double                          total_used_filament, total_extruded_volume, total_cost, total_weight;
-    std::map<size_t,float>          filament_stats;
+    std::map<size_t, float>         filament_stats;
     PrintState<PrintStep, psCount>  state;
 
     // ordered collections of extrusion paths to build skirt loops and brim
diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp
index e44c3608a..bc5d115c3 100644
--- a/xs/src/libslic3r/PrintConfig.cpp
+++ b/xs/src/libslic3r/PrintConfig.cpp
@@ -9,6 +9,10 @@
 
 namespace Slic3r {
 
+//! macro used to mark string used at localization, 
+//! return same string
+#define _L(s) s
+
 PrintConfigDef::PrintConfigDef()
 {
     t_optiondef_map &Options = this->options;
@@ -17,34 +21,39 @@ PrintConfigDef::PrintConfigDef()
 
     // Maximum extruder temperature, bumped to 1500 to support printing of glass.
     const int max_temp = 1500;
+
+	//! On purpose of localization there is that changes at text of tooltip and sidetext:
+	//! - ° -> \u00B0
+	//! - ² -> \u00B2
+	//! - ³ -> \u00B3
     
     def = this->add("avoid_crossing_perimeters", coBool);
-    def->label = "Avoid crossing perimeters";
-    def->tooltip = "Optimize travel moves in order to minimize the crossing of perimeters. "
+    def->label = _L("Avoid crossing perimeters");
+	def->tooltip = _L("Optimize travel moves in order to minimize the crossing of perimeters. "
                    "This is mostly useful with Bowden extruders which suffer from oozing. "
-                   "This feature slows down both the print and the G-code generation.";
+                   "This feature slows down both the print and the G-code generation.");
     def->cli = "avoid-crossing-perimeters!";
     def->default_value = new ConfigOptionBool(false);
 
     def = this->add("bed_shape", coPoints);
-    def->label = "Bed shape";
+	def->label = _L("Bed shape");
     def->default_value = new ConfigOptionPoints { Pointf(0,0), Pointf(200,0), Pointf(200,200), Pointf(0,200) };
     
     def = this->add("bed_temperature", coInts);
-    def->label = "Other layers";
-    def->tooltip = "Bed temperature for layers after the first one. "
-                   "Set this to zero to disable bed temperature control commands in the output.";
+    def->label = _L("Other layers");
+    def->tooltip = _L("Bed temperature for layers after the first one. "
+                   "Set this to zero to disable bed temperature control commands in the output.");
     def->cli = "bed-temperature=i@";
-    def->full_label = "Bed temperature";
+    def->full_label = _L("Bed temperature");
     def->min = 0;
     def->max = 300;
     def->default_value = new ConfigOptionInts { 0 };
 
     def = this->add("before_layer_gcode", coString);
-    def->label = "Before layer change G-code";
-    def->tooltip = "This custom code is inserted at every layer change, right before the Z move. "
+    def->label = _L("Before layer change G-code");
+    def->tooltip = _L("This custom code is inserted at every layer change, right before the Z move. "
                    "Note that you can use placeholder variables for all Slic3r settings as well "
-                   "as [layer_num] and [layer_z].";
+                   "as [layer_num] and [layer_z].");
     def->cli = "before-layer-gcode=s";
     def->multiline = true;
     def->full_width = true;
@@ -52,8 +61,8 @@ PrintConfigDef::PrintConfigDef()
     def->default_value = new ConfigOptionString("");
 
     def = this->add("between_objects_gcode", coString);
-    def->label = "Between objects G-code";
-    def->tooltip = "This code is inserted between objects when using sequential printing. By default extruder and bed temperature are reset using non-wait command; however if M104, M109, M140 or M190 are detected in this custom code, Slic3r will not add temperature commands. Note that you can use placeholder variables for all Slic3r settings, so you can put a \"M109 S[first_layer_temperature]\" command wherever you want.";
+    def->label = _L("Between objects G-code");
+    def->tooltip = _L("This code is inserted between objects when using sequential printing. By default extruder and bed temperature are reset using non-wait command; however if M104, M109, M140 or M190 are detected in this custom code, Slic3r will not add temperature commands. Note that you can use placeholder variables for all Slic3r settings, so you can put a \"M109 S[first_layer_temperature]\" command wherever you want.");
     def->cli = "between-objects-gcode=s";
     def->multiline = true;
     def->full_width = true;
@@ -61,158 +70,158 @@ PrintConfigDef::PrintConfigDef()
     def->default_value = new ConfigOptionString("");
 
     def = this->add("bottom_solid_layers", coInt);
-    def->label = "Bottom";
-    def->category = "Layers and Perimeters";
-    def->tooltip = "Number of solid layers to generate on bottom surfaces.";
+    def->label = _L("Bottom");
+    def->category = _L("Layers and Perimeters");
+    def->tooltip = _L("Number of solid layers to generate on bottom surfaces.");
     def->cli = "bottom-solid-layers=i";
-    def->full_label = "Bottom solid layers";
+    def->full_label = _L("Bottom solid layers");
     def->min = 0;
     def->default_value = new ConfigOptionInt(3);
 
     def = this->add("bridge_acceleration", coFloat);
-    def->label = "Bridge";
-    def->tooltip = "This is the acceleration your printer will use for bridges. "
-                   "Set zero to disable acceleration control for bridges.";
-    def->sidetext = "mm/s²";
+    def->label = _L("Bridge");
+    def->tooltip = _L("This is the acceleration your printer will use for bridges. "
+                   "Set zero to disable acceleration control for bridges.");
+    def->sidetext = _L("mm/s\u00B2");
     def->cli = "bridge-acceleration=f";
     def->min = 0;
     def->default_value = new ConfigOptionFloat(0);
 
     def = this->add("bridge_angle", coFloat);
-    def->label = "Bridging angle";
-    def->category = "Infill";
-    def->tooltip = "Bridging angle override. If left to zero, the bridging angle will be calculated "
+    def->label = _L("Bridging angle");
+    def->category = _L("Infill");
+    def->tooltip = _L("Bridging angle override. If left to zero, the bridging angle will be calculated "
                    "automatically. Otherwise the provided angle will be used for all bridges. "
-                   "Use 180° for zero angle.";
-    def->sidetext = "°";
+                   "Use 180\u00B0 for zero angle.");
+    def->sidetext = _L("\u00B0");
     def->cli = "bridge-angle=f";
     def->min = 0;
     def->default_value = new ConfigOptionFloat(0.);
 
     def = this->add("bridge_fan_speed", coInts);
-    def->label = "Bridges fan speed";
-    def->tooltip = "This fan speed is enforced during all bridges and overhangs.";
-    def->sidetext = "%";
+    def->label = _L("Bridges fan speed");
+    def->tooltip = _L("This fan speed is enforced during all bridges and overhangs.");
+    def->sidetext = _L("%");
     def->cli = "bridge-fan-speed=i@";
     def->min = 0;
     def->max = 100;
     def->default_value = new ConfigOptionInts { 100 };
 
     def = this->add("bridge_flow_ratio", coFloat);
-    def->label = "Bridge flow ratio";
-    def->category = "Advanced";
-    def->tooltip = "This factor affects the amount of plastic for bridging. "
+    def->label = _L("Bridge flow ratio");
+    def->category = _L("Advanced");
+    def->tooltip = _L("This factor affects the amount of plastic for bridging. "
                    "You can decrease it slightly to pull the extrudates and prevent sagging, "
                    "although default settings are usually good and you should experiment "
-                   "with cooling (use a fan) before tweaking this.";
+                   "with cooling (use a fan) before tweaking this.");
     def->cli = "bridge-flow-ratio=f";
     def->min = 0;
     def->default_value = new ConfigOptionFloat(1);
 
     def = this->add("bridge_speed", coFloat);
-    def->label = "Bridges";
-    def->category = "Speed";
-    def->tooltip = "Speed for printing bridges.";
-    def->sidetext = "mm/s";
+    def->label = _L("Bridges");
+    def->category = _L("Speed");
+    def->tooltip = _L("Speed for printing bridges.");
+    def->sidetext = _L("mm/s");
     def->cli = "bridge-speed=f";
     def->aliases.push_back("bridge_feed_rate");
     def->min = 0;
     def->default_value = new ConfigOptionFloat(60);
 
     def = this->add("brim_width", coFloat);
-    def->label = "Brim width";
-    def->tooltip = "Horizontal width of the brim that will be printed around each object on the first layer.";
-    def->sidetext = "mm";
+    def->label = _L("Brim width");
+    def->tooltip = _L("Horizontal width of the brim that will be printed around each object on the first layer.");
+    def->sidetext = _L("mm");
     def->cli = "brim-width=f";
     def->min = 0;
     def->default_value = new ConfigOptionFloat(0);
 
     def = this->add("clip_multipart_objects", coBool);
-    def->label = "Clip multi-part objects";
-    def->tooltip = "When printing multi-material objects, this settings will make slic3r "
+    def->label = _L("Clip multi-part objects");
+    def->tooltip = _L("When printing multi-material objects, this settings will make slic3r "
                    "to clip the overlapping object parts one by the other "
-                   "(2nd part will be clipped by the 1st, 3rd part will be clipped by the 1st and 2nd etc).";
+                   "(2nd part will be clipped by the 1st, 3rd part will be clipped by the 1st and 2nd etc).");
     def->cli = "clip-multipart-objects!";
     def->default_value = new ConfigOptionBool(false);
 
     def = this->add("compatible_printers", coStrings);
-    def->label = "Compatible printers";
+    def->label = _L("Compatible printers");
     def->default_value = new ConfigOptionStrings();
 
     def = this->add("compatible_printers_condition", coString);
-    def->label = "Compatible printers condition";
-    def->tooltip = "A boolean expression using the configuration values of an active printer profile. "
+    def->label = _L("Compatible printers condition");
+    def->tooltip = _L("A boolean expression using the configuration values of an active printer profile. "
                    "If this expression evaluates to true, this profile is considered compatible "
-                   "with the active printer profile.";
+                   "with the active printer profile.");
     def->default_value = new ConfigOptionString();
 
     def = this->add("complete_objects", coBool);
-    def->label = "Complete individual objects";
-    def->tooltip = "When printing multiple objects or copies, this feature will complete "
+    def->label = _L("Complete individual objects");
+    def->tooltip = _L("When printing multiple objects or copies, this feature will complete "
                    "each object before moving onto next one (and starting it from its bottom layer). "
                    "This feature is useful to avoid the risk of ruined prints. "
-                   "Slic3r should warn and prevent you from extruder collisions, but beware.";
+                   "Slic3r should warn and prevent you from extruder collisions, but beware.");
     def->cli = "complete-objects!";
     def->default_value = new ConfigOptionBool(false);
 
     def = this->add("cooling", coBools);
-    def->label = "Enable auto cooling";
-    def->tooltip = "This flag enables the automatic cooling logic that adjusts print speed "
-                   "and fan speed according to layer printing time.";
+    def->label = _L("Enable auto cooling");
+    def->tooltip = _L("This flag enables the automatic cooling logic that adjusts print speed "
+                   "and fan speed according to layer printing time.");
     def->cli = "cooling!";
     def->default_value = new ConfigOptionBools { true };
 
     def = this->add("default_acceleration", coFloat);
-    def->label = "Default";
-    def->tooltip = "This is the acceleration your printer will be reset to after "
+    def->label = _L("Default");
+    def->tooltip = _L("This is the acceleration your printer will be reset to after "
                    "the role-specific acceleration values are used (perimeter/infill). "
-                   "Set zero to prevent resetting acceleration at all.";
-    def->sidetext = "mm/s²";
+                   "Set zero to prevent resetting acceleration at all.");
+    def->sidetext = _L("mm/s\u00B2");
     def->cli = "default-acceleration=f";
     def->min = 0;
     def->default_value = new ConfigOptionFloat(0);
 
     def = this->add("disable_fan_first_layers", coInts);
-    def->label = "Disable fan for the first";
-    def->tooltip = "You can set this to a positive value to disable fan at all "
-                   "during the first layers, so that it does not make adhesion worse.";
-    def->sidetext = "layers";
+    def->label = _L("Disable fan for the first");
+    def->tooltip = _L("You can set this to a positive value to disable fan at all "
+                   "during the first layers, so that it does not make adhesion worse.");
+    def->sidetext = _L("layers");
     def->cli = "disable-fan-first-layers=i@";
     def->min = 0;
     def->max = 1000;
     def->default_value = new ConfigOptionInts { 3 };
 
     def = this->add("dont_support_bridges", coBool);
-    def->label = "Don't support bridges";
-    def->category = "Support material";
-    def->tooltip = "Experimental option for preventing support material from being generated "
-                   "under bridged areas.";
+    def->label = _L("Don't support bridges");
+    def->category = _L("Support material");
+    def->tooltip = _L("Experimental option for preventing support material from being generated "
+                   "under bridged areas.");
     def->cli = "dont-support-bridges!";
     def->default_value = new ConfigOptionBool(true);
 
     def = this->add("duplicate_distance", coFloat);
-    def->label = "Distance between copies";
-    def->tooltip = "Distance used for the auto-arrange feature of the plater.";
-    def->sidetext = "mm";
+    def->label = _L("Distance between copies");
+    def->tooltip = _L("Distance used for the auto-arrange feature of the plater.");
+    def->sidetext = _L("mm");
     def->cli = "duplicate-distance=f";
     def->aliases.push_back("multiply_distance");
     def->min = 0;
     def->default_value = new ConfigOptionFloat(6);
 
     def = this->add("elefant_foot_compensation", coFloat);
-    def->label = "Elefant foot compensation";
-    def->category = "Advanced";
-    def->tooltip = "The first layer will be shrunk in the XY plane by the configured value "
-                   "to compensate for the 1st layer squish aka an Elefant Foot effect.";
-    def->sidetext = "mm";
+    def->label = _L("Elephant foot compensation");
+    def->category = _L("Advanced");
+    def->tooltip = _L("The first layer will be shrunk in the XY plane by the configured value "
+                   "to compensate for the 1st layer squish aka an Elephant Foot effect.");
+    def->sidetext = _L("mm");
     def->cli = "elefant-foot-compensation=f";
     def->min = 0;
     def->default_value = new ConfigOptionFloat(0);
 
     def = this->add("end_gcode", coString);
-    def->label = "End G-code";
-    def->tooltip = "This end procedure is inserted at the end of the output file. "
-                   "Note that you can use placeholder variables for all Slic3r settings.";
+    def->label = _L("End G-code");
+    def->tooltip = _L("This end procedure is inserted at the end of the output file. "
+                   "Note that you can use placeholder variables for all Slic3r settings.");
     def->cli = "end-gcode=s";
     def->multiline = true;
     def->full_width = true;
@@ -220,10 +229,10 @@ PrintConfigDef::PrintConfigDef()
     def->default_value = new ConfigOptionString("M104 S0 ; turn off temperature\nG28 X0  ; home X axis\nM84     ; disable motors\n");
 
     def = this->add("end_filament_gcode", coStrings);
-    def->label = "End G-code";
-    def->tooltip = "This end procedure is inserted at the end of the output file, before the printer end gcode. "
+    def->label = _L("End G-code");
+    def->tooltip = _L("This end procedure is inserted at the end of the output file, before the printer end gcode. "
                    "Note that you can use placeholder variables for all Slic3r settings. "
-                   "If you have multiple extruders, the gcode is processed in extruder order.";
+                   "If you have multiple extruders, the gcode is processed in extruder order.");
     def->cli = "end-filament-gcode=s@";
     def->multiline = true;
     def->full_width = true;
@@ -231,18 +240,18 @@ PrintConfigDef::PrintConfigDef()
     def->default_value = new ConfigOptionStrings { "; Filament-specific end gcode \n;END gcode for filament\n" };
 
     def = this->add("ensure_vertical_shell_thickness", coBool);
-    def->label = "Ensure vertical shell thickness";
-    def->category = "Layers and Perimeters";
-    def->tooltip = "Add solid infill near sloping surfaces to guarantee the vertical shell thickness "
-                   "(top+bottom solid layers).";
+    def->label = _L("Ensure vertical shell thickness");
+    def->category = _L("Layers and Perimeters");
+    def->tooltip = _L("Add solid infill near sloping surfaces to guarantee the vertical shell thickness "
+                   "(top+bottom solid layers).");
     def->cli = "ensure-vertical-shell-thickness!";
     def->default_value = new ConfigOptionBool(false);
 
     def = this->add("external_fill_pattern", coEnum);
-    def->label = "Top/bottom fill pattern";
-    def->category = "Infill";
-    def->tooltip = "Fill pattern for top/bottom infill. This only affects the external visible layer, "
-                   "and not its adjacent solid shells.";
+    def->label = _L("Top/bottom fill pattern");
+    def->category = _L("Infill");
+    def->tooltip = _L("Fill pattern for top/bottom infill. This only affects the external visible layer, "
+                   "and not its adjacent solid shells.");
     def->cli = "external-fill-pattern|solid-fill-pattern=s";
     def->enum_keys_map = &ConfigOptionEnum<InfillPattern>::get_enum_values();
     def->enum_values.push_back("rectilinear");
@@ -260,50 +269,50 @@ PrintConfigDef::PrintConfigDef()
     def->default_value = new ConfigOptionEnum<InfillPattern>(ipRectilinear);
 
     def = this->add("external_perimeter_extrusion_width", coFloatOrPercent);
-    def->label = "External perimeters";
-    def->category = "Extrusion Width";
-    def->tooltip = "Set this to a non-zero value to set a manual extrusion width for external perimeters. "
+    def->label = _L("External perimeters");
+    def->category = _L("Extrusion Width");
+    def->tooltip = _L("Set this to a non-zero value to set a manual extrusion width for external perimeters. "
                    "If left zero, default extrusion width will be used if set, otherwise 1.125 x nozzle diameter will be used. "
-                   "If expressed as percentage (for example 200%), it will be computed over layer height.";
-    def->sidetext = "mm or % (leave 0 for default)";
+                   "If expressed as percentage (for example 200%), it will be computed over layer height.");
+    def->sidetext = _L("mm or % (leave 0 for default)");
     def->cli = "external-perimeter-extrusion-width=s";
     def->default_value = new ConfigOptionFloatOrPercent(0, false);
 
     def = this->add("external_perimeter_speed", coFloatOrPercent);
-    def->label = "External perimeters";
-    def->category = "Speed";
-    def->tooltip = "This separate setting will affect the speed of external perimeters (the visible ones). "
+    def->label = _L("External perimeters");
+    def->category = _L("Speed");
+    def->tooltip = _L("This separate setting will affect the speed of external perimeters (the visible ones). "
                    "If expressed as percentage (for example: 80%) it will be calculated "
-                   "on the perimeters speed setting above. Set to zero for auto.";
-    def->sidetext = "mm/s or %";
+                   "on the perimeters speed setting above. Set to zero for auto.");
+    def->sidetext = _L("mm/s or %");
     def->cli = "external-perimeter-speed=s";
     def->ratio_over = "perimeter_speed";
     def->min = 0;
     def->default_value = new ConfigOptionFloatOrPercent(50, true);
 
     def = this->add("external_perimeters_first", coBool);
-    def->label = "External perimeters first";
-    def->category = "Layers and Perimeters";
-    def->tooltip = "Print contour perimeters from the outermost one to the innermost one "
-                   "instead of the default inverse order.";
+    def->label = _L("External perimeters first");
+    def->category = _L("Layers and Perimeters");
+    def->tooltip = _L("Print contour perimeters from the outermost one to the innermost one "
+                   "instead of the default inverse order.");
     def->cli = "external-perimeters-first!";
     def->default_value = new ConfigOptionBool(false);
 
     def = this->add("extra_perimeters", coBool);
-    def->label = "Extra perimeters if needed";
-    def->category = "Layers and Perimeters";
-    def->tooltip = "Add more perimeters when needed for avoiding gaps in sloping walls. "
+    def->label = _L("Extra perimeters if needed");
+    def->category = _L("Layers and Perimeters");
+    def->tooltip = _L("Add more perimeters when needed for avoiding gaps in sloping walls. "
                    "Slic3r keeps adding perimeters, until more than 70% of the loop immediately above "
-                   "is supported.";
+                   "is supported.");
     def->cli = "extra-perimeters!";
     def->default_value = new ConfigOptionBool(true);
 
     def = this->add("extruder", coInt);
     def->gui_type = "i_enum_open";
-    def->label = "Extruder";
-    def->category = "Extruders";
-    def->tooltip = "The extruder to use (unless more specific extruder settings are specified). "
-                   "This value overrides perimeter and infill extruders, but not the support extruders.";
+    def->label = _L("Extruder");
+    def->category = _L("Extruders");
+    def->tooltip = _L("The extruder to use (unless more specific extruder settings are specified). "
+                   "This value overrides perimeter and infill extruders, but not the support extruders.");
     def->cli = "extruder=i";
     def->min = 0;  // 0 = inherit defaults
     def->enum_labels.push_back("default");  // override label for item 0
@@ -313,84 +322,84 @@ PrintConfigDef::PrintConfigDef()
     def->enum_labels.push_back("4");
 
     def = this->add("extruder_clearance_height", coFloat);
-    def->label = "Height";
-    def->tooltip = "Set this to the vertical distance between your nozzle tip and (usually) the X carriage rods. "
+    def->label = _L("Height");
+    def->tooltip = _L("Set this to the vertical distance between your nozzle tip and (usually) the X carriage rods. "
                    "In other words, this is the height of the clearance cylinder around your extruder, "
                    "and it represents the maximum depth the extruder can peek before colliding with "
-                   "other printed objects.";
-    def->sidetext = "mm";
+                   "other printed objects.");
+    def->sidetext = _L("mm");
     def->cli = "extruder-clearance-height=f";
     def->min = 0;
     def->default_value = new ConfigOptionFloat(20);
 
     def = this->add("extruder_clearance_radius", coFloat);
-    def->label = "Radius";
-    def->tooltip = "Set this to the clearance radius around your extruder. "
+    def->label = _L("Radius");
+    def->tooltip = _L("Set this to the clearance radius around your extruder. "
                    "If the extruder is not centered, choose the largest value for safety. "
                    "This setting is used to check for collisions and to display the graphical preview "
-                   "in the plater.";
-    def->sidetext = "mm";
+                   "in the plater.");
+    def->sidetext = _L("mm");
     def->cli = "extruder-clearance-radius=f";
     def->min = 0;
     def->default_value = new ConfigOptionFloat(20);
 
     def = this->add("extruder_colour", coStrings);
-    def->label = "Extruder Color";
-    def->tooltip = "This is only used in the Slic3r interface as a visual help.";
+    def->label = _L("Extruder Color");
+    def->tooltip = _L("This is only used in the Slic3r interface as a visual help.");
     def->cli = "extruder-color=s@";
     def->gui_type = "color";
     // Empty string means no color assigned yet.
     def->default_value = new ConfigOptionStrings { "" };
 
     def = this->add("extruder_offset", coPoints);
-    def->label = "Extruder offset";
-    def->tooltip = "If your firmware doesn't handle the extruder displacement you need the G-code "
+    def->label = _L("Extruder offset");
+    def->tooltip = _L("If your firmware doesn't handle the extruder displacement you need the G-code "
                    "to take it into account. This option lets you specify the displacement of each extruder "
                    "with respect to the first one. It expects positive coordinates (they will be subtracted "
-                   "from the XY coordinate).";
-    def->sidetext = "mm";
+                   "from the XY coordinate).");
+    def->sidetext = _L("mm");
     def->cli = "extruder-offset=s@";
     def->default_value = new ConfigOptionPoints { Pointf(0,0) };
 
     def = this->add("extrusion_axis", coString);
-    def->label = "Extrusion axis";
-    def->tooltip = "Use this option to set the axis letter associated to your printer's extruder "
-                   "(usually E but some printers use A).";
+    def->label = _L("Extrusion axis");
+    def->tooltip = _L("Use this option to set the axis letter associated to your printer's extruder "
+                   "(usually E but some printers use A).");
     def->cli = "extrusion-axis=s";
     def->default_value = new ConfigOptionString("E");
 
     def = this->add("extrusion_multiplier", coFloats);
-    def->label = "Extrusion multiplier";
-    def->tooltip = "This factor changes the amount of flow proportionally. You may need to tweak "
+    def->label = _L("Extrusion multiplier");
+    def->tooltip = _L("This factor changes the amount of flow proportionally. You may need to tweak "
                    "this setting to get nice surface finish and correct single wall widths. "
                    "Usual values are between 0.9 and 1.1. If you think you need to change this more, "
-                   "check filament diameter and your firmware E steps.";
+                   "check filament diameter and your firmware E steps.");
     def->cli = "extrusion-multiplier=f@";
     def->default_value = new ConfigOptionFloats { 1. };
     
     def = this->add("extrusion_width", coFloatOrPercent);
-    def->label = "Default extrusion width";
-    def->category = "Extrusion Width";
-    def->tooltip = "Set this to a non-zero value to allow a manual extrusion width. "
+    def->label = _L("Default extrusion width");
+    def->category = _L("Extrusion Width");
+    def->tooltip = _L("Set this to a non-zero value to allow a manual extrusion width. "
                    "If left to zero, Slic3r derives extrusion widths from the nozzle diameter "
                    "(see the tooltips for perimeter extrusion width, infill extrusion width etc). "
-                   "If expressed as percentage (for example: 230%), it will be computed over layer height.";
-    def->sidetext = "mm or % (leave 0 for auto)";
+                   "If expressed as percentage (for example: 230%), it will be computed over layer height.");
+    def->sidetext = _L("mm or % (leave 0 for auto)");
     def->cli = "extrusion-width=s";
     def->default_value = new ConfigOptionFloatOrPercent(0, false);
 
     def = this->add("fan_always_on", coBools);
-    def->label = "Keep fan always on";
-    def->tooltip = "If this is enabled, fan will never be disabled and will be kept running at least "
-                   "at its minimum speed. Useful for PLA, harmful for ABS.";
+    def->label = _L("Keep fan always on");
+    def->tooltip = _L("If this is enabled, fan will never be disabled and will be kept running at least "
+                   "at its minimum speed. Useful for PLA, harmful for ABS.");
     def->cli = "fan-always-on!";
     def->default_value = new ConfigOptionBools { false };
 
     def = this->add("fan_below_layer_time", coInts);
-    def->label = "Enable fan if layer print time is below";
-    def->tooltip = "If layer print time is estimated below this number of seconds, fan will be enabled "
-                   "and its speed will be calculated by interpolating the minimum and maximum speeds.";
-    def->sidetext = "approximate seconds";
+    def->label = _L("Enable fan if layer print time is below");
+    def->tooltip = _L("If layer print time is estimated below this number of seconds, fan will be enabled "
+                   "and its speed will be calculated by interpolating the minimum and maximum speeds.");
+    def->sidetext = _L("approximate seconds");
     def->cli = "fan-below-layer-time=i@";
     def->width = 60;
     def->min = 0;
@@ -398,15 +407,15 @@ PrintConfigDef::PrintConfigDef()
     def->default_value = new ConfigOptionInts { 60 };
 
     def = this->add("filament_colour", coStrings);
-    def->label = "Color";
-    def->tooltip = "This is only used in the Slic3r interface as a visual help.";
+    def->label = _L("Color");
+    def->tooltip = _L("This is only used in the Slic3r interface as a visual help.");
     def->cli = "filament-color=s@";
     def->gui_type = "color";
     def->default_value = new ConfigOptionStrings { "#29b2b2" };
 
     def = this->add("filament_notes", coStrings);
-    def->label = "Filament notes";
-    def->tooltip = "You can put your notes regarding the filament here.";
+    def->label = _L("Filament notes");
+    def->tooltip = _L("You can put your notes regarding the filament here.");
     def->cli = "filament-notes=s@";
     def->multiline = true;
     def->full_width = true;
@@ -414,40 +423,40 @@ PrintConfigDef::PrintConfigDef()
     def->default_value = new ConfigOptionStrings { "" };
 
     def = this->add("filament_max_volumetric_speed", coFloats);
-    def->label = "Max volumetric speed";
-    def->tooltip = "Maximum volumetric speed allowed for this filament. Limits the maximum volumetric "
+    def->label = _L("Max volumetric speed");
+    def->tooltip = _L("Maximum volumetric speed allowed for this filament. Limits the maximum volumetric "
                    "speed of a print to the minimum of print and filament volumetric speed. "
-                   "Set to zero for no limit.";
-    def->sidetext = "mm³/s";
+                   "Set to zero for no limit.");
+    def->sidetext = _L("mm\u00B3/s");
     def->cli = "filament-max-volumetric-speed=f@";
     def->min = 0;
     def->default_value = new ConfigOptionFloats { 0. };
 
     def = this->add("filament_diameter", coFloats);
-    def->label = "Diameter";
-    def->tooltip = "Enter your filament diameter here. Good precision is required, so use a caliper "
-                   "and do multiple measurements along the filament, then compute the average.";
-    def->sidetext = "mm";
+    def->label = _L("Diameter");
+    def->tooltip = _L("Enter your filament diameter here. Good precision is required, so use a caliper "
+                   "and do multiple measurements along the filament, then compute the average.");
+    def->sidetext = _L("mm");
     def->cli = "filament-diameter=f@";
     def->min = 0;
     def->default_value = new ConfigOptionFloats { 3. };
 
     def = this->add("filament_density", coFloats);
-    def->label = "Density";
-    def->tooltip = "Enter your filament density here. This is only for statistical information. "
+    def->label = _L("Density");
+    def->tooltip = _L("Enter your filament density here. This is only for statistical information. "
                    "A decent way is to weigh a known length of filament and compute the ratio "
-                   "of the length to volume. Better is to calculate the volume directly through displacement.";
-    def->sidetext = "g/cm^3";
+                   "of the length to volume. Better is to calculate the volume directly through displacement.");
+    def->sidetext = _L("g/cm\u00B3");
     def->cli = "filament-density=f@";
     def->min = 0;
     def->default_value = new ConfigOptionFloats { 0. };
 
     def = this->add("filament_type", coStrings);
-    def->label = "Filament type";
-    def->tooltip = "If you want to process the output G-code through custom scripts, just list their "
+    def->label = _L("Filament type");
+    def->tooltip = _L("If you want to process the output G-code through custom scripts, just list their "
                    "absolute paths here. Separate multiple scripts with a semicolon. Scripts will be passed "
                    "the absolute path to the G-code file as the first argument, and they can access "
-                   "the Slic3r config settings by reading environment variables.";
+                   "the Slic3r config settings by reading environment variables.");
     def->cli = "filament_type=s@";
     def->gui_type = "f_enum_open";
     def->gui_flags = "show_value";
@@ -463,15 +472,15 @@ PrintConfigDef::PrintConfigDef()
     def->default_value = new ConfigOptionStrings { "PLA" };
 
     def = this->add("filament_soluble", coBools);
-    def->label = "Soluble material";
-    def->tooltip = "Soluble material is most likely used for a soluble support.";
+    def->label = _L("Soluble material");
+    def->tooltip = _L("Soluble material is most likely used for a soluble support.");
     def->cli = "filament-soluble!";
     def->default_value = new ConfigOptionBools { false };
 
     def = this->add("filament_cost", coFloats);
-    def->label = "Cost";
-    def->tooltip = "Enter your filament cost per kg here. This is only for statistical information.";
-    def->sidetext = "money/kg";
+    def->label = _L("Cost");
+    def->tooltip = _L("Enter your filament cost per kg here. This is only for statistical information.");
+    def->sidetext = _L("money/kg");
     def->cli = "filament-cost=f@";
     def->min = 0;
     def->default_value = new ConfigOptionFloats { 0. };
@@ -480,12 +489,12 @@ PrintConfigDef::PrintConfigDef()
     def->default_value = new ConfigOptionStrings { "" };
 
     def = this->add("fill_angle", coFloat);
-    def->label = "Fill angle";
-    def->category = "Infill";
-    def->tooltip = "Default base angle for infill orientation. Cross-hatching will be applied to this. "
+    def->label = _L("Fill angle");
+    def->category = _L("Infill");
+    def->tooltip = _L("Default base angle for infill orientation. Cross-hatching will be applied to this. "
                    "Bridges will be infilled using the best direction Slic3r can detect, so this setting "
-                   "does not affect them.";
-    def->sidetext = "°";
+                   "does not affect them.");
+    def->sidetext = _L("\u00B0");
     def->cli = "fill-angle=f";
     def->min = 0;
     def->max = 360;
@@ -494,10 +503,10 @@ PrintConfigDef::PrintConfigDef()
     def = this->add("fill_density", coPercent);
     def->gui_type = "f_enum_open";
     def->gui_flags = "show_value";
-    def->label = "Fill density";
-    def->category = "Infill";
-    def->tooltip = "Density of internal infill, expressed in the range 0% - 100%.";
-    def->sidetext = "%";
+    def->label = _L("Fill density");
+    def->category = _L("Infill");
+    def->tooltip = _L("Density of internal infill, expressed in the range 0% - 100%.");
+    def->sidetext = _L("%");
     def->cli = "fill-density=s";
     def->min = 0;
     def->max = 100;
@@ -532,9 +541,9 @@ PrintConfigDef::PrintConfigDef()
     def->default_value = new ConfigOptionPercent(20);
 
     def = this->add("fill_pattern", coEnum);
-    def->label = "Fill pattern";
-    def->category = "Infill";
-    def->tooltip = "Fill pattern for general low-density infill.";
+    def->label = _L("Fill pattern");
+    def->category = _L("Infill");
+    def->tooltip = _L("Fill pattern for general low-density infill.");
     def->cli = "fill-pattern=s";
     def->enum_keys_map = &ConfigOptionEnum<InfillPattern>::get_enum_values();
     def->enum_values.push_back("rectilinear");
@@ -564,181 +573,183 @@ PrintConfigDef::PrintConfigDef()
     def->default_value = new ConfigOptionEnum<InfillPattern>(ipStars);
 
     def = this->add("first_layer_acceleration", coFloat);
-    def->label = "First layer";
-    def->tooltip = "This is the acceleration your printer will use for first layer. Set zero "
-                   "to disable acceleration control for first layer.";
-    def->sidetext = "mm/s²";
+    def->label = _L("First layer");
+    def->tooltip = _L("This is the acceleration your printer will use for first layer. Set zero "
+                   "to disable acceleration control for first layer.");
+    def->sidetext = _L("mm/s\u00B2");
     def->cli = "first-layer-acceleration=f";
     def->min = 0;
     def->default_value = new ConfigOptionFloat(0);
 
     def = this->add("first_layer_bed_temperature", coInts);
-    def->label = "First layer";
-    def->tooltip = "Heated build plate temperature for the first layer. Set this to zero to disable "
-                   "bed temperature control commands in the output.";
+    def->label = _L("First layer");
+    def->tooltip = _L("Heated build plate temperature for the first layer. Set this to zero to disable "
+                   "bed temperature control commands in the output.");
     def->cli = "first-layer-bed-temperature=i@";
     def->max = 0;
     def->max = 300;
     def->default_value = new ConfigOptionInts { 0 };
 
     def = this->add("first_layer_extrusion_width", coFloatOrPercent);
-    def->label = "First layer";
-    def->category = "Extrusion Width";
-    def->tooltip = "Set this to a non-zero value to set a manual extrusion width for first layer. "
+    def->label = _L("First layer");
+    def->category = _L("Extrusion Width");
+    def->tooltip = _L("Set this to a non-zero value to set a manual extrusion width for first layer. "
                    "You can use this to force fatter extrudates for better adhesion. If expressed "
                    "as percentage (for example 120%) it will be computed over first layer height. "
-                   "If set to zero, it will use the default extrusion width.";
-    def->sidetext = "mm or % (leave 0 for default)";
+                   "If set to zero, it will use the default extrusion width.");
+    def->sidetext = _L("mm or % (leave 0 for default)");
     def->cli = "first-layer-extrusion-width=s";
     def->ratio_over = "first_layer_height";
     def->default_value = new ConfigOptionFloatOrPercent(200, true);
 
     def = this->add("first_layer_height", coFloatOrPercent);
-    def->label = "First layer height";
-    def->category = "Layers and Perimeters";
-    def->tooltip = "When printing with very low layer heights, you might still want to print a thicker "
+    def->label = _L("First layer height");
+    def->category = _L("Layers and Perimeters");
+    def->tooltip = _L("When printing with very low layer heights, you might still want to print a thicker "
                    "bottom layer to improve adhesion and tolerance for non perfect build plates. "
                    "This can be expressed as an absolute value or as a percentage (for example: 150%) "
-                   "over the default layer height.";
-    def->sidetext = "mm or %";
+                   "over the default layer height.");
+    def->sidetext = _L("mm or %");
     def->cli = "first-layer-height=s";
     def->ratio_over = "layer_height";
     def->default_value = new ConfigOptionFloatOrPercent(0.35, false);
 
     def = this->add("first_layer_speed", coFloatOrPercent);
-    def->label = "First layer speed";
-    def->tooltip = "If expressed as absolute value in mm/s, this speed will be applied to all the print moves "
+    def->label = _L("First layer speed");
+    def->tooltip = _L("If expressed as absolute value in mm/s, this speed will be applied to all the print moves "
                    "of the first layer, regardless of their type. If expressed as a percentage "
-                   "(for example: 40%) it will scale the default speeds.";
-    def->sidetext = "mm/s or %";
+                   "(for example: 40%) it will scale the default speeds.");
+    def->sidetext = _L("mm/s or %");
     def->cli = "first-layer-speed=s";
     def->min = 0;
     def->default_value = new ConfigOptionFloatOrPercent(30, false);
 
     def = this->add("first_layer_temperature", coInts);
-    def->label = "First layer";
-    def->tooltip = "Extruder temperature for first layer. If you want to control temperature manually "
-                   "during print, set this to zero to disable temperature control commands in the output file.";
+    def->label = _L("First layer");
+    def->tooltip = _L("Extruder temperature for first layer. If you want to control temperature manually "
+                   "during print, set this to zero to disable temperature control commands in the output file.");
     def->cli = "first-layer-temperature=i@";
     def->min = 0;
     def->max = max_temp;
     def->default_value = new ConfigOptionInts { 200 };
     
     def = this->add("gap_fill_speed", coFloat);
-    def->label = "Gap fill";
-    def->category = "Speed";
-    def->tooltip = "Speed for filling small gaps using short zigzag moves. Keep this reasonably low "
-                   "to avoid too much shaking and resonance issues. Set zero to disable gaps filling.";
-    def->sidetext = "mm/s";
+    def->label = _L("Gap fill");
+    def->category = _L("Speed");
+    def->tooltip = _L("Speed for filling small gaps using short zigzag moves. Keep this reasonably low "
+                   "to avoid too much shaking and resonance issues. Set zero to disable gaps filling.");
+    def->sidetext = _L("mm/s");
     def->cli = "gap-fill-speed=f";
     def->min = 0;
     def->default_value = new ConfigOptionFloat(20);
 
     def = this->add("gcode_comments", coBool);
-    def->label = "Verbose G-code";
-    def->tooltip = "Enable this to get a commented G-code file, with each line explained by a descriptive text. "
+    def->label = _L("Verbose G-code");
+    def->tooltip = _L("Enable this to get a commented G-code file, with each line explained by a descriptive text. "
                    "If you print from SD card, the additional weight of the file could make your firmware "
-                   "slow down.";
+                   "slow down.");
     def->cli = "gcode-comments!";
     def->default_value = new ConfigOptionBool(0);
 
     def = this->add("gcode_flavor", coEnum);
-    def->label = "G-code flavor";
-    def->tooltip = "Some G/M-code commands, including temperature control and others, are not universal. "
+    def->label = _L("G-code flavor");
+    def->tooltip = _L("Some G/M-code commands, including temperature control and others, are not universal. "
                    "Set this option to your printer's firmware to get a compatible output. "
-                   "The \"No extrusion\" flavor prevents Slic3r from exporting any extrusion value at all.";
+                   "The \"No extrusion\" flavor prevents Slic3r from exporting any extrusion value at all.");
     def->cli = "gcode-flavor=s";
     def->enum_keys_map = &ConfigOptionEnum<GCodeFlavor>::get_enum_values();
     def->enum_values.push_back("reprap");
     def->enum_values.push_back("repetier");
     def->enum_values.push_back("teacup");
     def->enum_values.push_back("makerware");
+    def->enum_values.push_back("marlin");
     def->enum_values.push_back("sailfish");
     def->enum_values.push_back("mach3");
     def->enum_values.push_back("machinekit");
     def->enum_values.push_back("smoothie");
     def->enum_values.push_back("no-extrusion");
-    def->enum_labels.push_back("RepRap (Marlin/Sprinter)");
+    def->enum_labels.push_back("RepRap/Sprinter");
     def->enum_labels.push_back("Repetier");
     def->enum_labels.push_back("Teacup");
     def->enum_labels.push_back("MakerWare (MakerBot)");
+    def->enum_labels.push_back("Marlin");
     def->enum_labels.push_back("Sailfish (MakerBot)");
     def->enum_labels.push_back("Mach3/LinuxCNC");
     def->enum_labels.push_back("Machinekit");
     def->enum_labels.push_back("Smoothie");
     def->enum_labels.push_back("No extrusion");
-    def->default_value = new ConfigOptionEnum<GCodeFlavor>(gcfRepRap);
+    def->default_value = new ConfigOptionEnum<GCodeFlavor>(gcfMarlin);
 
     def = this->add("infill_acceleration", coFloat);
-    def->label = "Infill";
-    def->tooltip = "This is the acceleration your printer will use for infill. Set zero to disable "
-                   "acceleration control for infill.";
-    def->sidetext = "mm/s²";
+    def->label = _L("Infill");
+    def->tooltip = _L("This is the acceleration your printer will use for infill. Set zero to disable "
+                   "acceleration control for infill.");
+    def->sidetext = _L("mm/s\u00B2");
     def->cli = "infill-acceleration=f";
     def->min = 0;
     def->default_value = new ConfigOptionFloat(0);
 
     def = this->add("infill_every_layers", coInt);
-    def->label = "Combine infill every";
-    def->category = "Infill";
-    def->tooltip = "This feature allows to combine infill and speed up your print by extruding thicker "
-                   "infill layers while preserving thin perimeters, thus accuracy.";
-    def->sidetext = "layers";
+    def->label = _L("Combine infill every");
+    def->category = _L("Infill");
+    def->tooltip = _L("This feature allows to combine infill and speed up your print by extruding thicker "
+                   "infill layers while preserving thin perimeters, thus accuracy.");
+    def->sidetext = _L("layers");
     def->cli = "infill-every-layers=i";
-    def->full_label = "Combine infill every n layers";
+    def->full_label = _L("Combine infill every n layers");
     def->min = 1;
     def->default_value = new ConfigOptionInt(1);
 
     def = this->add("infill_extruder", coInt);
-    def->label = "Infill extruder";
-    def->category = "Extruders";
-    def->tooltip = "The extruder to use when printing infill.";
+    def->label = _L("Infill extruder");
+    def->category = _L("Extruders");
+    def->tooltip = _L("The extruder to use when printing infill.");
     def->cli = "infill-extruder=i";
     def->min = 1;
     def->default_value = new ConfigOptionInt(1);
 
     def = this->add("infill_extrusion_width", coFloatOrPercent);
-    def->label = "Infill";
-    def->category = "Extrusion Width";
-    def->tooltip = "Set this to a non-zero value to set a manual extrusion width for infill. "
+    def->label = _L("Infill");
+    def->category = _L("Extrusion Width");
+    def->tooltip = _L("Set this to a non-zero value to set a manual extrusion width for infill. "
                    "If left zero, default extrusion width will be used if set, otherwise 1.125 x nozzle diameter will be used. "
                    "You may want to use fatter extrudates to speed up the infill and make your parts stronger. "
-                   "If expressed as percentage (for example 90%) it will be computed over layer height.";
-    def->sidetext = "mm or % (leave 0 for default)";
+                   "If expressed as percentage (for example 90%) it will be computed over layer height.");
+    def->sidetext = _L("mm or % (leave 0 for default)");
     def->cli = "infill-extrusion-width=s";
     def->default_value = new ConfigOptionFloatOrPercent(0, false);
 
     def = this->add("infill_first", coBool);
-    def->label = "Infill before perimeters";
-    def->tooltip = "This option will switch the print order of perimeters and infill, making the latter first.";
+    def->label = _L("Infill before perimeters");
+    def->tooltip = _L("This option will switch the print order of perimeters and infill, making the latter first.");
     def->cli = "infill-first!";
     def->default_value = new ConfigOptionBool(false);
 
     def = this->add("infill_only_where_needed", coBool);
-    def->label = "Only infill where needed";
-    def->category = "Infill";
-    def->tooltip = "This option will limit infill to the areas actually needed for supporting ceilings "
+    def->label = _L("Only infill where needed");
+    def->category = _L("Infill");
+    def->tooltip = _L("This option will limit infill to the areas actually needed for supporting ceilings "
                    "(it will act as internal support material). If enabled, slows down the G-code generation "
-                   "due to the multiple checks involved.";
+                   "due to the multiple checks involved.");
     def->cli = "infill-only-where-needed!";
     def->default_value = new ConfigOptionBool(false);
 
     def = this->add("infill_overlap", coFloatOrPercent);
-    def->label = "Infill/perimeters overlap";
-    def->category = "Advanced";
-    def->tooltip = "This setting applies an additional overlap between infill and perimeters for better bonding. "
+    def->label = _L("Infill/perimeters overlap");
+    def->category = _L("Advanced");
+    def->tooltip = _L("This setting applies an additional overlap between infill and perimeters for better bonding. "
                    "Theoretically this shouldn't be needed, but backlash might cause gaps. If expressed "
-                   "as percentage (example: 15%) it is calculated over perimeter extrusion width.";
-    def->sidetext = "mm or %";
+                   "as percentage (example: 15%) it is calculated over perimeter extrusion width.");
+    def->sidetext = _L("mm or %");
     def->cli = "infill-overlap=s";
     def->ratio_over = "perimeter_extrusion_width";
     def->default_value = new ConfigOptionFloatOrPercent(25, true);
 
     def = this->add("infill_speed", coFloat);
-    def->label = "Infill";
-    def->category = "Speed";
-    def->tooltip = "Speed for printing the internal fill. Set to zero for auto.";
-    def->sidetext = "mm/s";
+    def->label = _L("Infill");
+    def->category = _L("Speed");
+    def->tooltip = _L("Speed for printing the internal fill. Set to zero for auto.");
+    def->sidetext = _L("mm/s");
     def->cli = "infill-speed=f";
     def->aliases.push_back("print_feed_rate");
     def->aliases.push_back("infill_feed_rate");
@@ -746,19 +757,19 @@ PrintConfigDef::PrintConfigDef()
     def->default_value = new ConfigOptionFloat(80);
 
     def = this->add("interface_shells", coBool);
-    def->label = "Interface shells";
-    def->tooltip = "Force the generation of solid shells between adjacent materials/volumes. "
+    def->label = _L("Interface shells");
+    def->tooltip = _L("Force the generation of solid shells between adjacent materials/volumes. "
                    "Useful for multi-extruder prints with translucent materials or manual soluble "
-                   "support material.";
+                   "support material.");
     def->cli = "interface-shells!";
-    def->category = "Layers and Perimeters";
+    def->category = _L("Layers and Perimeters");
     def->default_value = new ConfigOptionBool(false);
 
     def = this->add("layer_gcode", coString);
-    def->label = "After layer change G-code";
-    def->tooltip = "This custom code is inserted at every layer change, right after the Z move "
+    def->label = _L("After layer change G-code");
+    def->tooltip = _L("This custom code is inserted at every layer change, right after the Z move "
                    "and before the extruder moves to the first layer point. Note that you can use "
-                   "placeholder variables for all Slic3r settings as well as [layer_num] and [layer_z].";
+                   "placeholder variables for all Slic3r settings as well as [layer_num] and [layer_z].");
     def->cli = "after-layer-gcode|layer-gcode=s";
     def->multiline = true;
     def->full_width = true;
@@ -766,116 +777,116 @@ PrintConfigDef::PrintConfigDef()
     def->default_value = new ConfigOptionString("");
 
     def = this->add("layer_height", coFloat);
-    def->label = "Layer height";
-    def->category = "Layers and Perimeters";
-    def->tooltip = "This setting controls the height (and thus the total number) of the slices/layers. "
-                   "Thinner layers give better accuracy but take more time to print.";
-    def->sidetext = "mm";
+    def->label = _L("Layer height");
+    def->category = _L("Layers and Perimeters");
+    def->tooltip = _L("This setting controls the height (and thus the total number) of the slices/layers. "
+                   "Thinner layers give better accuracy but take more time to print.");
+    def->sidetext = _L("mm");
     def->cli = "layer-height=f";
     def->min = 0;
     def->default_value = new ConfigOptionFloat(0.3);
 
     def = this->add("max_fan_speed", coInts);
-    def->label = "Max";
-    def->tooltip = "This setting represents the maximum speed of your fan.";
-    def->sidetext = "%";
+    def->label = _L("Max");
+    def->tooltip = _L("This setting represents the maximum speed of your fan.");
+    def->sidetext = _L("%");
     def->cli = "max-fan-speed=i@";
     def->min = 0;
     def->max = 100;
     def->default_value = new ConfigOptionInts { 100 };
 
     def = this->add("max_layer_height", coFloats);
-    def->label = "Max";
-    def->tooltip = "This is the highest printable layer height for this extruder, used to cap "
+    def->label = _L("Max");
+    def->tooltip = _L("This is the highest printable layer height for this extruder, used to cap "
                    "the variable layer height and support layer height. Maximum recommended layer height "
                    "is 75% of the extrusion width to achieve reasonable inter-layer adhesion. "
-                   "If set to 0, layer height is limited to 75% of the nozzle diameter.";
-    def->sidetext = "mm";
+                   "If set to 0, layer height is limited to 75% of the nozzle diameter.");
+    def->sidetext = _L("mm");
     def->cli = "max-layer-height=f@";
     def->min = 0;
     def->default_value = new ConfigOptionFloats { 0. };
 
     def = this->add("max_print_speed", coFloat);
-    def->label = "Max print speed";
-    def->tooltip = "When setting other speed settings to 0 Slic3r will autocalculate the optimal speed "
+    def->label = _L("Max print speed");
+    def->tooltip = _L("When setting other speed settings to 0 Slic3r will autocalculate the optimal speed "
                    "in order to keep constant extruder pressure. This experimental setting is used "
-                   "to set the highest print speed you want to allow.";
-    def->sidetext = "mm/s";
+                   "to set the highest print speed you want to allow.");
+    def->sidetext = _L("mm/s");
     def->cli = "max-print-speed=f";
     def->min = 1;
     def->default_value = new ConfigOptionFloat(80);
 
     def = this->add("max_volumetric_speed", coFloat);
-    def->label = "Max volumetric speed";
-    def->tooltip = "This experimental setting is used to set the maximum volumetric speed your "
-                   "extruder supports.";
-    def->sidetext = "mm³/s";
+    def->label = _L("Max volumetric speed");
+    def->tooltip = _L("This experimental setting is used to set the maximum volumetric speed your "
+                   "extruder supports.");
+    def->sidetext = _L("mm\u00B3/s");
     def->cli = "max-volumetric-speed=f";
     def->min = 0;
     def->default_value = new ConfigOptionFloat(0);
 
     def = this->add("max_volumetric_extrusion_rate_slope_positive", coFloat);
-    def->label = "Max volumetric slope positive";
-    def->tooltip = "This experimental setting is used to limit the speed of change in extrusion rate. "
-                   "A value of 1.8 mm³/s² ensures, that a change from the extrusion rate "
-                   "of 1.8 mm³/s (0.45mm extrusion width, 0.2mm extrusion height, feedrate 20 mm/s) "
-                   "to 5.4 mm³/s (feedrate 60 mm/s) will take at least 2 seconds.";
-    def->sidetext = "mm³/s²";
+    def->label = _L("Max volumetric slope positive");
+    def->tooltip = _L("This experimental setting is used to limit the speed of change in extrusion rate. "
+                   "A value of 1.8 mm\u00B3/s\u00B2 ensures, that a change from the extrusion rate "
+                   "of 1.8 mm\u00B3/s (0.45mm extrusion width, 0.2mm extrusion height, feedrate 20 mm/s) "
+                   "to 5.4 mm\u00B3/s (feedrate 60 mm/s) will take at least 2 seconds.");
+    def->sidetext = _L("mm\u00B3/s\u00B2");
     def->cli = "max-volumetric-extrusion-rate-slope-positive=f";
     def->min = 0;
     def->default_value = new ConfigOptionFloat(0);
 
     def = this->add("max_volumetric_extrusion_rate_slope_negative", coFloat);
-    def->label = "Max volumetric slope negative";
-    def->tooltip = "This experimental setting is used to limit the speed of change in extrusion rate. "
-                   "A value of 1.8 mm³/s² ensures, that a change from the extrusion rate "
-                   "of 1.8 mm³/s (0.45mm extrusion width, 0.2mm extrusion height, feedrate 20 mm/s) "
-                   "to 5.4 mm³/s (feedrate 60 mm/s) will take at least 2 seconds.";
-    def->sidetext = "mm³/s²";
+    def->label = _L("Max volumetric slope negative");
+    def->tooltip = _L("This experimental setting is used to limit the speed of change in extrusion rate. "
+                   "A value of 1.8 mm\u00B3/s\u00B2 ensures, that a change from the extrusion rate "
+                   "of 1.8 mm\u00B3/s (0.45mm extrusion width, 0.2mm extrusion height, feedrate 20 mm/s) "
+                   "to 5.4 mm\u00B3/s (feedrate 60 mm/s) will take at least 2 seconds.");
+    def->sidetext = _L("mm\u00B3/s\u00B2");
     def->cli = "max-volumetric-extrusion-rate-slope-negative=f";
     def->min = 0;
     def->default_value = new ConfigOptionFloat(0);
 
     def = this->add("min_fan_speed", coInts);
-    def->label = "Min";
-    def->tooltip = "This setting represents the minimum PWM your fan needs to work.";
-    def->sidetext = "%";
+    def->label = _L("Min");
+    def->tooltip = _L("This setting represents the minimum PWM your fan needs to work.");
+    def->sidetext = _L("%");
     def->cli = "min-fan-speed=i@";
     def->min = 0;
     def->max = 100;
     def->default_value = new ConfigOptionInts { 35 };
 
     def = this->add("min_layer_height", coFloats);
-    def->label = "Min";
-    def->tooltip = "This is the lowest printable layer height for this extruder and limits "
-                   "the resolution for variable layer height. Typical values are between 0.05 mm and 0.1 mm.";
-    def->sidetext = "mm";
+    def->label = _L("Min");
+    def->tooltip = _L("This is the lowest printable layer height for this extruder and limits "
+                   "the resolution for variable layer height. Typical values are between 0.05 mm and 0.1 mm.");
+    def->sidetext = _L("mm");
     def->cli = "min-layer-height=f@";
     def->min = 0;
     def->default_value = new ConfigOptionFloats { 0.07 };
 
     def = this->add("min_print_speed", coFloats);
-    def->label = "Min print speed";
-    def->tooltip = "Slic3r will not scale speed down below this speed.";
-    def->sidetext = "mm/s";
+    def->label = _L("Min print speed");
+    def->tooltip = _L("Slic3r will not scale speed down below this speed.");
+    def->sidetext = _L("mm/s");
     def->cli = "min-print-speed=f@";
     def->min = 0;
     def->default_value = new ConfigOptionFloats { 10. };
 
     def = this->add("min_skirt_length", coFloat);
-    def->label = "Minimum extrusion length";
-    def->tooltip = "Generate no less than the number of skirt loops required to consume "
+    def->label = _L("Minimum extrusion length");
+    def->tooltip = _L("Generate no less than the number of skirt loops required to consume "
                    "the specified amount of filament on the bottom layer. For multi-extruder machines, "
-                   "this minimum applies to each extruder.";
-    def->sidetext = "mm";
+                   "this minimum applies to each extruder.");
+    def->sidetext = _L("mm");
     def->cli = "min-skirt-length=f";
     def->min = 0;
     def->default_value = new ConfigOptionFloat(0);
 
     def = this->add("notes", coString);
-    def->label = "Configuration notes";
-    def->tooltip = "You can put here your personal notes. This text will be added to the G-code "
-                   "header comments.";
+    def->label = _L("Configuration notes");
+    def->tooltip = _L("You can put here your personal notes. This text will be added to the G-code "
+                   "header comments.");
     def->cli = "notes=s";
     def->multiline = true;
     def->full_width = true;
@@ -883,127 +894,128 @@ PrintConfigDef::PrintConfigDef()
     def->default_value = new ConfigOptionString("");
 
     def = this->add("nozzle_diameter", coFloats);
-    def->label = "Nozzle diameter";
-    def->tooltip = "This is the diameter of your extruder nozzle (for example: 0.5, 0.35 etc.)";
-    def->sidetext = "mm";
+    def->label = _L("Nozzle diameter");
+    def->tooltip = _L("This is the diameter of your extruder nozzle (for example: 0.5, 0.35 etc.)");
+    def->sidetext = _L("mm");
     def->cli = "nozzle-diameter=f@";
     def->default_value = new ConfigOptionFloats { 0.5 };
 
     def = this->add("octoprint_apikey", coString);
-    def->label = "API Key";
-    def->tooltip = "Slic3r can upload G-code files to OctoPrint. This field should contain "
-                   "the API Key required for authentication.";
+    def->label = _L("API Key");
+    def->tooltip = _L("Slic3r can upload G-code files to OctoPrint. This field should contain "
+                   "the API Key required for authentication.");
     def->cli = "octoprint-apikey=s";
     def->default_value = new ConfigOptionString("");
     
     def = this->add("octoprint_host", coString);
-    def->label = "Host or IP";
-    def->tooltip = "Slic3r can upload G-code files to OctoPrint. This field should contain "
-                   "the hostname or IP address of the OctoPrint instance.";
+    def->label = _L("Host or IP");
+    def->tooltip = _L("Slic3r can upload G-code files to OctoPrint. This field should contain "
+                   "the hostname or IP address of the OctoPrint instance.");
     def->cli = "octoprint-host=s";
     def->default_value = new ConfigOptionString("");
 
     def = this->add("only_retract_when_crossing_perimeters", coBool);
-    def->label = "Only retract when crossing perimeters";
-    def->tooltip = "Disables retraction when the travel path does not exceed the upper layer's perimeters "
-                   "(and thus any ooze will be probably invisible).";
+    def->label = _L("Only retract when crossing perimeters");
+    def->tooltip = _L("Disables retraction when the travel path does not exceed the upper layer's perimeters "
+                   "(and thus any ooze will be probably invisible).");
     def->cli = "only-retract-when-crossing-perimeters!";
     def->default_value = new ConfigOptionBool(true);
 
     def = this->add("ooze_prevention", coBool);
-    def->label = "Enable";
-    def->tooltip = "This option will drop the temperature of the inactive extruders to prevent oozing. "
+    def->label = _L("Enable");
+    def->tooltip = _L("This option will drop the temperature of the inactive extruders to prevent oozing. "
                    "It will enable a tall skirt automatically and move extruders outside such "
-                   "skirt when changing temperatures.";
+                   "skirt when changing temperatures.");
     def->cli = "ooze-prevention!";
     def->default_value = new ConfigOptionBool(false);
 
     def = this->add("output_filename_format", coString);
-    def->label = "Output filename format";
-    def->tooltip = "You can use all configuration options as variables inside this template. "
+    def->label = _L("Output filename format");
+    def->tooltip = _L("You can use all configuration options as variables inside this template. "
                    "For example: [layer_height], [fill_density] etc. You can also use [timestamp], "
                    "[year], [month], [day], [hour], [minute], [second], [version], [input_filename], "
-                   "[input_filename_base].";
+                   "[input_filename_base].");
     def->cli = "output-filename-format=s";
     def->full_width = true;
     def->default_value = new ConfigOptionString("[input_filename_base].gcode");
 
     def = this->add("overhangs", coBool);
-    def->label = "Detect bridging perimeters";
-    def->category = "Layers and Perimeters";
-    def->tooltip = "Experimental option to adjust flow for overhangs (bridge flow will be used), "
-                   "to apply bridge speed to them and enable fan.";
+    def->label = _L("Detect bridging perimeters");
+    def->category = _L("Layers and Perimeters");
+    def->tooltip = _L("Experimental option to adjust flow for overhangs (bridge flow will be used), "
+                   "to apply bridge speed to them and enable fan.");
     def->cli = "overhangs!";
     def->default_value = new ConfigOptionBool(true);
 
     def = this->add("perimeter_acceleration", coFloat);
-    def->label = "Perimeters";
-    def->tooltip = "This is the acceleration your printer will use for perimeters. "
+    def->label = _L("Perimeters");
+    def->tooltip = _L("This is the acceleration your printer will use for perimeters. "
                    "A high value like 9000 usually gives good results if your hardware is up to the job. "
-                   "Set zero to disable acceleration control for perimeters.";
-    def->sidetext = "mm/s²";
+                   "Set zero to disable acceleration control for perimeters.");
+    def->sidetext = _L("mm/s\u00B2");
     def->cli = "perimeter-acceleration=f";
     def->default_value = new ConfigOptionFloat(0);
 
     def = this->add("perimeter_extruder", coInt);
-    def->label = "Perimeter extruder";
-    def->category = "Extruders";
-    def->tooltip = "The extruder to use when printing perimeters and brim. First extruder is 1.";
+    def->label = _L("Perimeter extruder");
+    def->category = _L("Extruders");
+    def->tooltip = _L("The extruder to use when printing perimeters and brim. First extruder is 1.");
     def->cli = "perimeter-extruder=i";
     def->aliases.push_back("perimeters_extruder");
     def->min = 1;
     def->default_value = new ConfigOptionInt(1);
 
     def = this->add("perimeter_extrusion_width", coFloatOrPercent);
-    def->label = "Perimeters";
-    def->category = "Extrusion Width";
-    def->tooltip = "Set this to a non-zero value to set a manual extrusion width for perimeters. "
+    def->label = _L("Perimeters");
+    def->category = _L("Extrusion Width");
+    def->tooltip = _L("Set this to a non-zero value to set a manual extrusion width for perimeters. "
                    "You may want to use thinner extrudates to get more accurate surfaces. "
                    "If left zero, default extrusion width will be used if set, otherwise 1.125 x nozzle diameter will be used. "
-                   "If expressed as percentage (for example 200%) it will be computed over layer height.";
-    def->sidetext = "mm or % (leave 0 for default)";
+                   "If expressed as percentage (for example 200%) it will be computed over layer height.");
+    def->sidetext = _L("mm or % (leave 0 for default)");
     def->cli = "perimeter-extrusion-width=s";
     def->aliases.push_back("perimeters_extrusion_width");
     def->default_value = new ConfigOptionFloatOrPercent(0, false);
 
     def = this->add("perimeter_speed", coFloat);
-    def->label = "Perimeters";
-    def->category = "Speed";
-    def->tooltip = "Speed for perimeters (contours, aka vertical shells). Set to zero for auto.";
-    def->sidetext = "mm/s";
+    def->label = _L("Perimeters");
+    def->category = _L("Speed");
+    def->tooltip = _L("Speed for perimeters (contours, aka vertical shells). Set to zero for auto.");
+    def->sidetext = _L("mm/s");
     def->cli = "perimeter-speed=f";
     def->aliases.push_back("perimeter_feed_rate");
     def->min = 0;
     def->default_value = new ConfigOptionFloat(60);
 
     def = this->add("perimeters", coInt);
-    def->label = "Perimeters";
-    def->category = "Layers and Perimeters";
-    def->tooltip = "This option sets the number of perimeters to generate for each layer. "
+    def->label = _L("Perimeters");
+    def->category = _L("Layers and Perimeters");
+    def->tooltip = _L("This option sets the number of perimeters to generate for each layer. "
                    "Note that Slic3r may increase this number automatically when it detects "
                    "sloping surfaces which benefit from a higher number of perimeters "
-                   "if the Extra Perimeters option is enabled.";
-    def->sidetext = "(minimum)";
+                   "if the Extra Perimeters option is enabled.");
+    def->sidetext = _L("(minimum)");
     def->cli = "perimeters=i";
     def->aliases.push_back("perimeter_offsets");
     def->min = 0;
     def->default_value = new ConfigOptionInt(3);
 
     def = this->add("post_process", coStrings);
-    def->label = "Post-processing scripts";
-    def->tooltip = "If you want to process the output G-code through custom scripts, "
+    def->label = _L("Post-processing scripts");
+    def->tooltip = _L("If you want to process the output G-code through custom scripts, "
                    "just list their absolute paths here. Separate multiple scripts with a semicolon. "
                    "Scripts will be passed the absolute path to the G-code file as the first argument, "
-                   "and they can access the Slic3r config settings by reading environment variables.";
+                   "and they can access the Slic3r config settings by reading environment variables.");
     def->cli = "post-process=s@";
     def->gui_flags = "serialized";
     def->multiline = true;
     def->full_width = true;
-    def->height = 60;
+	def->height = 60;
+	def->default_value = new ConfigOptionStrings{ "" };
 
     def = this->add("printer_notes", coString);
-    def->label = "Printer notes";
-    def->tooltip = "You can put your notes regarding the printer here.";
+    def->label = _L("Printer notes");
+    def->tooltip = _L("You can put your notes regarding the printer here.");
     def->cli = "printer-notes=s";
     def->multiline = true;
     def->full_width = true;
@@ -1017,131 +1029,131 @@ PrintConfigDef::PrintConfigDef()
     def->default_value = new ConfigOptionString("");
 
     def = this->add("raft_layers", coInt);
-    def->label = "Raft layers";
-    def->category = "Support material";
-    def->tooltip = "The object will be raised by this number of layers, and support material "
-                   "will be generated under it.";
-    def->sidetext = "layers";
+    def->label = _L("Raft layers");
+    def->category = _L("Support material");
+    def->tooltip = _L("The object will be raised by this number of layers, and support material "
+                   "will be generated under it.");
+    def->sidetext = _L("layers");
     def->cli = "raft-layers=i";
     def->min = 0;
     def->default_value = new ConfigOptionInt(0);
 
     def = this->add("resolution", coFloat);
-    def->label = "Resolution";
-    def->tooltip = "Minimum detail resolution, used to simplify the input file for speeding up "
+    def->label = _L("Resolution");
+    def->tooltip = _L("Minimum detail resolution, used to simplify the input file for speeding up "
                    "the slicing job and reducing memory usage. High-resolution models often carry "
                    "more detail than printers can render. Set to zero to disable any simplification "
-                   "and use full resolution from input.";
-    def->sidetext = "mm";
+                   "and use full resolution from input.");
+    def->sidetext = _L("mm");
     def->cli = "resolution=f";
     def->min = 0;
     def->default_value = new ConfigOptionFloat(0);
 
     def = this->add("retract_before_travel", coFloats);
-    def->label = "Minimum travel after retraction";
-    def->tooltip = "Retraction is not triggered when travel moves are shorter than this length.";
-    def->sidetext = "mm";
+    def->label = _L("Minimum travel after retraction");
+    def->tooltip = _L("Retraction is not triggered when travel moves are shorter than this length.");
+    def->sidetext = _L("mm");
     def->cli = "retract-before-travel=f@";
     def->default_value = new ConfigOptionFloats { 2. };
 
     def = this->add("retract_before_wipe", coPercents);
-    def->label = "Retract amount before wipe";
-    def->tooltip = "With bowden extruders, it may be wise to do some amount of quick retract "
-                   "before doing the wipe movement.";
-    def->sidetext = "%";
+    def->label = _L("Retract amount before wipe");
+    def->tooltip = _L("With bowden extruders, it may be wise to do some amount of quick retract "
+                   "before doing the wipe movement.");
+    def->sidetext = _L("%");
     def->cli = "retract-before-wipe=s@";
     def->default_value = new ConfigOptionPercents { 0. };
     
     def = this->add("retract_layer_change", coBools);
-    def->label = "Retract on layer change";
-    def->tooltip = "This flag enforces a retraction whenever a Z move is done.";
+    def->label = _L("Retract on layer change");
+    def->tooltip = _L("This flag enforces a retraction whenever a Z move is done.");
     def->cli = "retract-layer-change!";
     def->default_value = new ConfigOptionBools { false };
 
     def = this->add("retract_length", coFloats);
-    def->label = "Length";
-    def->full_label = "Retraction Length";
-    def->tooltip = "When retraction is triggered, filament is pulled back by the specified amount "
-                   "(the length is measured on raw filament, before it enters the extruder).";
-    def->sidetext = "mm (zero to disable)";
+    def->label = _L("Length");
+    def->full_label = _L("Retraction Length");
+    def->tooltip = _L("When retraction is triggered, filament is pulled back by the specified amount "
+                   "(the length is measured on raw filament, before it enters the extruder).");
+    def->sidetext = _L("mm (zero to disable)");
     def->cli = "retract-length=f@";
     def->default_value = new ConfigOptionFloats { 2. };
 
     def = this->add("retract_length_toolchange", coFloats);
-    def->label = "Length";
-    def->full_label = "Retraction Length (Toolchange)";
-    def->tooltip = "When retraction is triggered before changing tool, filament is pulled back "
+    def->label = _L("Length");
+    def->full_label = _L("Retraction Length (Toolchange)");
+    def->tooltip = _L("When retraction is triggered before changing tool, filament is pulled back "
                    "by the specified amount (the length is measured on raw filament, before it enters "
-                   "the extruder).";
-    def->sidetext = "mm (zero to disable)";
+                   "the extruder).");
+    def->sidetext = _L("mm (zero to disable)");
     def->cli = "retract-length-toolchange=f@";
     def->default_value = new ConfigOptionFloats { 10. };
 
     def = this->add("retract_lift", coFloats);
-    def->label = "Lift Z";
-    def->tooltip = "If you set this to a positive value, Z is quickly raised every time a retraction "
+    def->label = _L("Lift Z");
+    def->tooltip = _L("If you set this to a positive value, Z is quickly raised every time a retraction "
                    "is triggered. When using multiple extruders, only the setting for the first extruder "
-                   "will be considered.";
-    def->sidetext = "mm";
+                   "will be considered.");
+    def->sidetext = _L("mm");
     def->cli = "retract-lift=f@";
     def->default_value = new ConfigOptionFloats { 0. };
 
     def = this->add("retract_lift_above", coFloats);
-    def->label = "Above Z";
-    def->full_label = "Only lift Z above";
-    def->tooltip = "If you set this to a positive value, Z lift will only take place above the specified "
-                   "absolute Z. You can tune this setting for skipping lift on the first layers.";
-    def->sidetext = "mm";
+    def->label = _L("Above Z");
+    def->full_label = _L("Only lift Z above");
+    def->tooltip = _L("If you set this to a positive value, Z lift will only take place above the specified "
+                   "absolute Z. You can tune this setting for skipping lift on the first layers.");
+    def->sidetext = _L("mm");
     def->cli = "retract-lift-above=f@";
     def->default_value = new ConfigOptionFloats { 0. };
 
     def = this->add("retract_lift_below", coFloats);
-    def->label = "Below Z";
-    def->full_label = "Only lift Z below";
-    def->tooltip = "If you set this to a positive value, Z lift will only take place below "
+    def->label = _L("Below Z");
+    def->full_label = _L("Only lift Z below");
+    def->tooltip = _L("If you set this to a positive value, Z lift will only take place below "
                    "the specified absolute Z. You can tune this setting for limiting lift "
-                   "to the first layers.";
-    def->sidetext = "mm";
+                   "to the first layers.");
+    def->sidetext = _L("mm");
     def->cli = "retract-lift-below=f@";
     def->default_value = new ConfigOptionFloats { 0. };
 
     def = this->add("retract_restart_extra", coFloats);
-    def->label = "Extra length on restart";
-    def->tooltip = "When the retraction is compensated after the travel move, the extruder will push "
-                   "this additional amount of filament. This setting is rarely needed.";
-    def->sidetext = "mm";
+    def->label = _L("Extra length on restart");
+    def->tooltip = _L("When the retraction is compensated after the travel move, the extruder will push "
+                   "this additional amount of filament. This setting is rarely needed.");
+    def->sidetext = _L("mm");
     def->cli = "retract-restart-extra=f@";
     def->default_value = new ConfigOptionFloats { 0. };
 
     def = this->add("retract_restart_extra_toolchange", coFloats);
-    def->label = "Extra length on restart";
-    def->tooltip = "When the retraction is compensated after changing tool, the extruder will push "
-                   "this additional amount of filament.";
-    def->sidetext = "mm";
+    def->label = _L("Extra length on restart");
+    def->tooltip = _L("When the retraction is compensated after changing tool, the extruder will push "
+                   "this additional amount of filament.");
+    def->sidetext = _L("mm");
     def->cli = "retract-restart-extra-toolchange=f@";
     def->default_value = new ConfigOptionFloats { 0. };
 
     def = this->add("retract_speed", coFloats);
-    def->label = "Retraction Speed";
-    def->full_label = "Retraction Speed";
-    def->tooltip = "The speed for retractions (it only applies to the extruder motor).";
-    def->sidetext = "mm/s";
+    def->label = _L("Retraction Speed");
+    def->full_label = _L("Retraction Speed");
+    def->tooltip = _L("The speed for retractions (it only applies to the extruder motor).");
+    def->sidetext = _L("mm/s");
     def->cli = "retract-speed=f@";
     def->default_value = new ConfigOptionFloats { 40. };
 
     def = this->add("deretract_speed", coFloats);
-    def->label = "Deretraction Speed";
-    def->full_label = "Deretraction Speed";
-    def->tooltip = "The speed for loading of a filament into extruder after retraction "
-                   "(it only applies to the extruder motor). If left to zero, the retraction speed is used.";
-    def->sidetext = "mm/s";
+    def->label = _L("Deretraction Speed");
+    def->full_label = _L("Deretraction Speed");
+    def->tooltip = _L("The speed for loading of a filament into extruder after retraction "
+                   "(it only applies to the extruder motor). If left to zero, the retraction speed is used.");
+    def->sidetext = _L("mm/s");
     def->cli = "retract-speed=f@";
     def->default_value = new ConfigOptionFloats { 0. };
 
     def = this->add("seam_position", coEnum);
-    def->label = "Seam position";
-    def->category = "Layers and Perimeters";
-    def->tooltip = "Position of perimeters starting points.";
+    def->label = _L("Seam position");
+    def->category = _L("Layers and Perimeters");
+    def->tooltip = _L("Position of perimeters starting points.");
     def->cli = "seam-position=s";
     def->enum_keys_map = &ConfigOptionEnum<SeamPosition>::get_enum_values();
     def->enum_values.push_back("random");
@@ -1157,10 +1169,10 @@ PrintConfigDef::PrintConfigDef()
 #if 0
     def = this->add("seam_preferred_direction", coFloat);
 //    def->gui_type = "slider";
-    def->label = "Direction";
-    def->sidetext = "°";
-    def->full_label = "Preferred direction of the seam";
-    def->tooltip = "Seam preferred direction";
+    def->label = _L("Direction");
+    def->sidetext = _L("\u00B0");
+    def->full_label = _L("Preferred direction of the seam");
+    def->tooltip = _L("Seam preferred direction");
     def->cli = "seam-preferred-direction=f";
     def->min = 0;
     def->max = 360;
@@ -1168,10 +1180,10 @@ PrintConfigDef::PrintConfigDef()
 
     def = this->add("seam_preferred_direction_jitter", coFloat);
 //    def->gui_type = "slider";
-    def->label = "Jitter";
-    def->sidetext = "°";
-    def->full_label = "Seam preferred direction jitter";
-    def->tooltip = "Preferred direction of the seam - jitter";
+    def->label = _L("Jitter");
+    def->sidetext = _L("\u00B0");
+    def->full_label = _L("Seam preferred direction jitter");
+    def->tooltip = _L("Preferred direction of the seam - jitter");
     def->cli = "seam-preferred-direction-jitter=f";
     def->min = 0;
     def->max = 360;
@@ -1181,17 +1193,17 @@ PrintConfigDef::PrintConfigDef()
     def = this->add("serial_port", coString);
     def->gui_type = "select_open";
     def->label = "";
-    def->full_label = "Serial port";
-    def->tooltip = "USB/serial port for printer connection.";
+    def->full_label = _L("Serial port");
+    def->tooltip = _L("USB/serial port for printer connection.");
     def->cli = "serial-port=s";
     def->width = 200;
     def->default_value = new ConfigOptionString("");
 
     def = this->add("serial_speed", coInt);
     def->gui_type = "i_enum_open";
-    def->label = "Speed";
-    def->full_label = "Serial port speed";
-    def->tooltip = "Speed (baud) of USB/serial port for printer connection.";
+    def->label = _L("Speed");
+    def->full_label = _L("Serial port speed");
+    def->tooltip = _L("Speed (baud) of USB/serial port for printer connection.");
     def->cli = "serial-speed=i";
     def->min = 1;
     def->max = 300000;
@@ -1200,37 +1212,37 @@ PrintConfigDef::PrintConfigDef()
     def->default_value = new ConfigOptionInt(250000);
 
     def = this->add("skirt_distance", coFloat);
-    def->label = "Distance from object";
-    def->tooltip = "Distance between skirt and object(s). Set this to zero to attach the skirt "
-                   "to the object(s) and get a brim for better adhesion.";
-    def->sidetext = "mm";
+    def->label = _L("Distance from object");
+    def->tooltip = _L("Distance between skirt and object(s). Set this to zero to attach the skirt "
+                   "to the object(s) and get a brim for better adhesion.");
+    def->sidetext = _L("mm");
     def->cli = "skirt-distance=f";
     def->min = 0;
     def->default_value = new ConfigOptionFloat(6);
 
     def = this->add("skirt_height", coInt);
-    def->label = "Skirt height";
-    def->tooltip = "Height of skirt expressed in layers. Set this to a tall value to use skirt "
-                   "as a shield against drafts.";
-    def->sidetext = "layers";
+    def->label = _L("Skirt height");
+    def->tooltip = _L("Height of skirt expressed in layers. Set this to a tall value to use skirt "
+                   "as a shield against drafts.");
+    def->sidetext = _L("layers");
     def->cli = "skirt-height=i";
     def->default_value = new ConfigOptionInt(1);
 
     def = this->add("skirts", coInt);
-    def->label = "Loops (minimum)";
-    def->full_label = "Skirt Loops";
-    def->tooltip = "Number of loops for the skirt. If the Minimum Extrusion Length option is set, "
+    def->label = _L("Loops (minimum)");
+    def->full_label = _L("Skirt Loops");
+    def->tooltip = _L("Number of loops for the skirt. If the Minimum Extrusion Length option is set, "
                    "the number of loops might be greater than the one configured here. Set this to zero "
-                   "to disable skirt completely.";
+                   "to disable skirt completely.");
     def->cli = "skirts=i";
     def->min = 0;
     def->default_value = new ConfigOptionInt(1);
     
     def = this->add("slowdown_below_layer_time", coInts);
-    def->label = "Slow down if layer print time is below";
-    def->tooltip = "If layer print time is estimated below this number of seconds, print moves "
-                   "speed will be scaled down to extend duration to this value.";
-    def->sidetext = "approximate seconds";
+    def->label = _L("Slow down if layer print time is below");
+    def->tooltip = _L("If layer print time is estimated below this number of seconds, print moves "
+                   "speed will be scaled down to extend duration to this value.");
+    def->sidetext = _L("approximate seconds");
     def->cli = "slowdown-below-layer-time=i@";
     def->width = 60;
     def->min = 0;
@@ -1238,63 +1250,63 @@ PrintConfigDef::PrintConfigDef()
     def->default_value = new ConfigOptionInts { 5 };
 
     def = this->add("small_perimeter_speed", coFloatOrPercent);
-    def->label = "Small perimeters";
-    def->category = "Speed";
-    def->tooltip = "This separate setting will affect the speed of perimeters having radius <= 6.5mm "
+    def->label = _L("Small perimeters");
+    def->category = _L("Speed");
+    def->tooltip = _L("This separate setting will affect the speed of perimeters having radius <= 6.5mm "
                    "(usually holes). If expressed as percentage (for example: 80%) it will be calculated "
-                   "on the perimeters speed setting above. Set to zero for auto.";
-    def->sidetext = "mm/s or %";
+                   "on the perimeters speed setting above. Set to zero for auto.");
+    def->sidetext = _L("mm/s or %");
     def->cli = "small-perimeter-speed=s";
     def->ratio_over = "perimeter_speed";
     def->min = 0;
     def->default_value = new ConfigOptionFloatOrPercent(15, false);
 
     def = this->add("solid_infill_below_area", coFloat);
-    def->label = "Solid infill threshold area";
-    def->category = "Infill";
-    def->tooltip = "Force solid infill for regions having a smaller area than the specified threshold.";
-    def->sidetext = "mm²";
+    def->label = _L("Solid infill threshold area");
+    def->category = _L("Infill");
+    def->tooltip = _L("Force solid infill for regions having a smaller area than the specified threshold.");
+    def->sidetext = _L("mm\u00B2");
     def->cli = "solid-infill-below-area=f";
     def->min = 0;
     def->default_value = new ConfigOptionFloat(70);
 
     def = this->add("solid_infill_extruder", coInt);
-    def->label = "Solid infill extruder";
-    def->category = "Extruders";
-    def->tooltip = "The extruder to use when printing solid infill.";
+    def->label = _L("Solid infill extruder");
+    def->category = _L("Extruders");
+    def->tooltip = _L("The extruder to use when printing solid infill.");
     def->cli = "solid-infill-extruder=i";
     def->min = 1;
     def->default_value = new ConfigOptionInt(1);
 
     def = this->add("solid_infill_every_layers", coInt);
-    def->label = "Solid infill every";
-    def->category = "Infill";
-    def->tooltip = "This feature allows to force a solid layer every given number of layers. "
+    def->label = _L("Solid infill every");
+    def->category = _L("Infill");
+    def->tooltip = _L("This feature allows to force a solid layer every given number of layers. "
                    "Zero to disable. You can set this to any value (for example 9999); "
                    "Slic3r will automatically choose the maximum possible number of layers "
-                   "to combine according to nozzle diameter and layer height.";
-    def->sidetext = "layers";
+                   "to combine according to nozzle diameter and layer height.");
+    def->sidetext = _L("layers");
     def->cli = "solid-infill-every-layers=i";
     def->min = 0;
     def->default_value = new ConfigOptionInt(0);
 
     def = this->add("solid_infill_extrusion_width", coFloatOrPercent);
-    def->label = "Solid infill";
-    def->category = "Extrusion Width";
-    def->tooltip = "Set this to a non-zero value to set a manual extrusion width for infill for solid surfaces. "
+    def->label = _L("Solid infill");
+    def->category = _L("Extrusion Width");
+    def->tooltip = _L("Set this to a non-zero value to set a manual extrusion width for infill for solid surfaces. "
                    "If left zero, default extrusion width will be used if set, otherwise 1.125 x nozzle diameter will be used. "
-                   "If expressed as percentage (for example 90%) it will be computed over layer height.";
-    def->sidetext = "mm or % (leave 0 for default)";
+                   "If expressed as percentage (for example 90%) it will be computed over layer height.");
+    def->sidetext = _L("mm or % (leave 0 for default)");
     def->cli = "solid-infill-extrusion-width=s";
     def->default_value = new ConfigOptionFloatOrPercent(0, false);
 
     def = this->add("solid_infill_speed", coFloatOrPercent);
-    def->label = "Solid infill";
-    def->category = "Speed";
-    def->tooltip = "Speed for printing solid regions (top/bottom/internal horizontal shells). "
+    def->label = _L("Solid infill");
+    def->category = _L("Speed");
+    def->tooltip = _L("Speed for printing solid regions (top/bottom/internal horizontal shells). "
                    "This can be expressed as a percentage (for example: 80%) over the default "
-                   "infill speed above. Set to zero for auto.";
-    def->sidetext = "mm/s or %";
+                   "infill speed above. Set to zero for auto.");
+    def->sidetext = _L("mm/s or %");
     def->cli = "solid-infill-speed=s";
     def->ratio_over = "infill_speed";
     def->aliases.push_back("solid_infill_feed_rate");
@@ -1302,42 +1314,42 @@ PrintConfigDef::PrintConfigDef()
     def->default_value = new ConfigOptionFloatOrPercent(20, false);
 
     def = this->add("solid_layers", coInt);
-    def->label = "Solid layers";
-    def->tooltip = "Number of solid layers to generate on top and bottom surfaces.";
+    def->label = _L("Solid layers");
+    def->tooltip = _L("Number of solid layers to generate on top and bottom surfaces.");
     def->cli = "solid-layers=i";
     def->shortcut.push_back("top_solid_layers");
     def->shortcut.push_back("bottom_solid_layers");
     def->min = 0;
 
     def = this->add("spiral_vase", coBool);
-    def->label = "Spiral vase";
-    def->tooltip = "This feature will raise Z gradually while printing a single-walled object "
+    def->label = _L("Spiral vase");
+    def->tooltip = _L("This feature will raise Z gradually while printing a single-walled object "
                    "in order to remove any visible seam. This option requires a single perimeter, "
                    "no infill, no top solid layers and no support material. You can still set "
                    "any number of bottom solid layers as well as skirt/brim loops. "
-                   "It won't work when printing more than an object.";
+                   "It won't work when printing more than an object.");
     def->cli = "spiral-vase!";
     def->default_value = new ConfigOptionBool(false);
 
     def = this->add("standby_temperature_delta", coInt);
-    def->label = "Temperature variation";
-    def->tooltip = "Temperature difference to be applied when an extruder is not active. "
-                   "Enables a full-height \"sacrificial\" skirt on which the nozzles are periodically wiped.";
-    def->sidetext = "∆°C";
+    def->label = _L("Temperature variation");
+    def->tooltip = _L("Temperature difference to be applied when an extruder is not active. "
+                   "Enables a full-height \"sacrificial\" skirt on which the nozzles are periodically wiped.");
+	def->sidetext = "∆°C";
     def->cli = "standby-temperature-delta=i";
     def->min = -max_temp;
     def->max = max_temp;
     def->default_value = new ConfigOptionInt(-5);
 
     def = this->add("start_gcode", coString);
-    def->label = "Start G-code";
-    def->tooltip = "This start procedure is inserted at the beginning, after bed has reached "
+    def->label = _L("Start G-code");
+    def->tooltip = _L("This start procedure is inserted at the beginning, after bed has reached "
                    "the target temperature and extruder just started heating, and before extruder "
                    "has finished heating. If Slic3r detects M104 or M190 in your custom codes, "
                    "such commands will not be prepended automatically so you're free to customize "
                    "the order of heating commands and other custom actions. Note that you can use "
                    "placeholder variables for all Slic3r settings, so you can put "
-                   "a \"M109 S[first_layer_temperature]\" command wherever you want.";
+                   "a \"M109 S[first_layer_temperature]\" command wherever you want.");
     def->cli = "start-gcode=s";
     def->multiline = true;
     def->full_width = true;
@@ -1345,15 +1357,15 @@ PrintConfigDef::PrintConfigDef()
     def->default_value = new ConfigOptionString("G28 ; home all axes\nG1 Z5 F5000 ; lift nozzle\n");
 
     def = this->add("start_filament_gcode", coStrings);
-    def->label = "Start G-code";
-    def->tooltip = "This start procedure is inserted at the beginning, after any printer start gcode. "
+    def->label = _L("Start G-code");
+    def->tooltip = _L("This start procedure is inserted at the beginning, after any printer start gcode. "
                    "This is used to override settings for a specific filament. If Slic3r detects "
                    "M104, M109, M140 or M190 in your custom codes, such commands will "
                    "not be prepended automatically so you're free to customize the order "
                    "of heating commands and other custom actions. Note that you can use placeholder variables "
                    "for all Slic3r settings, so you can put a \"M109 S[first_layer_temperature]\" command "
                    "wherever you want. If you have multiple extruders, the gcode is processed "
-                   "in extruder order.";
+                   "in extruder order.");
     def->cli = "start-filament-gcode=s@";
     def->multiline = true;
     def->full_width = true;
@@ -1361,24 +1373,24 @@ PrintConfigDef::PrintConfigDef()
     def->default_value = new ConfigOptionStrings { "; Filament gcode\n" };
 
     def = this->add("single_extruder_multi_material", coBool);
-    def->label = "Single Extruder Multi Material";
-    def->tooltip = "The printer multiplexes filaments into a single hot end.";
+    def->label = _L("Single Extruder Multi Material");
+    def->tooltip = _L("The printer multiplexes filaments into a single hot end.");
     def->cli = "single-extruder-multi-material!";
     def->default_value = new ConfigOptionBool(false);
 
     def = this->add("support_material", coBool);
-    def->label = "Generate support material";
-    def->category = "Support material";
-    def->tooltip = "Enable support material generation.";
+    def->label = _L("Generate support material");
+    def->category = _L("Support material");
+    def->tooltip = _L("Enable support material generation.");
     def->cli = "support-material!";
     def->default_value = new ConfigOptionBool(false);
 
     def = this->add("support_material_xy_spacing", coFloatOrPercent);
-    def->label = "XY separation between an object and its support";
-    def->category = "Support material";
-    def->tooltip = "XY separation between an object and its support. If expressed as percentage "
-                   "(for example 50%), it will be calculated over external perimeter width.";
-    def->sidetext = "mm or %";
+    def->label = _L("XY separation between an object and its support");
+    def->category = _L("Support material");
+    def->tooltip = _L("XY separation between an object and its support. If expressed as percentage "
+                   "(for example 50%), it will be calculated over external perimeter width.");
+    def->sidetext = _L("mm or %");
     def->cli = "support-material-xy-spacing=s";
     def->ratio_over = "external_perimeter_extrusion_width";
     def->min = 0;
@@ -1386,30 +1398,30 @@ PrintConfigDef::PrintConfigDef()
     def->default_value = new ConfigOptionFloatOrPercent(50, true);
 
     def = this->add("support_material_angle", coFloat);
-    def->label = "Pattern angle";
-    def->category = "Support material";
-    def->tooltip = "Use this setting to rotate the support material pattern on the horizontal plane.";
-    def->sidetext = "°";
+    def->label = _L("Pattern angle");
+    def->category = _L("Support material");
+    def->tooltip = _L("Use this setting to rotate the support material pattern on the horizontal plane.");
+    def->sidetext = _L("\u00B0");
     def->cli = "support-material-angle=f";
     def->min = 0;
     def->max = 359;
     def->default_value = new ConfigOptionFloat(0);
 
     def = this->add("support_material_buildplate_only", coBool);
-    def->label = "Support on build plate only";
-    def->category = "Support material";
-    def->tooltip = "Only create support if it lies on a build plate. Don't create support on a print.";
+    def->label = _L("Support on build plate only");
+    def->category = _L("Support material");
+    def->tooltip = _L("Only create support if it lies on a build plate. Don't create support on a print.");
     def->cli = "support-material-buildplate-only!";
     def->default_value = new ConfigOptionBool(false);
 
     def = this->add("support_material_contact_distance", coFloat);
     def->gui_type = "f_enum_open";
-    def->label = "Contact Z distance";
-    def->category = "Support material";
-    def->tooltip = "The vertical distance between object and support material interface. "
+    def->label = _L("Contact Z distance");
+    def->category = _L("Support material");
+    def->tooltip = _L("The vertical distance between object and support material interface. "
                    "Setting this to 0 will also prevent Slic3r from using bridge flow and speed "
-                   "for the first object layer.";
-    def->sidetext = "mm";
+                   "for the first object layer.");
+    def->sidetext = _L("mm");
     def->cli = "support-material-contact-distance=f";
     def->min = 0;
     def->enum_values.push_back("0");
@@ -1419,86 +1431,86 @@ PrintConfigDef::PrintConfigDef()
     def->default_value = new ConfigOptionFloat(0.2);
 
     def = this->add("support_material_enforce_layers", coInt);
-    def->label = "Enforce support for the first";
-    def->category = "Support material";
-    def->tooltip = "Generate support material for the specified number of layers counting from bottom, "
+    def->label = _L("Enforce support for the first");
+    def->category = _L("Support material");
+    def->tooltip = _L("Generate support material for the specified number of layers counting from bottom, "
                    "regardless of whether normal support material is enabled or not and regardless "
                    "of any angle threshold. This is useful for getting more adhesion of objects "
-                   "having a very thin or poor footprint on the build plate.";
-    def->sidetext = "layers";
+                   "having a very thin or poor footprint on the build plate.");
+    def->sidetext = _L("layers");
     def->cli = "support-material-enforce-layers=f";
-    def->full_label = "Enforce support for the first n layers";
+    def->full_label = _L("Enforce support for the first n layers");
     def->min = 0;
     def->default_value = new ConfigOptionInt(0);
 
     def = this->add("support_material_extruder", coInt);
-    def->label = "Support material/raft/skirt extruder";
-    def->category = "Extruders";
-    def->tooltip = "The extruder to use when printing support material, raft and skirt "
-                   "(1+, 0 to use the current extruder to minimize tool changes).";
+    def->label = _L("Support material/raft/skirt extruder");
+    def->category = _L("Extruders");
+    def->tooltip = _L("The extruder to use when printing support material, raft and skirt "
+                   "(1+, 0 to use the current extruder to minimize tool changes).");
     def->cli = "support-material-extruder=i";
     def->min = 0;
     def->default_value = new ConfigOptionInt(1);
 
     def = this->add("support_material_extrusion_width", coFloatOrPercent);
-    def->label = "Support material";
-    def->category = "Extrusion Width";
-    def->tooltip = "Set this to a non-zero value to set a manual extrusion width for support material. "
+    def->label = _L("Support material");
+    def->category = _L("Extrusion Width");
+    def->tooltip = _L("Set this to a non-zero value to set a manual extrusion width for support material. "
                    "If left zero, default extrusion width will be used if set, otherwise nozzle diameter will be used. "
-                   "If expressed as percentage (for example 90%) it will be computed over layer height.";
-    def->sidetext = "mm or % (leave 0 for default)";
+                   "If expressed as percentage (for example 90%) it will be computed over layer height.");
+    def->sidetext = _L("mm or % (leave 0 for default)");
     def->cli = "support-material-extrusion-width=s";
     def->default_value = new ConfigOptionFloatOrPercent(0, false);
 
     def = this->add("support_material_interface_contact_loops", coBool);
-    def->label = "Interface loops";
-    def->category = "Support material";
-    def->tooltip = "Cover the top contact layer of the supports with loops. Disabled by default.";
+    def->label = _L("Interface loops");
+    def->category = _L("Support material");
+    def->tooltip = _L("Cover the top contact layer of the supports with loops. Disabled by default.");
     def->cli = "support-material-interface-contact-loops!";
     def->default_value = new ConfigOptionBool(false);
 
     def = this->add("support_material_interface_extruder", coInt);
-    def->label = "Support material/raft interface extruder";
-    def->category = "Extruders";
-    def->tooltip = "The extruder to use when printing support material interface "
-                   "(1+, 0 to use the current extruder to minimize tool changes). This affects raft too.";
+    def->label = _L("Support material/raft interface extruder");
+    def->category = _L("Extruders");
+    def->tooltip = _L("The extruder to use when printing support material interface "
+                   "(1+, 0 to use the current extruder to minimize tool changes). This affects raft too.");
     def->cli = "support-material-interface-extruder=i";
     def->min = 0;
     def->default_value = new ConfigOptionInt(1);
 
     def = this->add("support_material_interface_layers", coInt);
-    def->label = "Interface layers";
-    def->category = "Support material";
-    def->tooltip = "Number of interface layers to insert between the object(s) and support material.";
-    def->sidetext = "layers";
+    def->label = _L("Interface layers");
+    def->category = _L("Support material");
+    def->tooltip = _L("Number of interface layers to insert between the object(s) and support material.");
+    def->sidetext = _L("layers");
     def->cli = "support-material-interface-layers=i";
     def->min = 0;
     def->default_value = new ConfigOptionInt(3);
 
     def = this->add("support_material_interface_spacing", coFloat);
-    def->label = "Interface pattern spacing";
-    def->category = "Support material";
-    def->tooltip = "Spacing between interface lines. Set zero to get a solid interface.";
-    def->sidetext = "mm";
+    def->label = _L("Interface pattern spacing");
+    def->category = _L("Support material");
+    def->tooltip = _L("Spacing between interface lines. Set zero to get a solid interface.");
+    def->sidetext = _L("mm");
     def->cli = "support-material-interface-spacing=f";
     def->min = 0;
     def->default_value = new ConfigOptionFloat(0);
 
     def = this->add("support_material_interface_speed", coFloatOrPercent);
-    def->label = "Support material interface";
-    def->category = "Support material";
-    def->tooltip = "Speed for printing support material interface layers. If expressed as percentage "
-                   "(for example 50%) it will be calculated over support material speed.";
-    def->sidetext = "mm/s or %";
+    def->label = _L("Support material interface");
+    def->category = _L("Support material");
+    def->tooltip = _L("Speed for printing support material interface layers. If expressed as percentage "
+                   "(for example 50%) it will be calculated over support material speed.");
+    def->sidetext = _L("mm/s or %");
     def->cli = "support-material-interface-speed=s";
     def->ratio_over = "support_material_speed";
     def->min = 0;
     def->default_value = new ConfigOptionFloatOrPercent(100, true);
 
     def = this->add("support_material_pattern", coEnum);
-    def->label = "Pattern";
-    def->category = "Support material";
-    def->tooltip = "Pattern used to generate support material.";
+    def->label = _L("Pattern");
+    def->category = _L("Support material");
+    def->tooltip = _L("Pattern used to generate support material.");
     def->cli = "support-material-pattern=s";
     def->enum_keys_map = &ConfigOptionEnum<SupportMaterialPattern>::get_enum_values();
     def->enum_values.push_back("rectilinear");
@@ -1512,75 +1524,75 @@ PrintConfigDef::PrintConfigDef()
     def->default_value = new ConfigOptionEnum<SupportMaterialPattern>(smpPillars);
 
     def = this->add("support_material_spacing", coFloat);
-    def->label = "Pattern spacing";
-    def->category = "Support material";
-    def->tooltip = "Spacing between support material lines.";
-    def->sidetext = "mm";
+    def->label = _L("Pattern spacing");
+    def->category = _L("Support material");
+    def->tooltip = _L("Spacing between support material lines.");
+    def->sidetext = _L("mm");
     def->cli = "support-material-spacing=f";
     def->min = 0;
     def->default_value = new ConfigOptionFloat(2.5);
 
     def = this->add("support_material_speed", coFloat);
-    def->label = "Support material";
-    def->category = "Support material";
-    def->tooltip = "Speed for printing support material.";
-    def->sidetext = "mm/s";
+    def->label = _L("Support material");
+    def->category = _L("Support material");
+    def->tooltip = _L("Speed for printing support material.");
+    def->sidetext = _L("mm/s");
     def->cli = "support-material-speed=f";
     def->min = 0;
     def->default_value = new ConfigOptionFloat(60);
 
     def = this->add("support_material_synchronize_layers", coBool);
-    def->label = "Synchronize with object layers";
-    def->category = "Support material";
-    def->tooltip = "Synchronize support layers with the object print layers. This is useful "
-                   "with multi-material printers, where the extruder switch is expensive.";
+    def->label = _L("Synchronize with object layers");
+    def->category = _L("Support material");
+    def->tooltip = _L("Synchronize support layers with the object print layers. This is useful "
+                   "with multi-material printers, where the extruder switch is expensive.");
     def->cli = "support-material-synchronize-layers!";
     def->default_value = new ConfigOptionBool(false);
 
     def = this->add("support_material_threshold", coInt);
-    def->label = "Overhang threshold";
-    def->category = "Support material";
-    def->tooltip = "Support material will not be generated for overhangs whose slope angle "
-                   "(90° = vertical) is above the given threshold. In other words, this value "
+    def->label = _L("Overhang threshold");
+    def->category = _L("Support material");
+    def->tooltip = _L("Support material will not be generated for overhangs whose slope angle "
+                   "(90\u00B0 = vertical) is above the given threshold. In other words, this value "
                    "represent the most horizontal slope (measured from the horizontal plane) "
                    "that you can print without support material. Set to zero for automatic detection "
-                   "(recommended).";
-    def->sidetext = "°";
+                   "(recommended).");
+    def->sidetext = _L("\u00B0");
     def->cli = "support-material-threshold=i";
     def->min = 0;
     def->max = 90;
     def->default_value = new ConfigOptionInt(0);
 
     def = this->add("support_material_with_sheath", coBool);
-    def->label = "With sheath around the support";
-    def->category = "Support material";
-    def->tooltip = "Add a sheath (a single perimeter line) around the base support. This makes "
-                   "the support more reliable, but also more difficult to remove.";
+    def->label = _L("With sheath around the support");
+    def->category = _L("Support material");
+    def->tooltip = _L("Add a sheath (a single perimeter line) around the base support. This makes "
+                   "the support more reliable, but also more difficult to remove.");
     def->cli = "support-material-with-sheath!";
     def->default_value = new ConfigOptionBool(true);
 
     def = this->add("temperature", coInts);
-    def->label = "Other layers";
-    def->tooltip = "Extruder temperature for layers after the first one. Set this to zero to disable "
-                   "temperature control commands in the output.";
+    def->label = _L("Other layers");
+    def->tooltip = _L("Extruder temperature for layers after the first one. Set this to zero to disable "
+                   "temperature control commands in the output.");
     def->cli = "temperature=i@";
-    def->full_label = "Temperature";
+    def->full_label = _L("Temperature");
     def->max = 0;
     def->max = max_temp;
     def->default_value = new ConfigOptionInts { 200 };
     
     def = this->add("thin_walls", coBool);
-    def->label = "Detect thin walls";
-    def->category = "Layers and Perimeters";
-    def->tooltip = "Detect single-width walls (parts where two extrusions don't fit and we need "
-                   "to collapse them into a single trace).";
+    def->label = _L("Detect thin walls");
+    def->category = _L("Layers and Perimeters");
+    def->tooltip = _L("Detect single-width walls (parts where two extrusions don't fit and we need "
+                   "to collapse them into a single trace).");
     def->cli = "thin-walls!";
     def->default_value = new ConfigOptionBool(true);
 
     def = this->add("threads", coInt);
-    def->label = "Threads";
-    def->tooltip = "Threads are used to parallelize long-running tasks. Optimal threads number "
-                   "is slightly above the number of available cores/processors.";
+    def->label = _L("Threads");
+    def->tooltip = _L("Threads are used to parallelize long-running tasks. Optimal threads number "
+                   "is slightly above the number of available cores/processors.");
     def->cli = "threads|j=i";
     def->readonly = true;
     def->min = 1;
@@ -1590,10 +1602,10 @@ PrintConfigDef::PrintConfigDef()
     }
     
     def = this->add("toolchange_gcode", coString);
-    def->label = "Tool change G-code";
-    def->tooltip = "This custom code is inserted right before every extruder change. "
+    def->label = _L("Tool change G-code");
+    def->tooltip = _L("This custom code is inserted right before every extruder change. "
                    "Note that you can use placeholder variables for all Slic3r settings as well "
-                   "as [previous_extruder] and [next_extruder].";
+                   "as [previous_extruder] and [next_extruder].");
     def->cli = "toolchange-gcode=s";
     def->multiline = true;
     def->full_width = true;
@@ -1601,121 +1613,121 @@ PrintConfigDef::PrintConfigDef()
     def->default_value = new ConfigOptionString("");
 
     def = this->add("top_infill_extrusion_width", coFloatOrPercent);
-    def->label = "Top solid infill";
-    def->category = "Extrusion Width";
-    def->tooltip = "Set this to a non-zero value to set a manual extrusion width for infill for top surfaces. "
+    def->label = _L("Top solid infill");
+    def->category = _L("Extrusion Width");
+    def->tooltip = _L("Set this to a non-zero value to set a manual extrusion width for infill for top surfaces. "
                    "You may want to use thinner extrudates to fill all narrow regions and get a smoother finish. "
                    "If left zero, default extrusion width will be used if set, otherwise nozzle diameter will be used. "
-                   "If expressed as percentage (for example 90%) it will be computed over layer height.";
-    def->sidetext = "mm or % (leave 0 for default)";
+                   "If expressed as percentage (for example 90%) it will be computed over layer height.");
+    def->sidetext = _L("mm or % (leave 0 for default)");
     def->cli = "top-infill-extrusion-width=s";
     def->default_value = new ConfigOptionFloatOrPercent(0, false);
 
     def = this->add("top_solid_infill_speed", coFloatOrPercent);
-    def->label = "Top solid infill";
-    def->category = "Speed";
-    def->tooltip = "Speed for printing top solid layers (it only applies to the uppermost "
+    def->label = _L("Top solid infill");
+    def->category = _L("Speed");
+    def->tooltip = _L("Speed for printing top solid layers (it only applies to the uppermost "
                    "external layers and not to their internal solid layers). You may want "
                    "to slow down this to get a nicer surface finish. This can be expressed "
                    "as a percentage (for example: 80%) over the solid infill speed above. "
-                   "Set to zero for auto.";
-    def->sidetext = "mm/s or %";
+                   "Set to zero for auto.");
+    def->sidetext = _L("mm/s or %");
     def->cli = "top-solid-infill-speed=s";
     def->ratio_over = "solid_infill_speed";
     def->min = 0;
     def->default_value = new ConfigOptionFloatOrPercent(15, false);
 
     def = this->add("top_solid_layers", coInt);
-    def->label = "Top";
-    def->category = "Layers and Perimeters";
-    def->tooltip = "Number of solid layers to generate on top surfaces.";
+    def->label = _L("Top");
+    def->category = _L("Layers and Perimeters");
+    def->tooltip = _L("Number of solid layers to generate on top surfaces.");
     def->cli = "top-solid-layers=i";
-    def->full_label = "Top solid layers";
+    def->full_label = _L("Top solid layers");
     def->min = 0;
     def->default_value = new ConfigOptionInt(3);
 
     def = this->add("travel_speed", coFloat);
-    def->label = "Travel";
-    def->tooltip = "Speed for travel moves (jumps between distant extrusion points).";
-    def->sidetext = "mm/s";
+    def->label = _L("Travel");
+    def->tooltip = _L("Speed for travel moves (jumps between distant extrusion points).");
+    def->sidetext = _L("mm/s");
     def->cli = "travel-speed=f";
     def->aliases.push_back("travel_feed_rate");
     def->min = 1;
     def->default_value = new ConfigOptionFloat(130);
 
     def = this->add("use_firmware_retraction", coBool);
-    def->label = "Use firmware retraction";
-    def->tooltip = "This experimental setting uses G10 and G11 commands to have the firmware "
-                   "handle the retraction. This is only supported in recent Marlin.";
+    def->label = _L("Use firmware retraction");
+    def->tooltip = _L("This experimental setting uses G10 and G11 commands to have the firmware "
+                   "handle the retraction. This is only supported in recent Marlin.");
     def->cli = "use-firmware-retraction!";
     def->default_value = new ConfigOptionBool(false);
 
     def = this->add("use_relative_e_distances", coBool);
-    def->label = "Use relative E distances";
-    def->tooltip = "If your firmware requires relative E values, check this, "
-                   "otherwise leave it unchecked. Most firmwares use absolute values.";
+    def->label = _L("Use relative E distances");
+    def->tooltip = _L("If your firmware requires relative E values, check this, "
+                   "otherwise leave it unchecked. Most firmwares use absolute values.");
     def->cli = "use-relative-e-distances!";
     def->default_value = new ConfigOptionBool(false);
 
     def = this->add("use_volumetric_e", coBool);
-    def->label = "Use volumetric E";
-    def->tooltip = "This experimental setting uses outputs the E values in cubic millimeters "
+    def->label = _L("Use volumetric E");
+    def->tooltip = _L("This experimental setting uses outputs the E values in cubic millimeters "
                    "instead of linear millimeters. If your firmware doesn't already know "
                    "filament diameter(s), you can put commands like 'M200 D[filament_diameter_0] T0' "
                    "in your start G-code in order to turn volumetric mode on and use the filament "
                    "diameter associated to the filament selected in Slic3r. This is only supported "
-                   "in recent Marlin.";
+                   "in recent Marlin.");
     def->cli = "use-volumetric-e!";
     def->default_value = new ConfigOptionBool(false);
 
     def = this->add("variable_layer_height", coBool);
-    def->label = "Enable variable layer height feature";
-    def->tooltip = "Some printers or printer setups may have difficulties printing "
-                   "with a variable layer height. Enabled by default.";
+    def->label = _L("Enable variable layer height feature");
+    def->tooltip = _L("Some printers or printer setups may have difficulties printing "
+                   "with a variable layer height. Enabled by default.");
     def->cli = "variable-layer-height!";
     def->default_value = new ConfigOptionBool(true);
 
     def = this->add("wipe", coBools);
-    def->label = "Wipe while retracting";
-    def->tooltip = "This flag will move the nozzle while retracting to minimize the possible blob "
-                   "on leaky extruders.";
+    def->label = _L("Wipe while retracting");
+    def->tooltip = _L("This flag will move the nozzle while retracting to minimize the possible blob "
+                   "on leaky extruders.");
     def->cli = "wipe!";
     def->default_value = new ConfigOptionBools { false };
 
     def = this->add("wipe_tower", coBool);
-    def->label = "Enable";
-    def->tooltip = "Multi material printers may need to prime or purge extruders on tool changes. "
-                   "Extrude the excess material into the wipe tower.";
+    def->label = _L("Enable");
+    def->tooltip = _L("Multi material printers may need to prime or purge extruders on tool changes. "
+                   "Extrude the excess material into the wipe tower.");
     def->cli = "wipe-tower!";
     def->default_value = new ConfigOptionBool(false);
 
     def = this->add("wipe_tower_x", coFloat);
-    def->label = "Position X";
-    def->tooltip = "X coordinate of the left front corner of a wipe tower";
-    def->sidetext = "mm";
+    def->label = _L("Position X");
+    def->tooltip = _L("X coordinate of the left front corner of a wipe tower");
+    def->sidetext = _L("mm");
     def->cli = "wipe-tower-x=f";
     def->default_value = new ConfigOptionFloat(180.);
 
     def = this->add("wipe_tower_y", coFloat);
-    def->label = "Position Y";
-    def->tooltip = "Y coordinate of the left front corner of a wipe tower";
-    def->sidetext = "mm";
+    def->label = _L("Position Y");
+    def->tooltip = _L("Y coordinate of the left front corner of a wipe tower");
+    def->sidetext = _L("mm");
     def->cli = "wipe-tower-y=f";
     def->default_value = new ConfigOptionFloat(140.);
 
     def = this->add("wipe_tower_width", coFloat);
-    def->label = "Width";
-    def->tooltip = "Width of a wipe tower";
-    def->sidetext = "mm";
+    def->label = _L("Width");
+    def->tooltip = _L("Width of a wipe tower");
+    def->sidetext = _L("mm");
     def->cli = "wipe-tower-width=f";
     def->default_value = new ConfigOptionFloat(60.);
 
     def = this->add("wipe_tower_per_color_wipe", coFloat);
-    def->label = "Per color change depth";
-    def->tooltip = "Depth of a wipe color per color change. For N colors, there will be "
+    def->label = _L("Per color change depth");
+    def->tooltip = _L("Depth of a wipe color per color change. For N colors, there will be "
                    "maximum (N-1) tool switches performed, therefore the total depth "
-                   "of the wipe tower will be (N-1) times this value.";
-    def->sidetext = "mm";
+                   "of the wipe tower will be (N-1) times this value.");
+    def->sidetext = _L("mm");
     def->cli = "wipe-tower-per-color-wipe=f";
     def->default_value = new ConfigOptionFloat(15.);
 
@@ -1727,22 +1739,22 @@ PrintConfigDef::PrintConfigDef()
     def->default_value = new ConfigOptionFloat(0.);
 
     def = this->add("xy_size_compensation", coFloat);
-    def->label = "XY Size Compensation";
-    def->category = "Advanced";
-    def->tooltip = "The object will be grown/shrunk in the XY plane by the configured value "
+    def->label = _L("XY Size Compensation");
+    def->category = _L("Advanced");
+    def->tooltip = _L("The object will be grown/shrunk in the XY plane by the configured value "
                    "(negative = inwards, positive = outwards). This might be useful "
-                   "for fine-tuning hole sizes.";
-    def->sidetext = "mm";
+                   "for fine-tuning hole sizes.");
+    def->sidetext = _L("mm");
     def->cli = "xy-size-compensation=f";
     def->default_value = new ConfigOptionFloat(0);
 
     def = this->add("z_offset", coFloat);
-    def->label = "Z offset";
-    def->tooltip = "This value will be added (or subtracted) from all the Z coordinates "
+    def->label = _L("Z offset");
+    def->tooltip = _L("This value will be added (or subtracted) from all the Z coordinates "
                    "in the output G-code. It is used to compensate for bad Z endstop position: "
                    "for example, if your endstop zero actually leaves the nozzle 0.3mm far "
-                   "from the print bed, set this to -0.3 (or fix your endstop).";
-    def->sidetext = "mm";
+                   "from the print bed, set this to -0.3 (or fix your endstop).");
+    def->sidetext = _L("mm");
     def->cli = "z-offset=f";
     def->default_value = new ConfigOptionFloat(0);
 }
@@ -1926,6 +1938,7 @@ std::string FullPrintConfig::validate()
     if (this->use_firmware_retraction.value && 
         this->gcode_flavor.value != gcfSmoothie &&
         this->gcode_flavor.value != gcfRepRap &&
+        this->gcode_flavor.value != gcfMarlin &&
         this->gcode_flavor.value != gcfMachinekit &&
         this->gcode_flavor.value != gcfRepetier)
         return "--use-firmware-retraction is only supported by Marlin, Smoothie, Repetier and Machinekit firmware";
diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp
index ea4e07dd9..7c2d40458 100644
--- a/xs/src/libslic3r/PrintConfig.hpp
+++ b/xs/src/libslic3r/PrintConfig.hpp
@@ -23,7 +23,8 @@
 namespace Slic3r {
 
 enum GCodeFlavor {
-    gcfRepRap, gcfTeacup, gcfMakerWare, gcfSailfish, gcfMach3, gcfMachinekit, gcfNoExtrusion, gcfSmoothie, gcfRepetier,
+    gcfRepRap, gcfRepetier, gcfTeacup, gcfMakerWare, gcfMarlin, gcfSailfish, gcfMach3, gcfMachinekit, 
+    gcfSmoothie, gcfNoExtrusion,
 };
 
 enum InfillPattern {
@@ -50,6 +51,7 @@ template<> inline t_config_enum_values& ConfigOptionEnum<GCodeFlavor>::get_enum_
         keys_map["repetier"]        = gcfRepetier;
         keys_map["teacup"]          = gcfTeacup;
         keys_map["makerware"]       = gcfMakerWare;
+        keys_map["marlin"]          = gcfMarlin;
         keys_map["sailfish"]        = gcfSailfish;
         keys_map["smoothie"]        = gcfSmoothie;
         keys_map["mach3"]           = gcfMach3;
diff --git a/xs/src/libslic3r/TriangleMesh.cpp b/xs/src/libslic3r/TriangleMesh.cpp
index 0dbbf5f8d..c2c64e427 100644
--- a/xs/src/libslic3r/TriangleMesh.cpp
+++ b/xs/src/libslic3r/TriangleMesh.cpp
@@ -197,10 +197,11 @@ TriangleMesh::repair() {
         stl_fill_holes(&stl);
         stl_clear_error(&stl);
     }
-    
-    // normal_directions
-    stl_fix_normal_directions(&stl);
-    
+
+    // commenting out the following call fixes: #574, #413, #269, #262, #259, #230, #228, #206
+//    // normal_directions
+//    stl_fix_normal_directions(&stl);
+
     // normal_values
     stl_fix_normal_values(&stl);
     
@@ -374,6 +375,15 @@ void TriangleMesh::mirror_z()
     this->mirror(Z);
 }
 
+void TriangleMesh::transform(const float* matrix3x4)
+{
+    if (matrix3x4 == nullptr)
+        return;
+
+    stl_transform(&stl, const_cast<float*>(matrix3x4));
+    stl_invalidate_shared_vertices(&stl);
+}
+
 void TriangleMesh::align_to_origin()
 {
     this->translate(
diff --git a/xs/src/libslic3r/TriangleMesh.hpp b/xs/src/libslic3r/TriangleMesh.hpp
index b28f3a310..3192c90b6 100644
--- a/xs/src/libslic3r/TriangleMesh.hpp
+++ b/xs/src/libslic3r/TriangleMesh.hpp
@@ -47,6 +47,7 @@ public:
     void mirror_x();
     void mirror_y();
     void mirror_z();
+    void transform(const float* matrix3x4);
     void align_to_origin();
     void rotate(double angle, Point* center);
     TriangleMeshPtrs split() const;
diff --git a/xs/src/libslic3r/Utils.hpp b/xs/src/libslic3r/Utils.hpp
index 3afbc912f..27e7fad6b 100644
--- a/xs/src/libslic3r/Utils.hpp
+++ b/xs/src/libslic3r/Utils.hpp
@@ -20,21 +20,49 @@ void set_resources_dir(const std::string &path);
 // Return a full path to the resources directory.
 const std::string& resources_dir();
 
+// Set a path with GUI localization files.
+void set_local_dir(const std::string &path);
+// Return a full path to the localization directory.
+const std::string& localization_dir();
+
 // Set a path with preset files.
 void set_data_dir(const std::string &path);
 // Return a full path to the GUI resource files.
 const std::string& data_dir();
 
-extern std::string encode_path(const char *src);
+// A special type for strings encoded in the local Windows 8-bit code page.
+// This type is only needed for Perl bindings to relay to Perl that the string is raw, not UTF-8 encoded.
+typedef std::string local_encoded_string;
+
+// Convert an UTF-8 encoded string into local coding.
+// On Windows, the UTF-8 string is converted to a local 8-bit code page.
+// On OSX and Linux, this function does no conversion and returns a copy of the source string.
+extern local_encoded_string encode_path(const char *src);
 extern std::string decode_path(const char *src);
 extern std::string normalize_utf8_nfc(const char *src);
 
+// File path / name / extension splitting utilities, working with UTF-8,
+// to be published to Perl.
+namespace PerlUtils {
+    // Get a file name including the extension.
+    extern std::string path_to_filename(const char *src);
+    // Get a file name without the extension.
+    extern std::string path_to_stem(const char *src);
+    // Get just the extension.
+    extern std::string path_to_extension(const char *src);
+    // Get a directory without the trailing slash.
+    extern std::string path_to_parent_path(const char *src);
+};
+
 // Timestamp formatted for header_slic3r_generated().
 extern std::string timestamp_str();
 // Standard "generated by Slic3r version xxx timestamp xxx" header string, 
 // to be placed at the top of Slic3r generated files.
 inline std::string header_slic3r_generated() { return std::string("generated by " SLIC3R_FORK_NAME " " SLIC3R_VERSION " " ) + timestamp_str(); }
 
+// Encode a file into a multi-part HTTP response with a given boundary.
+std::string octoprint_encode_file_send_request_content(const char *path, bool select, bool print, const char *boundary);
+
 // Compute the next highest power of 2 of 32-bit v
 // http://graphics.stanford.edu/~seander/bithacks.html
 template<typename T>
diff --git a/xs/src/libslic3r/libslic3r.h b/xs/src/libslic3r/libslic3r.h
index f71311e7f..0f192c37c 100644
--- a/xs/src/libslic3r/libslic3r.h
+++ b/xs/src/libslic3r/libslic3r.h
@@ -14,11 +14,11 @@
 #include <boost/thread.hpp>
 
 #define SLIC3R_FORK_NAME "Slic3r Prusa Edition"
-#define SLIC3R_VERSION "1.38.4"
+#define SLIC3R_VERSION "1.39.0"
 #define SLIC3R_BUILD "UNKNOWN"
 
-typedef long coord_t;
-typedef double coordf_t;
+typedef int32_t coord_t;
+typedef double  coordf_t;
 
 //FIXME This epsilon value is used for many non-related purposes:
 // For a threshold of a squared Euclidean distance,
@@ -102,7 +102,7 @@ inline std::string debug_out_path(const char *name, ...)
 
 namespace Slic3r {
 
-enum Axis { X=0, Y, Z };
+enum Axis { X=0, Y, Z, E, F, NUM_AXES };
 
 template <class T>
 inline void append_to(std::vector<T> &dst, const std::vector<T> &src)
@@ -163,11 +163,11 @@ static inline T clamp(const T low, const T high, const T value)
     return std::max(low, std::min(high, value));
 }
 
-template <typename T>
-static inline T lerp(const T a, const T b, const T t)
+template <typename T, typename Number>
+static inline T lerp(const T& a, const T& b, Number t)
 {
-    assert(t >= T(-EPSILON) && t <= T(1.+EPSILON));
-    return (1. - t) * a + t * b;
+    assert((t >= Number(-EPSILON)) && (t <= Number(1) + Number(EPSILON)));
+    return (Number(1) - t) * a + t * b;
 }
 
 } // namespace Slic3r
diff --git a/xs/src/libslic3r/utils.cpp b/xs/src/libslic3r/utils.cpp
index ef05dcae7..34b9eaa9f 100644
--- a/xs/src/libslic3r/utils.cpp
+++ b/xs/src/libslic3r/utils.cpp
@@ -10,6 +10,8 @@
 #include <boost/algorithm/string/predicate.hpp>
 #include <boost/date_time/local_time/local_time.hpp>
 #include <boost/filesystem.hpp>
+#include <boost/filesystem/path.hpp>
+#include <boost/nowide/fstream.hpp>
 #include <boost/nowide/integration/filesystem.hpp>
 #include <boost/nowide/convert.hpp>
 
@@ -101,6 +103,18 @@ const std::string& resources_dir()
     return g_resources_dir;
 }
 
+static std::string g_local_dir;
+
+void set_local_dir(const std::string &dir)
+{
+    g_local_dir = dir;
+}
+
+const std::string& localization_dir()
+{
+	return g_local_dir;
+}
+
 static std::string g_data_dir;
 
 void set_data_dir(const std::string &dir)
@@ -235,6 +249,17 @@ std::string normalize_utf8_nfc(const char *src)
     return boost::locale::normalize(src, boost::locale::norm_nfc, locale_utf8);
 }
 
+namespace PerlUtils {
+    // Get a file name including the extension.
+    std::string path_to_filename(const char *src)       { return boost::filesystem::path(src).filename().string(); }
+    // Get a file name without the extension.
+    std::string path_to_stem(const char *src)           { return boost::filesystem::path(src).stem().string(); }
+    // Get just the extension.
+    std::string path_to_extension(const char *src)      { return boost::filesystem::path(src).extension().string(); }
+    // Get a directory without the trailing slash.
+    std::string path_to_parent_path(const char *src)    { return boost::filesystem::path(src).parent_path().string(); }
+};
+
 std::string timestamp_str()
 {
     const auto now = boost::posix_time::second_clock::local_time();
@@ -247,4 +272,31 @@ std::string timestamp_str()
     return buf;
 }
 
+std::string octoprint_encode_file_send_request_content(const char *cpath, bool select, bool print, const char *boundary)
+{
+    // Read the complete G-code string into a string buffer.
+    // It will throw if the file cannot be open or read.
+    std::stringstream str_stream;
+    {
+        boost::nowide::ifstream ifs(cpath);
+        str_stream << ifs.rdbuf();
+    }
+
+    boost::filesystem::path path(cpath);
+    std::string request = boundary + '\n';
+    request += "Content-Disposition: form-data; name=\"";
+    request += path.stem().string() + "\"; filename=\"" + path.filename().string() + "\"\n";
+    request += "Content-Type: application/octet-stream\n\n";
+    request += str_stream.str();
+    request += boundary + '\n';
+    request += "Content-Disposition: form-data; name=\"select\"\n\n";
+    request += select ? "true\n" : "false\n";
+    request += boundary + '\n';
+    request += "Content-Disposition: form-data; name=\"print\"\n\n";
+    request += print ? "true\n" : "false\n";
+    request += boundary + '\n';
+
+    return request;
+}
+
 }; // namespace Slic3r
diff --git a/xs/src/miniz/miniz.cpp b/xs/src/miniz/miniz.cpp
new file mode 100644
index 000000000..318a86da9
--- /dev/null
+++ b/xs/src/miniz/miniz.cpp
@@ -0,0 +1,594 @@
+/**************************************************************************
+ *
+ * Copyright 2013-2014 RAD Game Tools and Valve Software
+ * Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "miniz.h"
+
+typedef unsigned char mz_validate_uint16[sizeof(mz_uint16) == 2 ? 1 : -1];
+typedef unsigned char mz_validate_uint32[sizeof(mz_uint32) == 4 ? 1 : -1];
+typedef unsigned char mz_validate_uint64[sizeof(mz_uint64) == 8 ? 1 : -1];
+
+/* ------------------- zlib-style API's */
+
+mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len)
+{
+    mz_uint32 i, s1 = (mz_uint32)(adler & 0xffff), s2 = (mz_uint32)(adler >> 16);
+    size_t block_len = buf_len % 5552;
+    if (!ptr)
+        return MZ_ADLER32_INIT;
+    while (buf_len)
+    {
+        for (i = 0; i + 7 < block_len; i += 8, ptr += 8)
+        {
+            s1 += ptr[0], s2 += s1;
+            s1 += ptr[1], s2 += s1;
+            s1 += ptr[2], s2 += s1;
+            s1 += ptr[3], s2 += s1;
+            s1 += ptr[4], s2 += s1;
+            s1 += ptr[5], s2 += s1;
+            s1 += ptr[6], s2 += s1;
+            s1 += ptr[7], s2 += s1;
+        }
+        for (; i < block_len; ++i)
+            s1 += *ptr++, s2 += s1;
+        s1 %= 65521U, s2 %= 65521U;
+        buf_len -= block_len;
+        block_len = 5552;
+    }
+    return (s2 << 16) + s1;
+}
+
+/* Karl Malbrain's compact CRC-32. See "A compact CCITT crc16 and crc32 C implementation that balances processor cache usage against speed": http://www.geocities.com/malbrain/ */
+#if 0
+    mz_ulong mz_crc32(mz_ulong crc, const mz_uint8 *ptr, size_t buf_len)
+    {
+        static const mz_uint32 s_crc32[16] = { 0, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c,
+                                               0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c, 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c };
+        mz_uint32 crcu32 = (mz_uint32)crc;
+        if (!ptr)
+            return MZ_CRC32_INIT;
+        crcu32 = ~crcu32;
+        while (buf_len--)
+        {
+            mz_uint8 b = *ptr++;
+            crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b & 0xF)];
+            crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b >> 4)];
+        }
+        return ~crcu32;
+    }
+#else
+/* Faster, but larger CPU cache footprint.
+ */
+mz_ulong mz_crc32(mz_ulong crc, const mz_uint8 *ptr, size_t buf_len)
+{
+    static const mz_uint32 s_crc_table[256] =
+        {
+          0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535,
+          0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD,
+          0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D,
+          0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
+          0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4,
+          0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C,
+          0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC,
+          0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
+          0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB,
+          0xB6662D3D, 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F,
+          0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB,
+          0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
+          0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA,
+          0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE,
+          0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A,
+          0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
+          0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409,
+          0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81,
+          0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739,
+          0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
+          0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268,
+          0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0,
+          0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8,
+          0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
+          0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF,
+          0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703,
+          0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7,
+          0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
+          0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE,
+          0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242,
+          0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6,
+          0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
+          0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D,
+          0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5,
+          0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605,
+          0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
+          0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
+        };
+
+    mz_uint32 crc32 = (mz_uint32)crc ^ 0xFFFFFFFF;
+    const mz_uint8 *pByte_buf = (const mz_uint8 *)ptr;
+
+    while (buf_len >= 4)
+    {
+        crc32 = (crc32 >> 8) ^ s_crc_table[(crc32 ^ pByte_buf[0]) & 0xFF];
+        crc32 = (crc32 >> 8) ^ s_crc_table[(crc32 ^ pByte_buf[1]) & 0xFF];
+        crc32 = (crc32 >> 8) ^ s_crc_table[(crc32 ^ pByte_buf[2]) & 0xFF];
+        crc32 = (crc32 >> 8) ^ s_crc_table[(crc32 ^ pByte_buf[3]) & 0xFF];
+        pByte_buf += 4;
+        buf_len -= 4;
+    }
+
+    while (buf_len)
+    {
+        crc32 = (crc32 >> 8) ^ s_crc_table[(crc32 ^ pByte_buf[0]) & 0xFF];
+        ++pByte_buf;
+        --buf_len;
+    }
+
+    return ~crc32;
+}
+#endif
+
+void mz_free(void *p)
+{
+    MZ_FREE(p);
+}
+
+void *miniz_def_alloc_func(void *opaque, size_t items, size_t size)
+{
+    (void)opaque, (void)items, (void)size;
+    return MZ_MALLOC(items * size);
+}
+void miniz_def_free_func(void *opaque, void *address)
+{
+    (void)opaque, (void)address;
+    MZ_FREE(address);
+}
+void *miniz_def_realloc_func(void *opaque, void *address, size_t items, size_t size)
+{
+    (void)opaque, (void)address, (void)items, (void)size;
+    return MZ_REALLOC(address, items * size);
+}
+
+const char *mz_version(void)
+{
+    return MZ_VERSION;
+}
+
+#ifndef MINIZ_NO_ZLIB_APIS
+
+int mz_deflateInit(mz_streamp pStream, int level)
+{
+    return mz_deflateInit2(pStream, level, MZ_DEFLATED, MZ_DEFAULT_WINDOW_BITS, 9, MZ_DEFAULT_STRATEGY);
+}
+
+int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy)
+{
+    tdefl_compressor *pComp;
+    mz_uint comp_flags = TDEFL_COMPUTE_ADLER32 | tdefl_create_comp_flags_from_zip_params(level, window_bits, strategy);
+
+    if (!pStream)
+        return MZ_STREAM_ERROR;
+    if ((method != MZ_DEFLATED) || ((mem_level < 1) || (mem_level > 9)) || ((window_bits != MZ_DEFAULT_WINDOW_BITS) && (-window_bits != MZ_DEFAULT_WINDOW_BITS)))
+        return MZ_PARAM_ERROR;
+
+    pStream->data_type = 0;
+    pStream->adler = MZ_ADLER32_INIT;
+    pStream->msg = NULL;
+    pStream->reserved = 0;
+    pStream->total_in = 0;
+    pStream->total_out = 0;
+    if (!pStream->zalloc)
+        pStream->zalloc = miniz_def_alloc_func;
+    if (!pStream->zfree)
+        pStream->zfree = miniz_def_free_func;
+
+    pComp = (tdefl_compressor *)pStream->zalloc(pStream->opaque, 1, sizeof(tdefl_compressor));
+    if (!pComp)
+        return MZ_MEM_ERROR;
+
+    pStream->state = (struct mz_internal_state *)pComp;
+
+    if (tdefl_init(pComp, NULL, NULL, comp_flags) != TDEFL_STATUS_OKAY)
+    {
+        mz_deflateEnd(pStream);
+        return MZ_PARAM_ERROR;
+    }
+
+    return MZ_OK;
+}
+
+int mz_deflateReset(mz_streamp pStream)
+{
+    if ((!pStream) || (!pStream->state) || (!pStream->zalloc) || (!pStream->zfree))
+        return MZ_STREAM_ERROR;
+    pStream->total_in = pStream->total_out = 0;
+    tdefl_init((tdefl_compressor *)pStream->state, NULL, NULL, ((tdefl_compressor *)pStream->state)->m_flags);
+    return MZ_OK;
+}
+
+int mz_deflate(mz_streamp pStream, int flush)
+{
+    size_t in_bytes, out_bytes;
+    mz_ulong orig_total_in, orig_total_out;
+    int mz_status = MZ_OK;
+
+    if ((!pStream) || (!pStream->state) || (flush < 0) || (flush > MZ_FINISH) || (!pStream->next_out))
+        return MZ_STREAM_ERROR;
+    if (!pStream->avail_out)
+        return MZ_BUF_ERROR;
+
+    if (flush == MZ_PARTIAL_FLUSH)
+        flush = MZ_SYNC_FLUSH;
+
+    if (((tdefl_compressor *)pStream->state)->m_prev_return_status == TDEFL_STATUS_DONE)
+        return (flush == MZ_FINISH) ? MZ_STREAM_END : MZ_BUF_ERROR;
+
+    orig_total_in = pStream->total_in;
+    orig_total_out = pStream->total_out;
+    for (;;)
+    {
+        tdefl_status defl_status;
+        in_bytes = pStream->avail_in;
+        out_bytes = pStream->avail_out;
+
+        defl_status = tdefl_compress((tdefl_compressor *)pStream->state, pStream->next_in, &in_bytes, pStream->next_out, &out_bytes, (tdefl_flush)flush);
+        pStream->next_in += (mz_uint)in_bytes;
+        pStream->avail_in -= (mz_uint)in_bytes;
+        pStream->total_in += (mz_uint)in_bytes;
+        pStream->adler = tdefl_get_adler32((tdefl_compressor *)pStream->state);
+
+        pStream->next_out += (mz_uint)out_bytes;
+        pStream->avail_out -= (mz_uint)out_bytes;
+        pStream->total_out += (mz_uint)out_bytes;
+
+        if (defl_status < 0)
+        {
+            mz_status = MZ_STREAM_ERROR;
+            break;
+        }
+        else if (defl_status == TDEFL_STATUS_DONE)
+        {
+            mz_status = MZ_STREAM_END;
+            break;
+        }
+        else if (!pStream->avail_out)
+            break;
+        else if ((!pStream->avail_in) && (flush != MZ_FINISH))
+        {
+            if ((flush) || (pStream->total_in != orig_total_in) || (pStream->total_out != orig_total_out))
+                break;
+            return MZ_BUF_ERROR; /* Can't make forward progress without some input.
+ */
+        }
+    }
+    return mz_status;
+}
+
+int mz_deflateEnd(mz_streamp pStream)
+{
+    if (!pStream)
+        return MZ_STREAM_ERROR;
+    if (pStream->state)
+    {
+        pStream->zfree(pStream->opaque, pStream->state);
+        pStream->state = NULL;
+    }
+    return MZ_OK;
+}
+
+mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len)
+{
+    (void)pStream;
+    /* This is really over conservative. (And lame, but it's actually pretty tricky to compute a true upper bound given the way tdefl's blocking works.) */
+    return MZ_MAX(128 + (source_len * 110) / 100, 128 + source_len + ((source_len / (31 * 1024)) + 1) * 5);
+}
+
+int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level)
+{
+    int status;
+    mz_stream stream;
+    memset(&stream, 0, sizeof(stream));
+
+    /* In case mz_ulong is 64-bits (argh I hate longs). */
+    if ((source_len | *pDest_len) > 0xFFFFFFFFU)
+        return MZ_PARAM_ERROR;
+
+    stream.next_in = pSource;
+    stream.avail_in = (mz_uint32)source_len;
+    stream.next_out = pDest;
+    stream.avail_out = (mz_uint32)*pDest_len;
+
+    status = mz_deflateInit(&stream, level);
+    if (status != MZ_OK)
+        return status;
+
+    status = mz_deflate(&stream, MZ_FINISH);
+    if (status != MZ_STREAM_END)
+    {
+        mz_deflateEnd(&stream);
+        return (status == MZ_OK) ? MZ_BUF_ERROR : status;
+    }
+
+    *pDest_len = stream.total_out;
+    return mz_deflateEnd(&stream);
+}
+
+int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len)
+{
+    return mz_compress2(pDest, pDest_len, pSource, source_len, MZ_DEFAULT_COMPRESSION);
+}
+
+mz_ulong mz_compressBound(mz_ulong source_len)
+{
+    return mz_deflateBound(NULL, source_len);
+}
+
+typedef struct
+{
+    tinfl_decompressor m_decomp;
+    mz_uint m_dict_ofs, m_dict_avail, m_first_call, m_has_flushed;
+    int m_window_bits;
+    mz_uint8 m_dict[TINFL_LZ_DICT_SIZE];
+    tinfl_status m_last_status;
+} inflate_state;
+
+int mz_inflateInit2(mz_streamp pStream, int window_bits)
+{
+    inflate_state *pDecomp;
+    if (!pStream)
+        return MZ_STREAM_ERROR;
+    if ((window_bits != MZ_DEFAULT_WINDOW_BITS) && (-window_bits != MZ_DEFAULT_WINDOW_BITS))
+        return MZ_PARAM_ERROR;
+
+    pStream->data_type = 0;
+    pStream->adler = 0;
+    pStream->msg = NULL;
+    pStream->total_in = 0;
+    pStream->total_out = 0;
+    pStream->reserved = 0;
+    if (!pStream->zalloc)
+        pStream->zalloc = miniz_def_alloc_func;
+    if (!pStream->zfree)
+        pStream->zfree = miniz_def_free_func;
+
+    pDecomp = (inflate_state *)pStream->zalloc(pStream->opaque, 1, sizeof(inflate_state));
+    if (!pDecomp)
+        return MZ_MEM_ERROR;
+
+    pStream->state = (struct mz_internal_state *)pDecomp;
+
+    tinfl_init(&pDecomp->m_decomp);
+    pDecomp->m_dict_ofs = 0;
+    pDecomp->m_dict_avail = 0;
+    pDecomp->m_last_status = TINFL_STATUS_NEEDS_MORE_INPUT;
+    pDecomp->m_first_call = 1;
+    pDecomp->m_has_flushed = 0;
+    pDecomp->m_window_bits = window_bits;
+
+    return MZ_OK;
+}
+
+int mz_inflateInit(mz_streamp pStream)
+{
+    return mz_inflateInit2(pStream, MZ_DEFAULT_WINDOW_BITS);
+}
+
+int mz_inflate(mz_streamp pStream, int flush)
+{
+    inflate_state *pState;
+    mz_uint n, first_call, decomp_flags = TINFL_FLAG_COMPUTE_ADLER32;
+    size_t in_bytes, out_bytes, orig_avail_in;
+    tinfl_status status;
+
+    if ((!pStream) || (!pStream->state))
+        return MZ_STREAM_ERROR;
+    if (flush == MZ_PARTIAL_FLUSH)
+        flush = MZ_SYNC_FLUSH;
+    if ((flush) && (flush != MZ_SYNC_FLUSH) && (flush != MZ_FINISH))
+        return MZ_STREAM_ERROR;
+
+    pState = (inflate_state *)pStream->state;
+    if (pState->m_window_bits > 0)
+        decomp_flags |= TINFL_FLAG_PARSE_ZLIB_HEADER;
+    orig_avail_in = pStream->avail_in;
+
+    first_call = pState->m_first_call;
+    pState->m_first_call = 0;
+    if (pState->m_last_status < 0)
+        return MZ_DATA_ERROR;
+
+    if (pState->m_has_flushed && (flush != MZ_FINISH))
+        return MZ_STREAM_ERROR;
+    pState->m_has_flushed |= (flush == MZ_FINISH);
+
+    if ((flush == MZ_FINISH) && (first_call))
+    {
+        /* MZ_FINISH on the first call implies that the input and output buffers are large enough to hold the entire compressed/decompressed file. */
+        decomp_flags |= TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF;
+        in_bytes = pStream->avail_in;
+        out_bytes = pStream->avail_out;
+        status = tinfl_decompress(&pState->m_decomp, pStream->next_in, &in_bytes, pStream->next_out, pStream->next_out, &out_bytes, decomp_flags);
+        pState->m_last_status = status;
+        pStream->next_in += (mz_uint)in_bytes;
+        pStream->avail_in -= (mz_uint)in_bytes;
+        pStream->total_in += (mz_uint)in_bytes;
+        pStream->adler = tinfl_get_adler32(&pState->m_decomp);
+        pStream->next_out += (mz_uint)out_bytes;
+        pStream->avail_out -= (mz_uint)out_bytes;
+        pStream->total_out += (mz_uint)out_bytes;
+
+        if (status < 0)
+            return MZ_DATA_ERROR;
+        else if (status != TINFL_STATUS_DONE)
+        {
+            pState->m_last_status = TINFL_STATUS_FAILED;
+            return MZ_BUF_ERROR;
+        }
+        return MZ_STREAM_END;
+    }
+    /* flush != MZ_FINISH then we must assume there's more input. */
+    if (flush != MZ_FINISH)
+        decomp_flags |= TINFL_FLAG_HAS_MORE_INPUT;
+
+    if (pState->m_dict_avail)
+    {
+        n = MZ_MIN(pState->m_dict_avail, pStream->avail_out);
+        memcpy(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n);
+        pStream->next_out += n;
+        pStream->avail_out -= n;
+        pStream->total_out += n;
+        pState->m_dict_avail -= n;
+        pState->m_dict_ofs = (pState->m_dict_ofs + n) & (TINFL_LZ_DICT_SIZE - 1);
+        return ((pState->m_last_status == TINFL_STATUS_DONE) && (!pState->m_dict_avail)) ? MZ_STREAM_END : MZ_OK;
+    }
+
+    for (;;)
+    {
+        in_bytes = pStream->avail_in;
+        out_bytes = TINFL_LZ_DICT_SIZE - pState->m_dict_ofs;
+
+        status = tinfl_decompress(&pState->m_decomp, pStream->next_in, &in_bytes, pState->m_dict, pState->m_dict + pState->m_dict_ofs, &out_bytes, decomp_flags);
+        pState->m_last_status = status;
+
+        pStream->next_in += (mz_uint)in_bytes;
+        pStream->avail_in -= (mz_uint)in_bytes;
+        pStream->total_in += (mz_uint)in_bytes;
+        pStream->adler = tinfl_get_adler32(&pState->m_decomp);
+
+        pState->m_dict_avail = (mz_uint)out_bytes;
+
+        n = MZ_MIN(pState->m_dict_avail, pStream->avail_out);
+        memcpy(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n);
+        pStream->next_out += n;
+        pStream->avail_out -= n;
+        pStream->total_out += n;
+        pState->m_dict_avail -= n;
+        pState->m_dict_ofs = (pState->m_dict_ofs + n) & (TINFL_LZ_DICT_SIZE - 1);
+
+        if (status < 0)
+            return MZ_DATA_ERROR; /* Stream is corrupted (there could be some uncompressed data left in the output dictionary - oh well). */
+        else if ((status == TINFL_STATUS_NEEDS_MORE_INPUT) && (!orig_avail_in))
+            return MZ_BUF_ERROR; /* Signal caller that we can't make forward progress without supplying more input or by setting flush to MZ_FINISH. */
+        else if (flush == MZ_FINISH)
+        {
+            /* The output buffer MUST be large to hold the remaining uncompressed data when flush==MZ_FINISH. */
+            if (status == TINFL_STATUS_DONE)
+                return pState->m_dict_avail ? MZ_BUF_ERROR : MZ_STREAM_END;
+            /* status here must be TINFL_STATUS_HAS_MORE_OUTPUT, which means there's at least 1 more byte on the way. If there's no more room left in the output buffer then something is wrong. */
+            else if (!pStream->avail_out)
+                return MZ_BUF_ERROR;
+        }
+        else if ((status == TINFL_STATUS_DONE) || (!pStream->avail_in) || (!pStream->avail_out) || (pState->m_dict_avail))
+            break;
+    }
+
+    return ((status == TINFL_STATUS_DONE) && (!pState->m_dict_avail)) ? MZ_STREAM_END : MZ_OK;
+}
+
+int mz_inflateEnd(mz_streamp pStream)
+{
+    if (!pStream)
+        return MZ_STREAM_ERROR;
+    if (pStream->state)
+    {
+        pStream->zfree(pStream->opaque, pStream->state);
+        pStream->state = NULL;
+    }
+    return MZ_OK;
+}
+
+int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len)
+{
+    mz_stream stream;
+    int status;
+    memset(&stream, 0, sizeof(stream));
+
+    /* In case mz_ulong is 64-bits (argh I hate longs). */
+    if ((source_len | *pDest_len) > 0xFFFFFFFFU)
+        return MZ_PARAM_ERROR;
+
+    stream.next_in = pSource;
+    stream.avail_in = (mz_uint32)source_len;
+    stream.next_out = pDest;
+    stream.avail_out = (mz_uint32)*pDest_len;
+
+    status = mz_inflateInit(&stream);
+    if (status != MZ_OK)
+        return status;
+
+    status = mz_inflate(&stream, MZ_FINISH);
+    if (status != MZ_STREAM_END)
+    {
+        mz_inflateEnd(&stream);
+        return ((status == MZ_BUF_ERROR) && (!stream.avail_in)) ? MZ_DATA_ERROR : status;
+    }
+    *pDest_len = stream.total_out;
+
+    return mz_inflateEnd(&stream);
+}
+
+const char *mz_error(int err)
+{
+    static struct
+    {
+        int m_err;
+        const char *m_pDesc;
+    } s_error_descs[] =
+        {
+          { MZ_OK, "" }, { MZ_STREAM_END, "stream end" }, { MZ_NEED_DICT, "need dictionary" }, { MZ_ERRNO, "file error" }, { MZ_STREAM_ERROR, "stream error" }, { MZ_DATA_ERROR, "data error" }, { MZ_MEM_ERROR, "out of memory" }, { MZ_BUF_ERROR, "buf error" }, { MZ_VERSION_ERROR, "version error" }, { MZ_PARAM_ERROR, "parameter error" }
+        };
+    mz_uint i;
+    for (i = 0; i < sizeof(s_error_descs) / sizeof(s_error_descs[0]); ++i)
+        if (s_error_descs[i].m_err == err)
+            return s_error_descs[i].m_pDesc;
+    return NULL;
+}
+
+#endif /*MINIZ_NO_ZLIB_APIS */
+
+/*
+  This is free and unencumbered software released into the public domain.
+
+  Anyone is free to copy, modify, publish, use, compile, sell, or
+  distribute this software, either in source code form or as a compiled
+  binary, for any purpose, commercial or non-commercial, and by any
+  means.
+
+  In jurisdictions that recognize copyright laws, the author or authors
+  of this software dedicate any and all copyright interest in the
+  software to the public domain. We make this dedication for the benefit
+  of the public at large and to the detriment of our heirs and
+  successors. We intend this dedication to be an overt act of
+  relinquishment in perpetuity of all present and future rights to this
+  software under copyright law.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+  IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+  OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+  OTHER DEALINGS IN THE SOFTWARE.
+
+  For more information, please refer to <http://unlicense.org/>
+*/
diff --git a/xs/src/miniz/miniz.h b/xs/src/miniz/miniz.h
new file mode 100644
index 000000000..6e7d5fde0
--- /dev/null
+++ b/xs/src/miniz/miniz.h
@@ -0,0 +1,462 @@
+/* miniz.c 2.0.6 beta - public domain deflate/inflate, zlib-subset, ZIP reading/writing/appending, PNG writing
+   See "unlicense" statement at the end of this file.
+   Rich Geldreich <richgel99@gmail.com>, last updated Oct. 13, 2013
+   Implements RFC 1950: http://www.ietf.org/rfc/rfc1950.txt and RFC 1951: http://www.ietf.org/rfc/rfc1951.txt
+
+   Most API's defined in miniz.c are optional. For example, to disable the archive related functions just define
+   MINIZ_NO_ARCHIVE_APIS, or to get rid of all stdio usage define MINIZ_NO_STDIO (see the list below for more macros).
+
+   * Low-level Deflate/Inflate implementation notes:
+
+     Compression: Use the "tdefl" API's. The compressor supports raw, static, and dynamic blocks, lazy or
+     greedy parsing, match length filtering, RLE-only, and Huffman-only streams. It performs and compresses
+     approximately as well as zlib.
+
+     Decompression: Use the "tinfl" API's. The entire decompressor is implemented as a single function
+     coroutine: see tinfl_decompress(). It supports decompression into a 32KB (or larger power of 2) wrapping buffer, or into a memory
+     block large enough to hold the entire file.
+
+     The low-level tdefl/tinfl API's do not make any use of dynamic memory allocation.
+
+   * zlib-style API notes:
+
+     miniz.c implements a fairly large subset of zlib. There's enough functionality present for it to be a drop-in
+     zlib replacement in many apps:
+        The z_stream struct, optional memory allocation callbacks
+        deflateInit/deflateInit2/deflate/deflateReset/deflateEnd/deflateBound
+        inflateInit/inflateInit2/inflate/inflateEnd
+        compress, compress2, compressBound, uncompress
+        CRC-32, Adler-32 - Using modern, minimal code size, CPU cache friendly routines.
+        Supports raw deflate streams or standard zlib streams with adler-32 checking.
+
+     Limitations:
+      The callback API's are not implemented yet. No support for gzip headers or zlib static dictionaries.
+      I've tried to closely emulate zlib's various flavors of stream flushing and return status codes, but
+      there are no guarantees that miniz.c pulls this off perfectly.
+
+   * PNG writing: See the tdefl_write_image_to_png_file_in_memory() function, originally written by
+     Alex Evans. Supports 1-4 bytes/pixel images.
+
+   * ZIP archive API notes:
+
+     The ZIP archive API's where designed with simplicity and efficiency in mind, with just enough abstraction to
+     get the job done with minimal fuss. There are simple API's to retrieve file information, read files from
+     existing archives, create new archives, append new files to existing archives, or clone archive data from
+     one archive to another. It supports archives located in memory or the heap, on disk (using stdio.h),
+     or you can specify custom file read/write callbacks.
+
+     - Archive reading: Just call this function to read a single file from a disk archive:
+
+      void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name,
+        size_t *pSize, mz_uint zip_flags);
+
+     For more complex cases, use the "mz_zip_reader" functions. Upon opening an archive, the entire central
+     directory is located and read as-is into memory, and subsequent file access only occurs when reading individual files.
+
+     - Archives file scanning: The simple way is to use this function to scan a loaded archive for a specific file:
+
+     int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags);
+
+     The locate operation can optionally check file comments too, which (as one example) can be used to identify
+     multiple versions of the same file in an archive. This function uses a simple linear search through the central
+     directory, so it's not very fast.
+
+     Alternately, you can iterate through all the files in an archive (using mz_zip_reader_get_num_files()) and
+     retrieve detailed info on each file by calling mz_zip_reader_file_stat().
+
+     - Archive creation: Use the "mz_zip_writer" functions. The ZIP writer immediately writes compressed file data
+     to disk and builds an exact image of the central directory in memory. The central directory image is written
+     all at once at the end of the archive file when the archive is finalized.
+
+     The archive writer can optionally align each file's local header and file data to any power of 2 alignment,
+     which can be useful when the archive will be read from optical media. Also, the writer supports placing
+     arbitrary data blobs at the very beginning of ZIP archives. Archives written using either feature are still
+     readable by any ZIP tool.
+
+     - Archive appending: The simple way to add a single file to an archive is to call this function:
+
+      mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name,
+        const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags);
+
+     The archive will be created if it doesn't already exist, otherwise it'll be appended to.
+     Note the appending is done in-place and is not an atomic operation, so if something goes wrong
+     during the operation it's possible the archive could be left without a central directory (although the local
+     file headers and file data will be fine, so the archive will be recoverable).
+
+     For more complex archive modification scenarios:
+     1. The safest way is to use a mz_zip_reader to read the existing archive, cloning only those bits you want to
+     preserve into a new archive using using the mz_zip_writer_add_from_zip_reader() function (which compiles the
+     compressed file data as-is). When you're done, delete the old archive and rename the newly written archive, and
+     you're done. This is safe but requires a bunch of temporary disk space or heap memory.
+
+     2. Or, you can convert an mz_zip_reader in-place to an mz_zip_writer using mz_zip_writer_init_from_reader(),
+     append new files as needed, then finalize the archive which will write an updated central directory to the
+     original archive. (This is basically what mz_zip_add_mem_to_archive_file_in_place() does.) There's a
+     possibility that the archive's central directory could be lost with this method if anything goes wrong, though.
+
+     - ZIP archive support limitations:
+     No zip64 or spanning support. Extraction functions can only handle unencrypted, stored or deflated files.
+     Requires streams capable of seeking.
+
+   * This is a header file library, like stb_image.c. To get only a header file, either cut and paste the
+     below header, or create miniz.h, #define MINIZ_HEADER_FILE_ONLY, and then include miniz.c from it.
+
+   * Important: For best perf. be sure to customize the below macros for your target platform:
+     #define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1
+     #define MINIZ_LITTLE_ENDIAN 1
+     #define MINIZ_HAS_64BIT_REGISTERS 1
+
+   * On platforms using glibc, Be sure to "#define _LARGEFILE64_SOURCE 1" before including miniz.c to ensure miniz
+     uses the 64-bit variants: fopen64(), stat64(), etc. Otherwise you won't be able to process large files
+     (i.e. 32-bit stat() fails for me on files > 0x7FFFFFFF bytes).
+*/
+#pragma once
+
+#include "miniz_common.h"
+#include "miniz_tdef.h"
+#include "miniz_tinfl.h"
+
+/* Defines to completely disable specific portions of miniz.c: 
+   If all macros here are defined the only functionality remaining will be CRC-32, adler-32, tinfl, and tdefl. */
+
+/* Define MINIZ_NO_STDIO to disable all usage and any functions which rely on stdio for file I/O. */
+/*#define MINIZ_NO_STDIO */
+
+/* If MINIZ_NO_TIME is specified then the ZIP archive functions will not be able to get the current time, or */
+/* get/set file times, and the C run-time funcs that get/set times won't be called. */
+/* The current downside is the times written to your archives will be from 1979. */
+/*#define MINIZ_NO_TIME */
+
+/* Define MINIZ_NO_ARCHIVE_APIS to disable all ZIP archive API's. */
+/*#define MINIZ_NO_ARCHIVE_APIS */
+
+/* Define MINIZ_NO_ARCHIVE_WRITING_APIS to disable all writing related ZIP archive API's. */
+/*#define MINIZ_NO_ARCHIVE_WRITING_APIS */
+
+/* Define MINIZ_NO_ZLIB_APIS to remove all ZLIB-style compression/decompression API's. */
+/*#define MINIZ_NO_ZLIB_APIS */
+
+/* Define MINIZ_NO_ZLIB_COMPATIBLE_NAME to disable zlib names, to prevent conflicts against stock zlib. */
+/*#define MINIZ_NO_ZLIB_COMPATIBLE_NAMES */
+
+/* Define MINIZ_NO_MALLOC to disable all calls to malloc, free, and realloc. 
+   Note if MINIZ_NO_MALLOC is defined then the user must always provide custom user alloc/free/realloc
+   callbacks to the zlib and archive API's, and a few stand-alone helper API's which don't provide custom user
+   functions (such as tdefl_compress_mem_to_heap() and tinfl_decompress_mem_to_heap()) won't work. */
+/*#define MINIZ_NO_MALLOC */
+
+#if defined(__TINYC__) && (defined(__linux) || defined(__linux__))
+/* TODO: Work around "error: include file 'sys\utime.h' when compiling with tcc on Linux */
+#define MINIZ_NO_TIME
+#endif
+
+#include <stddef.h>
+
+#if !defined(MINIZ_NO_TIME) && !defined(MINIZ_NO_ARCHIVE_APIS)
+#include <time.h>
+#endif
+
+#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || defined(__i386) || defined(__i486__) || defined(__i486) || defined(i386) || defined(__ia64__) || defined(__x86_64__)
+/* MINIZ_X86_OR_X64_CPU is only used to help set the below macros. */
+#define MINIZ_X86_OR_X64_CPU 1
+#else
+#define MINIZ_X86_OR_X64_CPU 0
+#endif
+
+#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || MINIZ_X86_OR_X64_CPU
+/* Set MINIZ_LITTLE_ENDIAN to 1 if the processor is little endian. */
+#define MINIZ_LITTLE_ENDIAN 1
+#else
+#define MINIZ_LITTLE_ENDIAN 0
+#endif
+
+#if MINIZ_X86_OR_X64_CPU
+/* Set MINIZ_USE_UNALIGNED_LOADS_AND_STORES to 1 on CPU's that permit efficient integer loads and stores from unaligned addresses. */
+#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1
+#else
+#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 0
+#endif
+
+#if defined(_M_X64) || defined(_WIN64) || defined(__MINGW64__) || defined(_LP64) || defined(__LP64__) || defined(__ia64__) || defined(__x86_64__)
+/* Set MINIZ_HAS_64BIT_REGISTERS to 1 if operations on 64-bit integers are reasonably fast (and don't involve compiler generated calls to helper functions). */
+#define MINIZ_HAS_64BIT_REGISTERS 1
+#else
+#define MINIZ_HAS_64BIT_REGISTERS 0
+#endif
+
+/* ------------------- zlib-style API Definitions. */
+
+/* For more compatibility with zlib, miniz.c uses unsigned long for some parameters/struct members. Beware: mz_ulong can be either 32 or 64-bits! */
+typedef unsigned long mz_ulong;
+
+/* mz_free() internally uses the MZ_FREE() macro (which by default calls free() unless you've modified the MZ_MALLOC macro) to release a block allocated from the heap. */
+void mz_free(void *p);
+
+#define MZ_ADLER32_INIT (1)
+/* mz_adler32() returns the initial adler-32 value to use when called with ptr==NULL. */
+mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len);
+
+#define MZ_CRC32_INIT (0)
+/* mz_crc32() returns the initial CRC-32 value to use when called with ptr==NULL. */
+mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len);
+
+/* Compression strategies. */
+enum
+{
+    MZ_DEFAULT_STRATEGY = 0,
+    MZ_FILTERED = 1,
+    MZ_HUFFMAN_ONLY = 2,
+    MZ_RLE = 3,
+    MZ_FIXED = 4
+};
+
+/* Method */
+#define MZ_DEFLATED 8
+
+/* Heap allocation callbacks.
+Note that mz_alloc_func parameter types purpsosely differ from zlib's: items/size is size_t, not unsigned long. */
+typedef void *(*mz_alloc_func)(void *opaque, size_t items, size_t size);
+typedef void (*mz_free_func)(void *opaque, void *address);
+typedef void *(*mz_realloc_func)(void *opaque, void *address, size_t items, size_t size);
+
+/* Compression levels: 0-9 are the standard zlib-style levels, 10 is best possible compression (not zlib compatible, and may be very slow), MZ_DEFAULT_COMPRESSION=MZ_DEFAULT_LEVEL. */
+enum
+{
+    MZ_NO_COMPRESSION = 0,
+    MZ_BEST_SPEED = 1,
+    MZ_BEST_COMPRESSION = 9,
+    MZ_UBER_COMPRESSION = 10,
+    MZ_DEFAULT_LEVEL = 6,
+    MZ_DEFAULT_COMPRESSION = -1
+};
+
+#define MZ_VERSION "10.0.1"
+#define MZ_VERNUM 0xA010
+#define MZ_VER_MAJOR 10
+#define MZ_VER_MINOR 0
+#define MZ_VER_REVISION 1
+#define MZ_VER_SUBREVISION 0
+
+#ifndef MINIZ_NO_ZLIB_APIS
+
+/* Flush values. For typical usage you only need MZ_NO_FLUSH and MZ_FINISH. The other values are for advanced use (refer to the zlib docs). */
+enum
+{
+    MZ_NO_FLUSH = 0,
+    MZ_PARTIAL_FLUSH = 1,
+    MZ_SYNC_FLUSH = 2,
+    MZ_FULL_FLUSH = 3,
+    MZ_FINISH = 4,
+    MZ_BLOCK = 5
+};
+
+/* Return status codes. MZ_PARAM_ERROR is non-standard. */
+enum
+{
+    MZ_OK = 0,
+    MZ_STREAM_END = 1,
+    MZ_NEED_DICT = 2,
+    MZ_ERRNO = -1,
+    MZ_STREAM_ERROR = -2,
+    MZ_DATA_ERROR = -3,
+    MZ_MEM_ERROR = -4,
+    MZ_BUF_ERROR = -5,
+    MZ_VERSION_ERROR = -6,
+    MZ_PARAM_ERROR = -10000
+};
+
+/* Window bits */
+#define MZ_DEFAULT_WINDOW_BITS 15
+
+struct mz_internal_state;
+
+/* Compression/decompression stream struct. */
+typedef struct mz_stream_s
+{
+    const unsigned char *next_in; /* pointer to next byte to read */
+    unsigned int avail_in;        /* number of bytes available at next_in */
+    mz_ulong total_in;            /* total number of bytes consumed so far */
+
+    unsigned char *next_out; /* pointer to next byte to write */
+    unsigned int avail_out;  /* number of bytes that can be written to next_out */
+    mz_ulong total_out;      /* total number of bytes produced so far */
+
+    char *msg;                       /* error msg (unused) */
+    struct mz_internal_state *state; /* internal state, allocated by zalloc/zfree */
+
+    mz_alloc_func zalloc; /* optional heap allocation function (defaults to malloc) */
+    mz_free_func zfree;   /* optional heap free function (defaults to free) */
+    void *opaque;         /* heap alloc function user pointer */
+
+    int data_type;     /* data_type (unused) */
+    mz_ulong adler;    /* adler32 of the source or uncompressed data */
+    mz_ulong reserved; /* not used */
+} mz_stream;
+
+typedef mz_stream *mz_streamp;
+
+/* Returns the version string of miniz.c. */
+const char *mz_version(void);
+
+/* mz_deflateInit() initializes a compressor with default options: */
+/* Parameters: */
+/*  pStream must point to an initialized mz_stream struct. */
+/*  level must be between [MZ_NO_COMPRESSION, MZ_BEST_COMPRESSION]. */
+/*  level 1 enables a specially optimized compression function that's been optimized purely for performance, not ratio. */
+/*  (This special func. is currently only enabled when MINIZ_USE_UNALIGNED_LOADS_AND_STORES and MINIZ_LITTLE_ENDIAN are defined.) */
+/* Return values: */
+/*  MZ_OK on success. */
+/*  MZ_STREAM_ERROR if the stream is bogus. */
+/*  MZ_PARAM_ERROR if the input parameters are bogus. */
+/*  MZ_MEM_ERROR on out of memory. */
+int mz_deflateInit(mz_streamp pStream, int level);
+
+/* mz_deflateInit2() is like mz_deflate(), except with more control: */
+/* Additional parameters: */
+/*   method must be MZ_DEFLATED */
+/*   window_bits must be MZ_DEFAULT_WINDOW_BITS (to wrap the deflate stream with zlib header/adler-32 footer) or -MZ_DEFAULT_WINDOW_BITS (raw deflate/no header or footer) */
+/*   mem_level must be between [1, 9] (it's checked but ignored by miniz.c) */
+int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy);
+
+/* Quickly resets a compressor without having to reallocate anything. Same as calling mz_deflateEnd() followed by mz_deflateInit()/mz_deflateInit2(). */
+int mz_deflateReset(mz_streamp pStream);
+
+/* mz_deflate() compresses the input to output, consuming as much of the input and producing as much output as possible. */
+/* Parameters: */
+/*   pStream is the stream to read from and write to. You must initialize/update the next_in, avail_in, next_out, and avail_out members. */
+/*   flush may be MZ_NO_FLUSH, MZ_PARTIAL_FLUSH/MZ_SYNC_FLUSH, MZ_FULL_FLUSH, or MZ_FINISH. */
+/* Return values: */
+/*   MZ_OK on success (when flushing, or if more input is needed but not available, and/or there's more output to be written but the output buffer is full). */
+/*   MZ_STREAM_END if all input has been consumed and all output bytes have been written. Don't call mz_deflate() on the stream anymore. */
+/*   MZ_STREAM_ERROR if the stream is bogus. */
+/*   MZ_PARAM_ERROR if one of the parameters is invalid. */
+/*   MZ_BUF_ERROR if no forward progress is possible because the input and/or output buffers are empty. (Fill up the input buffer or free up some output space and try again.) */
+int mz_deflate(mz_streamp pStream, int flush);
+
+/* mz_deflateEnd() deinitializes a compressor: */
+/* Return values: */
+/*  MZ_OK on success. */
+/*  MZ_STREAM_ERROR if the stream is bogus. */
+int mz_deflateEnd(mz_streamp pStream);
+
+/* mz_deflateBound() returns a (very) conservative upper bound on the amount of data that could be generated by deflate(), assuming flush is set to only MZ_NO_FLUSH or MZ_FINISH. */
+mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len);
+
+/* Single-call compression functions mz_compress() and mz_compress2(): */
+/* Returns MZ_OK on success, or one of the error codes from mz_deflate() on failure. */
+int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len);
+int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level);
+
+/* mz_compressBound() returns a (very) conservative upper bound on the amount of data that could be generated by calling mz_compress(). */
+mz_ulong mz_compressBound(mz_ulong source_len);
+
+/* Initializes a decompressor. */
+int mz_inflateInit(mz_streamp pStream);
+
+/* mz_inflateInit2() is like mz_inflateInit() with an additional option that controls the window size and whether or not the stream has been wrapped with a zlib header/footer: */
+/* window_bits must be MZ_DEFAULT_WINDOW_BITS (to parse zlib header/footer) or -MZ_DEFAULT_WINDOW_BITS (raw deflate). */
+int mz_inflateInit2(mz_streamp pStream, int window_bits);
+
+/* Decompresses the input stream to the output, consuming only as much of the input as needed, and writing as much to the output as possible. */
+/* Parameters: */
+/*   pStream is the stream to read from and write to. You must initialize/update the next_in, avail_in, next_out, and avail_out members. */
+/*   flush may be MZ_NO_FLUSH, MZ_SYNC_FLUSH, or MZ_FINISH. */
+/*   On the first call, if flush is MZ_FINISH it's assumed the input and output buffers are both sized large enough to decompress the entire stream in a single call (this is slightly faster). */
+/*   MZ_FINISH implies that there are no more source bytes available beside what's already in the input buffer, and that the output buffer is large enough to hold the rest of the decompressed data. */
+/* Return values: */
+/*   MZ_OK on success. Either more input is needed but not available, and/or there's more output to be written but the output buffer is full. */
+/*   MZ_STREAM_END if all needed input has been consumed and all output bytes have been written. For zlib streams, the adler-32 of the decompressed data has also been verified. */
+/*   MZ_STREAM_ERROR if the stream is bogus. */
+/*   MZ_DATA_ERROR if the deflate stream is invalid. */
+/*   MZ_PARAM_ERROR if one of the parameters is invalid. */
+/*   MZ_BUF_ERROR if no forward progress is possible because the input buffer is empty but the inflater needs more input to continue, or if the output buffer is not large enough. Call mz_inflate() again */
+/*   with more input data, or with more room in the output buffer (except when using single call decompression, described above). */
+int mz_inflate(mz_streamp pStream, int flush);
+
+/* Deinitializes a decompressor. */
+int mz_inflateEnd(mz_streamp pStream);
+
+/* Single-call decompression. */
+/* Returns MZ_OK on success, or one of the error codes from mz_inflate() on failure. */
+int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len);
+
+/* Returns a string description of the specified error code, or NULL if the error code is invalid. */
+const char *mz_error(int err);
+
+/* Redefine zlib-compatible names to miniz equivalents, so miniz.c can be used as a drop-in replacement for the subset of zlib that miniz.c supports. */
+/* Define MINIZ_NO_ZLIB_COMPATIBLE_NAMES to disable zlib-compatibility if you use zlib in the same project. */
+#ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES
+typedef unsigned char Byte;
+typedef unsigned int uInt;
+typedef mz_ulong uLong;
+typedef Byte Bytef;
+typedef uInt uIntf;
+typedef char charf;
+typedef int intf;
+typedef void *voidpf;
+typedef uLong uLongf;
+typedef void *voidp;
+typedef void *const voidpc;
+#define Z_NULL 0
+#define Z_NO_FLUSH MZ_NO_FLUSH
+#define Z_PARTIAL_FLUSH MZ_PARTIAL_FLUSH
+#define Z_SYNC_FLUSH MZ_SYNC_FLUSH
+#define Z_FULL_FLUSH MZ_FULL_FLUSH
+#define Z_FINISH MZ_FINISH
+#define Z_BLOCK MZ_BLOCK
+#define Z_OK MZ_OK
+#define Z_STREAM_END MZ_STREAM_END
+#define Z_NEED_DICT MZ_NEED_DICT
+#define Z_ERRNO MZ_ERRNO
+#define Z_STREAM_ERROR MZ_STREAM_ERROR
+#define Z_DATA_ERROR MZ_DATA_ERROR
+#define Z_MEM_ERROR MZ_MEM_ERROR
+#define Z_BUF_ERROR MZ_BUF_ERROR
+#define Z_VERSION_ERROR MZ_VERSION_ERROR
+#define Z_PARAM_ERROR MZ_PARAM_ERROR
+#define Z_NO_COMPRESSION MZ_NO_COMPRESSION
+#define Z_BEST_SPEED MZ_BEST_SPEED
+#define Z_BEST_COMPRESSION MZ_BEST_COMPRESSION
+#define Z_DEFAULT_COMPRESSION MZ_DEFAULT_COMPRESSION
+#define Z_DEFAULT_STRATEGY MZ_DEFAULT_STRATEGY
+#define Z_FILTERED MZ_FILTERED
+#define Z_HUFFMAN_ONLY MZ_HUFFMAN_ONLY
+#define Z_RLE MZ_RLE
+#define Z_FIXED MZ_FIXED
+#define Z_DEFLATED MZ_DEFLATED
+#define Z_DEFAULT_WINDOW_BITS MZ_DEFAULT_WINDOW_BITS
+#define alloc_func mz_alloc_func
+#define free_func mz_free_func
+#define internal_state mz_internal_state
+#define z_stream mz_stream
+#define deflateInit mz_deflateInit
+#define deflateInit2 mz_deflateInit2
+#define deflateReset mz_deflateReset
+#define deflate mz_deflate
+#define deflateEnd mz_deflateEnd
+#define deflateBound mz_deflateBound
+#define compress mz_compress
+#define compress2 mz_compress2
+#define compressBound mz_compressBound
+#define inflateInit mz_inflateInit
+#define inflateInit2 mz_inflateInit2
+#define inflate mz_inflate
+#define inflateEnd mz_inflateEnd
+#define uncompress mz_uncompress
+#define crc32 mz_crc32
+#define adler32 mz_adler32
+#define MAX_WBITS 15
+#define MAX_MEM_LEVEL 9
+#define zError mz_error
+#define ZLIB_VERSION MZ_VERSION
+#define ZLIB_VERNUM MZ_VERNUM
+#define ZLIB_VER_MAJOR MZ_VER_MAJOR
+#define ZLIB_VER_MINOR MZ_VER_MINOR
+#define ZLIB_VER_REVISION MZ_VER_REVISION
+#define ZLIB_VER_SUBREVISION MZ_VER_SUBREVISION
+#define zlibVersion mz_version
+#define zlib_version mz_version()
+#endif /* #ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES */
+
+#endif /* MINIZ_NO_ZLIB_APIS */
+
diff --git a/xs/src/miniz/miniz_common.h b/xs/src/miniz/miniz_common.h
new file mode 100644
index 000000000..d45bdfcb4
--- /dev/null
+++ b/xs/src/miniz/miniz_common.h
@@ -0,0 +1,83 @@
+#pragma once
+#include <assert.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* ------------------- Types and macros */
+typedef unsigned char mz_uint8;
+typedef signed short mz_int16;
+typedef unsigned short mz_uint16;
+typedef unsigned int mz_uint32;
+typedef unsigned int mz_uint;
+typedef int64_t mz_int64;
+typedef uint64_t mz_uint64;
+typedef int mz_bool;
+
+#define MZ_FALSE (0)
+#define MZ_TRUE (1)
+
+/* Works around MSVC's spammy "warning C4127: conditional expression is constant" message. */
+#ifdef _MSC_VER
+#define MZ_MACRO_END while (0, 0)
+#else
+#define MZ_MACRO_END while (0)
+#endif
+
+#ifdef MINIZ_NO_STDIO
+#define MZ_FILE void *
+#else
+#include <stdio.h>
+#define MZ_FILE FILE
+#endif /* #ifdef MINIZ_NO_STDIO */
+
+#ifdef MINIZ_NO_TIME
+typedef struct mz_dummy_time_t_tag
+{
+    int m_dummy;
+} mz_dummy_time_t;
+#define MZ_TIME_T mz_dummy_time_t
+#else
+#define MZ_TIME_T time_t
+#endif
+
+#define MZ_ASSERT(x) assert(x)
+
+#ifdef MINIZ_NO_MALLOC
+#define MZ_MALLOC(x) NULL
+#define MZ_FREE(x) (void)x, ((void)0)
+#define MZ_REALLOC(p, x) NULL
+#else
+#define MZ_MALLOC(x) malloc(x)
+#define MZ_FREE(x) free(x)
+#define MZ_REALLOC(p, x) realloc(p, x)
+#endif
+
+#define MZ_MAX(a, b) (((a) > (b)) ? (a) : (b))
+#define MZ_MIN(a, b) (((a) < (b)) ? (a) : (b))
+#define MZ_CLEAR_OBJ(obj) memset(&(obj), 0, sizeof(obj))
+
+#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN
+#define MZ_READ_LE16(p) *((const mz_uint16 *)(p))
+#define MZ_READ_LE32(p) *((const mz_uint32 *)(p))
+#else
+#define MZ_READ_LE16(p) ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U))
+#define MZ_READ_LE32(p) ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U) | ((mz_uint32)(((const mz_uint8 *)(p))[2]) << 16U) | ((mz_uint32)(((const mz_uint8 *)(p))[3]) << 24U))
+#endif
+
+#define MZ_READ_LE64(p) (((mz_uint64)MZ_READ_LE32(p)) | (((mz_uint64)MZ_READ_LE32((const mz_uint8 *)(p) + sizeof(mz_uint32))) << 32U))
+
+#ifdef _MSC_VER
+#define MZ_FORCEINLINE __forceinline
+#elif defined(__GNUC__)
+#define MZ_FORCEINLINE __inline__ __attribute__((__always_inline__))
+#else
+#define MZ_FORCEINLINE inline
+#endif
+
+extern void *miniz_def_alloc_func(void *opaque, size_t items, size_t size);
+extern void miniz_def_free_func(void *opaque, void *address);
+extern void *miniz_def_realloc_func(void *opaque, void *address, size_t items, size_t size);
+
+#define MZ_UINT16_MAX (0xFFFFU)
+#define MZ_UINT32_MAX (0xFFFFFFFFU)
diff --git a/xs/src/miniz/miniz_tdef.cpp b/xs/src/miniz/miniz_tdef.cpp
new file mode 100644
index 000000000..36207e64a
--- /dev/null
+++ b/xs/src/miniz/miniz_tdef.cpp
@@ -0,0 +1,1555 @@
+/**************************************************************************
+ *
+ * Copyright 2013-2014 RAD Game Tools and Valve Software
+ * Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "miniz_tdef.h"
+#include "miniz.h"
+
+/* ------------------- Low-level Compression (independent from all decompression API's) */
+
+/* Purposely making these tables static for faster init and thread safety. */
+static const mz_uint16 s_tdefl_len_sym[256] =
+    {
+      257, 258, 259, 260, 261, 262, 263, 264, 265, 265, 266, 266, 267, 267, 268, 268, 269, 269, 269, 269, 270, 270, 270, 270, 271, 271, 271, 271, 272, 272, 272, 272,
+      273, 273, 273, 273, 273, 273, 273, 273, 274, 274, 274, 274, 274, 274, 274, 274, 275, 275, 275, 275, 275, 275, 275, 275, 276, 276, 276, 276, 276, 276, 276, 276,
+      277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278,
+      279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280,
+      281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281,
+      282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282,
+      283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283,
+      284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 285
+    };
+
+static const mz_uint8 s_tdefl_len_extra[256] =
+    {
+      0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+      4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+      5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+      5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0
+    };
+
+static const mz_uint8 s_tdefl_small_dist_sym[512] =
+    {
+      0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11,
+      11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13,
+      13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+      14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+      14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+      15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+      16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+      16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+      16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
+      17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
+      17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
+      17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17
+    };
+
+static const mz_uint8 s_tdefl_small_dist_extra[512] =
+    {
+      0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5,
+      5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+      6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+      6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+      7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+      7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+      7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+      7, 7, 7, 7, 7, 7, 7, 7
+    };
+
+static const mz_uint8 s_tdefl_large_dist_sym[128] =
+    {
+      0, 0, 18, 19, 20, 20, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
+      26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+      28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
+    };
+
+static const mz_uint8 s_tdefl_large_dist_extra[128] =
+    {
+      0, 0, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+      12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+      13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13
+    };
+
+/* Radix sorts tdefl_sym_freq[] array by 16-bit key m_key. Returns ptr to sorted values. */
+typedef struct
+{
+    mz_uint16 m_key, m_sym_index;
+} tdefl_sym_freq;
+static tdefl_sym_freq *tdefl_radix_sort_syms(mz_uint num_syms, tdefl_sym_freq *pSyms0, tdefl_sym_freq *pSyms1)
+{
+    mz_uint32 total_passes = 2, pass_shift, pass, i, hist[256 * 2];
+    tdefl_sym_freq *pCur_syms = pSyms0, *pNew_syms = pSyms1;
+    MZ_CLEAR_OBJ(hist);
+    for (i = 0; i < num_syms; i++)
+    {
+        mz_uint freq = pSyms0[i].m_key;
+        hist[freq & 0xFF]++;
+        hist[256 + ((freq >> 8) & 0xFF)]++;
+    }
+    while ((total_passes > 1) && (num_syms == hist[(total_passes - 1) * 256]))
+        total_passes--;
+    for (pass_shift = 0, pass = 0; pass < total_passes; pass++, pass_shift += 8)
+    {
+        const mz_uint32 *pHist = &hist[pass << 8];
+        mz_uint offsets[256], cur_ofs = 0;
+        for (i = 0; i < 256; i++)
+        {
+            offsets[i] = cur_ofs;
+            cur_ofs += pHist[i];
+        }
+        for (i = 0; i < num_syms; i++)
+            pNew_syms[offsets[(pCur_syms[i].m_key >> pass_shift) & 0xFF]++] = pCur_syms[i];
+        {
+            tdefl_sym_freq *t = pCur_syms;
+            pCur_syms = pNew_syms;
+            pNew_syms = t;
+        }
+    }
+    return pCur_syms;
+}
+
+/* tdefl_calculate_minimum_redundancy() originally written by: Alistair Moffat, alistair@cs.mu.oz.au, Jyrki Katajainen, jyrki@diku.dk, November 1996. */
+static void tdefl_calculate_minimum_redundancy(tdefl_sym_freq *A, int n)
+{
+    int root, leaf, next, avbl, used, dpth;
+    if (n == 0)
+        return;
+    else if (n == 1)
+    {
+        A[0].m_key = 1;
+        return;
+    }
+    A[0].m_key += A[1].m_key;
+    root = 0;
+    leaf = 2;
+    for (next = 1; next < n - 1; next++)
+    {
+        if (leaf >= n || A[root].m_key < A[leaf].m_key)
+        {
+            A[next].m_key = A[root].m_key;
+            A[root++].m_key = (mz_uint16)next;
+        }
+        else
+            A[next].m_key = A[leaf++].m_key;
+        if (leaf >= n || (root < next && A[root].m_key < A[leaf].m_key))
+        {
+            A[next].m_key = (mz_uint16)(A[next].m_key + A[root].m_key);
+            A[root++].m_key = (mz_uint16)next;
+        }
+        else
+            A[next].m_key = (mz_uint16)(A[next].m_key + A[leaf++].m_key);
+    }
+    A[n - 2].m_key = 0;
+    for (next = n - 3; next >= 0; next--)
+        A[next].m_key = A[A[next].m_key].m_key + 1;
+    avbl = 1;
+    used = dpth = 0;
+    root = n - 2;
+    next = n - 1;
+    while (avbl > 0)
+    {
+        while (root >= 0 && (int)A[root].m_key == dpth)
+        {
+            used++;
+            root--;
+        }
+        while (avbl > used)
+        {
+            A[next--].m_key = (mz_uint16)(dpth);
+            avbl--;
+        }
+        avbl = 2 * used;
+        dpth++;
+        used = 0;
+    }
+}
+
+/* Limits canonical Huffman code table's max code size. */
+enum
+{
+    TDEFL_MAX_SUPPORTED_HUFF_CODESIZE = 32
+};
+static void tdefl_huffman_enforce_max_code_size(int *pNum_codes, int code_list_len, int max_code_size)
+{
+    int i;
+    mz_uint32 total = 0;
+    if (code_list_len <= 1)
+        return;
+    for (i = max_code_size + 1; i <= TDEFL_MAX_SUPPORTED_HUFF_CODESIZE; i++)
+        pNum_codes[max_code_size] += pNum_codes[i];
+    for (i = max_code_size; i > 0; i--)
+        total += (((mz_uint32)pNum_codes[i]) << (max_code_size - i));
+    while (total != (1UL << max_code_size))
+    {
+        pNum_codes[max_code_size]--;
+        for (i = max_code_size - 1; i > 0; i--)
+            if (pNum_codes[i])
+            {
+                pNum_codes[i]--;
+                pNum_codes[i + 1] += 2;
+                break;
+            }
+        total--;
+    }
+}
+
+static void tdefl_optimize_huffman_table(tdefl_compressor *d, int table_num, int table_len, int code_size_limit, int static_table)
+{
+    int i, j, l, num_codes[1 + TDEFL_MAX_SUPPORTED_HUFF_CODESIZE];
+    mz_uint next_code[TDEFL_MAX_SUPPORTED_HUFF_CODESIZE + 1];
+    MZ_CLEAR_OBJ(num_codes);
+    if (static_table)
+    {
+        for (i = 0; i < table_len; i++)
+            num_codes[d->m_huff_code_sizes[table_num][i]]++;
+    }
+    else
+    {
+        tdefl_sym_freq syms0[TDEFL_MAX_HUFF_SYMBOLS], syms1[TDEFL_MAX_HUFF_SYMBOLS], *pSyms;
+        int num_used_syms = 0;
+        const mz_uint16 *pSym_count = &d->m_huff_count[table_num][0];
+        for (i = 0; i < table_len; i++)
+            if (pSym_count[i])
+            {
+                syms0[num_used_syms].m_key = (mz_uint16)pSym_count[i];
+                syms0[num_used_syms++].m_sym_index = (mz_uint16)i;
+            }
+
+        pSyms = tdefl_radix_sort_syms(num_used_syms, syms0, syms1);
+        tdefl_calculate_minimum_redundancy(pSyms, num_used_syms);
+
+        for (i = 0; i < num_used_syms; i++)
+            num_codes[pSyms[i].m_key]++;
+
+        tdefl_huffman_enforce_max_code_size(num_codes, num_used_syms, code_size_limit);
+
+        MZ_CLEAR_OBJ(d->m_huff_code_sizes[table_num]);
+        MZ_CLEAR_OBJ(d->m_huff_codes[table_num]);
+        for (i = 1, j = num_used_syms; i <= code_size_limit; i++)
+            for (l = num_codes[i]; l > 0; l--)
+                d->m_huff_code_sizes[table_num][pSyms[--j].m_sym_index] = (mz_uint8)(i);
+    }
+
+    next_code[1] = 0;
+    for (j = 0, i = 2; i <= code_size_limit; i++)
+        next_code[i] = j = ((j + num_codes[i - 1]) << 1);
+
+    for (i = 0; i < table_len; i++)
+    {
+        mz_uint rev_code = 0, code, code_size;
+        if ((code_size = d->m_huff_code_sizes[table_num][i]) == 0)
+            continue;
+        code = next_code[code_size]++;
+        for (l = code_size; l > 0; l--, code >>= 1)
+            rev_code = (rev_code << 1) | (code & 1);
+        d->m_huff_codes[table_num][i] = (mz_uint16)rev_code;
+    }
+}
+
+#define TDEFL_PUT_BITS(b, l)                                       \
+    do                                                             \
+    {                                                              \
+        mz_uint bits = b;                                          \
+        mz_uint len = l;                                           \
+        MZ_ASSERT(bits <= ((1U << len) - 1U));                     \
+        d->m_bit_buffer |= (bits << d->m_bits_in);                 \
+        d->m_bits_in += len;                                       \
+        while (d->m_bits_in >= 8)                                  \
+        {                                                          \
+            if (d->m_pOutput_buf < d->m_pOutput_buf_end)           \
+                *d->m_pOutput_buf++ = (mz_uint8)(d->m_bit_buffer); \
+            d->m_bit_buffer >>= 8;                                 \
+            d->m_bits_in -= 8;                                     \
+        }                                                          \
+    }                                                              \
+    MZ_MACRO_END
+
+#define TDEFL_RLE_PREV_CODE_SIZE()                                                                                       \
+    {                                                                                                                    \
+        if (rle_repeat_count)                                                                                            \
+        {                                                                                                                \
+            if (rle_repeat_count < 3)                                                                                    \
+            {                                                                                                            \
+                d->m_huff_count[2][prev_code_size] = (mz_uint16)(d->m_huff_count[2][prev_code_size] + rle_repeat_count); \
+                while (rle_repeat_count--)                                                                               \
+                    packed_code_sizes[num_packed_code_sizes++] = prev_code_size;                                         \
+            }                                                                                                            \
+            else                                                                                                         \
+            {                                                                                                            \
+                d->m_huff_count[2][16] = (mz_uint16)(d->m_huff_count[2][16] + 1);                                        \
+                packed_code_sizes[num_packed_code_sizes++] = 16;                                                         \
+                packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_repeat_count - 3);                           \
+            }                                                                                                            \
+            rle_repeat_count = 0;                                                                                        \
+        }                                                                                                                \
+    }
+
+#define TDEFL_RLE_ZERO_CODE_SIZE()                                                         \
+    {                                                                                      \
+        if (rle_z_count)                                                                   \
+        {                                                                                  \
+            if (rle_z_count < 3)                                                           \
+            {                                                                              \
+                d->m_huff_count[2][0] = (mz_uint16)(d->m_huff_count[2][0] + rle_z_count);  \
+                while (rle_z_count--)                                                      \
+                    packed_code_sizes[num_packed_code_sizes++] = 0;                        \
+            }                                                                              \
+            else if (rle_z_count <= 10)                                                    \
+            {                                                                              \
+                d->m_huff_count[2][17] = (mz_uint16)(d->m_huff_count[2][17] + 1);          \
+                packed_code_sizes[num_packed_code_sizes++] = 17;                           \
+                packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_z_count - 3);  \
+            }                                                                              \
+            else                                                                           \
+            {                                                                              \
+                d->m_huff_count[2][18] = (mz_uint16)(d->m_huff_count[2][18] + 1);          \
+                packed_code_sizes[num_packed_code_sizes++] = 18;                           \
+                packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_z_count - 11); \
+            }                                                                              \
+            rle_z_count = 0;                                                               \
+        }                                                                                  \
+    }
+
+static mz_uint8 s_tdefl_packed_code_size_syms_swizzle[] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };
+
+static void tdefl_start_dynamic_block(tdefl_compressor *d)
+{
+    int num_lit_codes, num_dist_codes, num_bit_lengths;
+    mz_uint i, total_code_sizes_to_pack, num_packed_code_sizes, rle_z_count, rle_repeat_count, packed_code_sizes_index;
+    mz_uint8 code_sizes_to_pack[TDEFL_MAX_HUFF_SYMBOLS_0 + TDEFL_MAX_HUFF_SYMBOLS_1], packed_code_sizes[TDEFL_MAX_HUFF_SYMBOLS_0 + TDEFL_MAX_HUFF_SYMBOLS_1], prev_code_size = 0xFF;
+
+    d->m_huff_count[0][256] = 1;
+
+    tdefl_optimize_huffman_table(d, 0, TDEFL_MAX_HUFF_SYMBOLS_0, 15, MZ_FALSE);
+    tdefl_optimize_huffman_table(d, 1, TDEFL_MAX_HUFF_SYMBOLS_1, 15, MZ_FALSE);
+
+    for (num_lit_codes = 286; num_lit_codes > 257; num_lit_codes--)
+        if (d->m_huff_code_sizes[0][num_lit_codes - 1])
+            break;
+    for (num_dist_codes = 30; num_dist_codes > 1; num_dist_codes--)
+        if (d->m_huff_code_sizes[1][num_dist_codes - 1])
+            break;
+
+    memcpy(code_sizes_to_pack, &d->m_huff_code_sizes[0][0], num_lit_codes);
+    memcpy(code_sizes_to_pack + num_lit_codes, &d->m_huff_code_sizes[1][0], num_dist_codes);
+    total_code_sizes_to_pack = num_lit_codes + num_dist_codes;
+    num_packed_code_sizes = 0;
+    rle_z_count = 0;
+    rle_repeat_count = 0;
+
+    memset(&d->m_huff_count[2][0], 0, sizeof(d->m_huff_count[2][0]) * TDEFL_MAX_HUFF_SYMBOLS_2);
+    for (i = 0; i < total_code_sizes_to_pack; i++)
+    {
+        mz_uint8 code_size = code_sizes_to_pack[i];
+        if (!code_size)
+        {
+            TDEFL_RLE_PREV_CODE_SIZE();
+            if (++rle_z_count == 138)
+            {
+                TDEFL_RLE_ZERO_CODE_SIZE();
+            }
+        }
+        else
+        {
+            TDEFL_RLE_ZERO_CODE_SIZE();
+            if (code_size != prev_code_size)
+            {
+                TDEFL_RLE_PREV_CODE_SIZE();
+                d->m_huff_count[2][code_size] = (mz_uint16)(d->m_huff_count[2][code_size] + 1);
+                packed_code_sizes[num_packed_code_sizes++] = code_size;
+            }
+            else if (++rle_repeat_count == 6)
+            {
+                TDEFL_RLE_PREV_CODE_SIZE();
+            }
+        }
+        prev_code_size = code_size;
+    }
+    if (rle_repeat_count)
+    {
+        TDEFL_RLE_PREV_CODE_SIZE();
+    }
+    else
+    {
+        TDEFL_RLE_ZERO_CODE_SIZE();
+    }
+
+    tdefl_optimize_huffman_table(d, 2, TDEFL_MAX_HUFF_SYMBOLS_2, 7, MZ_FALSE);
+
+    TDEFL_PUT_BITS(2, 2);
+
+    TDEFL_PUT_BITS(num_lit_codes - 257, 5);
+    TDEFL_PUT_BITS(num_dist_codes - 1, 5);
+
+    for (num_bit_lengths = 18; num_bit_lengths >= 0; num_bit_lengths--)
+        if (d->m_huff_code_sizes[2][s_tdefl_packed_code_size_syms_swizzle[num_bit_lengths]])
+            break;
+    num_bit_lengths = MZ_MAX(4, (num_bit_lengths + 1));
+    TDEFL_PUT_BITS(num_bit_lengths - 4, 4);
+    for (i = 0; (int)i < num_bit_lengths; i++)
+        TDEFL_PUT_BITS(d->m_huff_code_sizes[2][s_tdefl_packed_code_size_syms_swizzle[i]], 3);
+
+    for (packed_code_sizes_index = 0; packed_code_sizes_index < num_packed_code_sizes;)
+    {
+        mz_uint code = packed_code_sizes[packed_code_sizes_index++];
+        MZ_ASSERT(code < TDEFL_MAX_HUFF_SYMBOLS_2);
+        TDEFL_PUT_BITS(d->m_huff_codes[2][code], d->m_huff_code_sizes[2][code]);
+        if (code >= 16)
+            TDEFL_PUT_BITS(packed_code_sizes[packed_code_sizes_index++], "\02\03\07"[code - 16]);
+    }
+}
+
+static void tdefl_start_static_block(tdefl_compressor *d)
+{
+    mz_uint i;
+    mz_uint8 *p = &d->m_huff_code_sizes[0][0];
+
+    for (i = 0; i <= 143; ++i)
+        *p++ = 8;
+    for (; i <= 255; ++i)
+        *p++ = 9;
+    for (; i <= 279; ++i)
+        *p++ = 7;
+    for (; i <= 287; ++i)
+        *p++ = 8;
+
+    memset(d->m_huff_code_sizes[1], 5, 32);
+
+    tdefl_optimize_huffman_table(d, 0, 288, 15, MZ_TRUE);
+    tdefl_optimize_huffman_table(d, 1, 32, 15, MZ_TRUE);
+
+    TDEFL_PUT_BITS(1, 2);
+}
+
+static const mz_uint mz_bitmasks[17] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF };
+
+#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN && MINIZ_HAS_64BIT_REGISTERS
+static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d)
+{
+    mz_uint flags;
+    mz_uint8 *pLZ_codes;
+    mz_uint8 *pOutput_buf = d->m_pOutput_buf;
+    mz_uint8 *pLZ_code_buf_end = d->m_pLZ_code_buf;
+    mz_uint64 bit_buffer = d->m_bit_buffer;
+    mz_uint bits_in = d->m_bits_in;
+
+#define TDEFL_PUT_BITS_FAST(b, l)                    \
+    {                                                \
+        bit_buffer |= (((mz_uint64)(b)) << bits_in); \
+        bits_in += (l);                              \
+    }
+
+    flags = 1;
+    for (pLZ_codes = d->m_lz_code_buf; pLZ_codes < pLZ_code_buf_end; flags >>= 1)
+    {
+        if (flags == 1)
+            flags = *pLZ_codes++ | 0x100;
+
+        if (flags & 1)
+        {
+            mz_uint s0, s1, n0, n1, sym, num_extra_bits;
+            mz_uint match_len = pLZ_codes[0], match_dist = *(const mz_uint16 *)(pLZ_codes + 1);
+            pLZ_codes += 3;
+
+            MZ_ASSERT(d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]);
+            TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][s_tdefl_len_sym[match_len]], d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]);
+            TDEFL_PUT_BITS_FAST(match_len & mz_bitmasks[s_tdefl_len_extra[match_len]], s_tdefl_len_extra[match_len]);
+
+            /* This sequence coaxes MSVC into using cmov's vs. jmp's. */
+            s0 = s_tdefl_small_dist_sym[match_dist & 511];
+            n0 = s_tdefl_small_dist_extra[match_dist & 511];
+            s1 = s_tdefl_large_dist_sym[match_dist >> 8];
+            n1 = s_tdefl_large_dist_extra[match_dist >> 8];
+            sym = (match_dist < 512) ? s0 : s1;
+            num_extra_bits = (match_dist < 512) ? n0 : n1;
+
+            MZ_ASSERT(d->m_huff_code_sizes[1][sym]);
+            TDEFL_PUT_BITS_FAST(d->m_huff_codes[1][sym], d->m_huff_code_sizes[1][sym]);
+            TDEFL_PUT_BITS_FAST(match_dist & mz_bitmasks[num_extra_bits], num_extra_bits);
+        }
+        else
+        {
+            mz_uint lit = *pLZ_codes++;
+            MZ_ASSERT(d->m_huff_code_sizes[0][lit]);
+            TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]);
+
+            if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end))
+            {
+                flags >>= 1;
+                lit = *pLZ_codes++;
+                MZ_ASSERT(d->m_huff_code_sizes[0][lit]);
+                TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]);
+
+                if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end))
+                {
+                    flags >>= 1;
+                    lit = *pLZ_codes++;
+                    MZ_ASSERT(d->m_huff_code_sizes[0][lit]);
+                    TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]);
+                }
+            }
+        }
+
+        if (pOutput_buf >= d->m_pOutput_buf_end)
+            return MZ_FALSE;
+
+        *(mz_uint64 *)pOutput_buf = bit_buffer;
+        pOutput_buf += (bits_in >> 3);
+        bit_buffer >>= (bits_in & ~7);
+        bits_in &= 7;
+    }
+
+#undef TDEFL_PUT_BITS_FAST
+
+    d->m_pOutput_buf = pOutput_buf;
+    d->m_bits_in = 0;
+    d->m_bit_buffer = 0;
+
+    while (bits_in)
+    {
+        mz_uint32 n = MZ_MIN(bits_in, 16);
+        TDEFL_PUT_BITS((mz_uint)bit_buffer & mz_bitmasks[n], n);
+        bit_buffer >>= n;
+        bits_in -= n;
+    }
+
+    TDEFL_PUT_BITS(d->m_huff_codes[0][256], d->m_huff_code_sizes[0][256]);
+
+    return (d->m_pOutput_buf < d->m_pOutput_buf_end);
+}
+#else
+static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d)
+{
+    mz_uint flags;
+    mz_uint8 *pLZ_codes;
+
+    flags = 1;
+    for (pLZ_codes = d->m_lz_code_buf; pLZ_codes < d->m_pLZ_code_buf; flags >>= 1)
+    {
+        if (flags == 1)
+            flags = *pLZ_codes++ | 0x100;
+        if (flags & 1)
+        {
+            mz_uint sym, num_extra_bits;
+            mz_uint match_len = pLZ_codes[0], match_dist = (pLZ_codes[1] | (pLZ_codes[2] << 8));
+            pLZ_codes += 3;
+
+            MZ_ASSERT(d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]);
+            TDEFL_PUT_BITS(d->m_huff_codes[0][s_tdefl_len_sym[match_len]], d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]);
+            TDEFL_PUT_BITS(match_len & mz_bitmasks[s_tdefl_len_extra[match_len]], s_tdefl_len_extra[match_len]);
+
+            if (match_dist < 512)
+            {
+                sym = s_tdefl_small_dist_sym[match_dist];
+                num_extra_bits = s_tdefl_small_dist_extra[match_dist];
+            }
+            else
+            {
+                sym = s_tdefl_large_dist_sym[match_dist >> 8];
+                num_extra_bits = s_tdefl_large_dist_extra[match_dist >> 8];
+            }
+            MZ_ASSERT(d->m_huff_code_sizes[1][sym]);
+            TDEFL_PUT_BITS(d->m_huff_codes[1][sym], d->m_huff_code_sizes[1][sym]);
+            TDEFL_PUT_BITS(match_dist & mz_bitmasks[num_extra_bits], num_extra_bits);
+        }
+        else
+        {
+            mz_uint lit = *pLZ_codes++;
+            MZ_ASSERT(d->m_huff_code_sizes[0][lit]);
+            TDEFL_PUT_BITS(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]);
+        }
+    }
+
+    TDEFL_PUT_BITS(d->m_huff_codes[0][256], d->m_huff_code_sizes[0][256]);
+
+    return (d->m_pOutput_buf < d->m_pOutput_buf_end);
+}
+#endif /* MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN && MINIZ_HAS_64BIT_REGISTERS */
+
+static mz_bool tdefl_compress_block(tdefl_compressor *d, mz_bool static_block)
+{
+    if (static_block)
+        tdefl_start_static_block(d);
+    else
+        tdefl_start_dynamic_block(d);
+    return tdefl_compress_lz_codes(d);
+}
+
+static int tdefl_flush_block(tdefl_compressor *d, int flush)
+{
+    mz_uint saved_bit_buf, saved_bits_in;
+    mz_uint8 *pSaved_output_buf;
+    mz_bool comp_block_succeeded = MZ_FALSE;
+    int n, use_raw_block = ((d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS) != 0) && (d->m_lookahead_pos - d->m_lz_code_buf_dict_pos) <= d->m_dict_size;
+    mz_uint8 *pOutput_buf_start = ((d->m_pPut_buf_func == NULL) && ((*d->m_pOut_buf_size - d->m_out_buf_ofs) >= TDEFL_OUT_BUF_SIZE)) ? ((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs) : d->m_output_buf;
+
+    d->m_pOutput_buf = pOutput_buf_start;
+    d->m_pOutput_buf_end = d->m_pOutput_buf + TDEFL_OUT_BUF_SIZE - 16;
+
+    MZ_ASSERT(!d->m_output_flush_remaining);
+    d->m_output_flush_ofs = 0;
+    d->m_output_flush_remaining = 0;
+
+    *d->m_pLZ_flags = (mz_uint8)(*d->m_pLZ_flags >> d->m_num_flags_left);
+    d->m_pLZ_code_buf -= (d->m_num_flags_left == 8);
+
+    if ((d->m_flags & TDEFL_WRITE_ZLIB_HEADER) && (!d->m_block_index))
+    {
+        TDEFL_PUT_BITS(0x78, 8);
+        TDEFL_PUT_BITS(0x01, 8);
+    }
+
+    TDEFL_PUT_BITS(flush == TDEFL_FINISH, 1);
+
+    pSaved_output_buf = d->m_pOutput_buf;
+    saved_bit_buf = d->m_bit_buffer;
+    saved_bits_in = d->m_bits_in;
+
+    if (!use_raw_block)
+        comp_block_succeeded = tdefl_compress_block(d, (d->m_flags & TDEFL_FORCE_ALL_STATIC_BLOCKS) || (d->m_total_lz_bytes < 48));
+
+    /* If the block gets expanded, forget the current contents of the output buffer and send a raw block instead. */
+    if (((use_raw_block) || ((d->m_total_lz_bytes) && ((d->m_pOutput_buf - pSaved_output_buf + 1U) >= d->m_total_lz_bytes))) &&
+        ((d->m_lookahead_pos - d->m_lz_code_buf_dict_pos) <= d->m_dict_size))
+    {
+        mz_uint i;
+        d->m_pOutput_buf = pSaved_output_buf;
+        d->m_bit_buffer = saved_bit_buf, d->m_bits_in = saved_bits_in;
+        TDEFL_PUT_BITS(0, 2);
+        if (d->m_bits_in)
+        {
+            TDEFL_PUT_BITS(0, 8 - d->m_bits_in);
+        }
+        for (i = 2; i; --i, d->m_total_lz_bytes ^= 0xFFFF)
+        {
+            TDEFL_PUT_BITS(d->m_total_lz_bytes & 0xFFFF, 16);
+        }
+        for (i = 0; i < d->m_total_lz_bytes; ++i)
+        {
+            TDEFL_PUT_BITS(d->m_dict[(d->m_lz_code_buf_dict_pos + i) & TDEFL_LZ_DICT_SIZE_MASK], 8);
+        }
+    }
+    /* Check for the extremely unlikely (if not impossible) case of the compressed block not fitting into the output buffer when using dynamic codes. */
+    else if (!comp_block_succeeded)
+    {
+        d->m_pOutput_buf = pSaved_output_buf;
+        d->m_bit_buffer = saved_bit_buf, d->m_bits_in = saved_bits_in;
+        tdefl_compress_block(d, MZ_TRUE);
+    }
+
+    if (flush)
+    {
+        if (flush == TDEFL_FINISH)
+        {
+            if (d->m_bits_in)
+            {
+                TDEFL_PUT_BITS(0, 8 - d->m_bits_in);
+            }
+            if (d->m_flags & TDEFL_WRITE_ZLIB_HEADER)
+            {
+                mz_uint i, a = d->m_adler32;
+                for (i = 0; i < 4; i++)
+                {
+                    TDEFL_PUT_BITS((a >> 24) & 0xFF, 8);
+                    a <<= 8;
+                }
+            }
+        }
+        else
+        {
+            mz_uint i, z = 0;
+            TDEFL_PUT_BITS(0, 3);
+            if (d->m_bits_in)
+            {
+                TDEFL_PUT_BITS(0, 8 - d->m_bits_in);
+            }
+            for (i = 2; i; --i, z ^= 0xFFFF)
+            {
+                TDEFL_PUT_BITS(z & 0xFFFF, 16);
+            }
+        }
+    }
+
+    MZ_ASSERT(d->m_pOutput_buf < d->m_pOutput_buf_end);
+
+    memset(&d->m_huff_count[0][0], 0, sizeof(d->m_huff_count[0][0]) * TDEFL_MAX_HUFF_SYMBOLS_0);
+    memset(&d->m_huff_count[1][0], 0, sizeof(d->m_huff_count[1][0]) * TDEFL_MAX_HUFF_SYMBOLS_1);
+
+    d->m_pLZ_code_buf = d->m_lz_code_buf + 1;
+    d->m_pLZ_flags = d->m_lz_code_buf;
+    d->m_num_flags_left = 8;
+    d->m_lz_code_buf_dict_pos += d->m_total_lz_bytes;
+    d->m_total_lz_bytes = 0;
+    d->m_block_index++;
+
+    if ((n = (int)(d->m_pOutput_buf - pOutput_buf_start)) != 0)
+    {
+        if (d->m_pPut_buf_func)
+        {
+            *d->m_pIn_buf_size = d->m_pSrc - (const mz_uint8 *)d->m_pIn_buf;
+            if (!(*d->m_pPut_buf_func)(d->m_output_buf, n, d->m_pPut_buf_user))
+                return (d->m_prev_return_status = TDEFL_STATUS_PUT_BUF_FAILED);
+        }
+        else if (pOutput_buf_start == d->m_output_buf)
+        {
+            int bytes_to_copy = (int)MZ_MIN((size_t)n, (size_t)(*d->m_pOut_buf_size - d->m_out_buf_ofs));
+            memcpy((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs, d->m_output_buf, bytes_to_copy);
+            d->m_out_buf_ofs += bytes_to_copy;
+            if ((n -= bytes_to_copy) != 0)
+            {
+                d->m_output_flush_ofs = bytes_to_copy;
+                d->m_output_flush_remaining = n;
+            }
+        }
+        else
+        {
+            d->m_out_buf_ofs += n;
+        }
+    }
+
+    return d->m_output_flush_remaining;
+}
+
+#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES
+#ifdef MINIZ_UNALIGNED_USE_MEMCPY
+static inline mz_uint16 TDEFL_READ_UNALIGNED_WORD(const mz_uint8* p)
+{
+	mz_uint16 ret;
+	memcpy(&ret, p, sizeof(mz_uint16));
+	return ret;
+}
+static inline mz_uint16 TDEFL_READ_UNALIGNED_WORD2(const mz_uint16* p)
+{
+	mz_uint16 ret;
+	memcpy(&ret, p, sizeof(mz_uint16));
+	return ret;
+}
+#else
+#define TDEFL_READ_UNALIGNED_WORD(p) *(const mz_uint16 *)(p)
+#define TDEFL_READ_UNALIGNED_WORD2(p) *(const mz_uint16 *)(p)
+#endif
+static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor *d, mz_uint lookahead_pos, mz_uint max_dist, mz_uint max_match_len, mz_uint *pMatch_dist, mz_uint *pMatch_len)
+{
+    mz_uint dist, pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK, match_len = *pMatch_len, probe_pos = pos, next_probe_pos, probe_len;
+    mz_uint num_probes_left = d->m_max_probes[match_len >= 32];
+    const mz_uint16 *s = (const mz_uint16 *)(d->m_dict + pos), *p, *q;
+    mz_uint16 c01 = TDEFL_READ_UNALIGNED_WORD(&d->m_dict[pos + match_len - 1]), s01 = TDEFL_READ_UNALIGNED_WORD2(s);
+    MZ_ASSERT(max_match_len <= TDEFL_MAX_MATCH_LEN);
+    if (max_match_len <= match_len)
+        return;
+    for (;;)
+    {
+        for (;;)
+        {
+            if (--num_probes_left == 0)
+                return;
+#define TDEFL_PROBE                                                                             \
+    next_probe_pos = d->m_next[probe_pos];                                                      \
+    if ((!next_probe_pos) || ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist)) \
+        return;                                                                                 \
+    probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK;                                       \
+    if (TDEFL_READ_UNALIGNED_WORD(&d->m_dict[probe_pos + match_len - 1]) == c01)                \
+        break;
+            TDEFL_PROBE;
+            TDEFL_PROBE;
+            TDEFL_PROBE;
+        }
+        if (!dist)
+            break;
+        q = (const mz_uint16 *)(d->m_dict + probe_pos);
+        if (TDEFL_READ_UNALIGNED_WORD2(q) != s01)
+            continue;
+        p = s;
+        probe_len = 32;
+        do
+        {
+        } while ((TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && (TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) &&
+                 (TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && (TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && (--probe_len > 0));
+        if (!probe_len)
+        {
+            *pMatch_dist = dist;
+            *pMatch_len = MZ_MIN(max_match_len, (mz_uint)TDEFL_MAX_MATCH_LEN);
+            break;
+        }
+        else if ((probe_len = ((mz_uint)(p - s) * 2) + (mz_uint)(*(const mz_uint8 *)p == *(const mz_uint8 *)q)) > match_len)
+        {
+            *pMatch_dist = dist;
+            if ((*pMatch_len = match_len = MZ_MIN(max_match_len, probe_len)) == max_match_len)
+                break;
+            c01 = TDEFL_READ_UNALIGNED_WORD(&d->m_dict[pos + match_len - 1]);
+        }
+    }
+}
+#else
+static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor *d, mz_uint lookahead_pos, mz_uint max_dist, mz_uint max_match_len, mz_uint *pMatch_dist, mz_uint *pMatch_len)
+{
+    mz_uint dist, pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK, match_len = *pMatch_len, probe_pos = pos, next_probe_pos, probe_len;
+    mz_uint num_probes_left = d->m_max_probes[match_len >= 32];
+    const mz_uint8 *s = d->m_dict + pos, *p, *q;
+    mz_uint8 c0 = d->m_dict[pos + match_len], c1 = d->m_dict[pos + match_len - 1];
+    MZ_ASSERT(max_match_len <= TDEFL_MAX_MATCH_LEN);
+    if (max_match_len <= match_len)
+        return;
+    for (;;)
+    {
+        for (;;)
+        {
+            if (--num_probes_left == 0)
+                return;
+#define TDEFL_PROBE                                                                               \
+    next_probe_pos = d->m_next[probe_pos];                                                        \
+    if ((!next_probe_pos) || ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist))   \
+        return;                                                                                   \
+    probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK;                                         \
+    if ((d->m_dict[probe_pos + match_len] == c0) && (d->m_dict[probe_pos + match_len - 1] == c1)) \
+        break;
+            TDEFL_PROBE;
+            TDEFL_PROBE;
+            TDEFL_PROBE;
+        }
+        if (!dist)
+            break;
+        p = s;
+        q = d->m_dict + probe_pos;
+        for (probe_len = 0; probe_len < max_match_len; probe_len++)
+            if (*p++ != *q++)
+                break;
+        if (probe_len > match_len)
+        {
+            *pMatch_dist = dist;
+            if ((*pMatch_len = match_len = probe_len) == max_match_len)
+                return;
+            c0 = d->m_dict[pos + match_len];
+            c1 = d->m_dict[pos + match_len - 1];
+        }
+    }
+}
+#endif /* #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES */
+
+#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN
+static mz_bool tdefl_compress_fast(tdefl_compressor *d)
+{
+    /* Faster, minimally featured LZRW1-style match+parse loop with better register utilization. Intended for applications where raw throughput is valued more highly than ratio. */
+    mz_uint lookahead_pos = d->m_lookahead_pos, lookahead_size = d->m_lookahead_size, dict_size = d->m_dict_size, total_lz_bytes = d->m_total_lz_bytes, num_flags_left = d->m_num_flags_left;
+    mz_uint8 *pLZ_code_buf = d->m_pLZ_code_buf, *pLZ_flags = d->m_pLZ_flags;
+    mz_uint cur_pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK;
+
+    while ((d->m_src_buf_left) || ((d->m_flush) && (lookahead_size)))
+    {
+        const mz_uint TDEFL_COMP_FAST_LOOKAHEAD_SIZE = 4096;
+        mz_uint dst_pos = (lookahead_pos + lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK;
+        mz_uint num_bytes_to_process = (mz_uint)MZ_MIN(d->m_src_buf_left, TDEFL_COMP_FAST_LOOKAHEAD_SIZE - lookahead_size);
+        d->m_src_buf_left -= num_bytes_to_process;
+        lookahead_size += num_bytes_to_process;
+
+        while (num_bytes_to_process)
+        {
+            mz_uint32 n = MZ_MIN(TDEFL_LZ_DICT_SIZE - dst_pos, num_bytes_to_process);
+            memcpy(d->m_dict + dst_pos, d->m_pSrc, n);
+            if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1))
+                memcpy(d->m_dict + TDEFL_LZ_DICT_SIZE + dst_pos, d->m_pSrc, MZ_MIN(n, (TDEFL_MAX_MATCH_LEN - 1) - dst_pos));
+            d->m_pSrc += n;
+            dst_pos = (dst_pos + n) & TDEFL_LZ_DICT_SIZE_MASK;
+            num_bytes_to_process -= n;
+        }
+
+        dict_size = MZ_MIN(TDEFL_LZ_DICT_SIZE - lookahead_size, dict_size);
+        if ((!d->m_flush) && (lookahead_size < TDEFL_COMP_FAST_LOOKAHEAD_SIZE))
+            break;
+
+        while (lookahead_size >= 4)
+        {
+            mz_uint cur_match_dist, cur_match_len = 1;
+            mz_uint8 *pCur_dict = d->m_dict + cur_pos;
+            mz_uint first_trigram = (*(const mz_uint32 *)pCur_dict) & 0xFFFFFF;
+            mz_uint hash = (first_trigram ^ (first_trigram >> (24 - (TDEFL_LZ_HASH_BITS - 8)))) & TDEFL_LEVEL1_HASH_SIZE_MASK;
+            mz_uint probe_pos = d->m_hash[hash];
+            d->m_hash[hash] = (mz_uint16)lookahead_pos;
+
+            if (((cur_match_dist = (mz_uint16)(lookahead_pos - probe_pos)) <= dict_size) && ((*(const mz_uint32 *)(d->m_dict + (probe_pos &= TDEFL_LZ_DICT_SIZE_MASK)) & 0xFFFFFF) == first_trigram))
+            {
+                const mz_uint16 *p = (const mz_uint16 *)pCur_dict;
+                const mz_uint16 *q = (const mz_uint16 *)(d->m_dict + probe_pos);
+                mz_uint32 probe_len = 32;
+                do
+                {
+                } while ((TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && (TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) &&
+                         (TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && (TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && (--probe_len > 0));
+                cur_match_len = ((mz_uint)(p - (const mz_uint16 *)pCur_dict) * 2) + (mz_uint)(*(const mz_uint8 *)p == *(const mz_uint8 *)q);
+                if (!probe_len)
+                    cur_match_len = cur_match_dist ? TDEFL_MAX_MATCH_LEN : 0;
+
+                if ((cur_match_len < TDEFL_MIN_MATCH_LEN) || ((cur_match_len == TDEFL_MIN_MATCH_LEN) && (cur_match_dist >= 8U * 1024U)))
+                {
+                    cur_match_len = 1;
+                    *pLZ_code_buf++ = (mz_uint8)first_trigram;
+                    *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1);
+                    d->m_huff_count[0][(mz_uint8)first_trigram]++;
+                }
+                else
+                {
+                    mz_uint32 s0, s1;
+                    cur_match_len = MZ_MIN(cur_match_len, lookahead_size);
+
+                    MZ_ASSERT((cur_match_len >= TDEFL_MIN_MATCH_LEN) && (cur_match_dist >= 1) && (cur_match_dist <= TDEFL_LZ_DICT_SIZE));
+
+                    cur_match_dist--;
+
+                    pLZ_code_buf[0] = (mz_uint8)(cur_match_len - TDEFL_MIN_MATCH_LEN);
+                    *(mz_uint16 *)(&pLZ_code_buf[1]) = (mz_uint16)cur_match_dist;
+                    pLZ_code_buf += 3;
+                    *pLZ_flags = (mz_uint8)((*pLZ_flags >> 1) | 0x80);
+
+                    s0 = s_tdefl_small_dist_sym[cur_match_dist & 511];
+                    s1 = s_tdefl_large_dist_sym[cur_match_dist >> 8];
+                    d->m_huff_count[1][(cur_match_dist < 512) ? s0 : s1]++;
+
+                    d->m_huff_count[0][s_tdefl_len_sym[cur_match_len - TDEFL_MIN_MATCH_LEN]]++;
+                }
+            }
+            else
+            {
+                *pLZ_code_buf++ = (mz_uint8)first_trigram;
+                *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1);
+                d->m_huff_count[0][(mz_uint8)first_trigram]++;
+            }
+
+            if (--num_flags_left == 0)
+            {
+                num_flags_left = 8;
+                pLZ_flags = pLZ_code_buf++;
+            }
+
+            total_lz_bytes += cur_match_len;
+            lookahead_pos += cur_match_len;
+            dict_size = MZ_MIN(dict_size + cur_match_len, (mz_uint)TDEFL_LZ_DICT_SIZE);
+            cur_pos = (cur_pos + cur_match_len) & TDEFL_LZ_DICT_SIZE_MASK;
+            MZ_ASSERT(lookahead_size >= cur_match_len);
+            lookahead_size -= cur_match_len;
+
+            if (pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8])
+            {
+                int n;
+                d->m_lookahead_pos = lookahead_pos;
+                d->m_lookahead_size = lookahead_size;
+                d->m_dict_size = dict_size;
+                d->m_total_lz_bytes = total_lz_bytes;
+                d->m_pLZ_code_buf = pLZ_code_buf;
+                d->m_pLZ_flags = pLZ_flags;
+                d->m_num_flags_left = num_flags_left;
+                if ((n = tdefl_flush_block(d, 0)) != 0)
+                    return (n < 0) ? MZ_FALSE : MZ_TRUE;
+                total_lz_bytes = d->m_total_lz_bytes;
+                pLZ_code_buf = d->m_pLZ_code_buf;
+                pLZ_flags = d->m_pLZ_flags;
+                num_flags_left = d->m_num_flags_left;
+            }
+        }
+
+        while (lookahead_size)
+        {
+            mz_uint8 lit = d->m_dict[cur_pos];
+
+            total_lz_bytes++;
+            *pLZ_code_buf++ = lit;
+            *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1);
+            if (--num_flags_left == 0)
+            {
+                num_flags_left = 8;
+                pLZ_flags = pLZ_code_buf++;
+            }
+
+            d->m_huff_count[0][lit]++;
+
+            lookahead_pos++;
+            dict_size = MZ_MIN(dict_size + 1, (mz_uint)TDEFL_LZ_DICT_SIZE);
+            cur_pos = (cur_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK;
+            lookahead_size--;
+
+            if (pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8])
+            {
+                int n;
+                d->m_lookahead_pos = lookahead_pos;
+                d->m_lookahead_size = lookahead_size;
+                d->m_dict_size = dict_size;
+                d->m_total_lz_bytes = total_lz_bytes;
+                d->m_pLZ_code_buf = pLZ_code_buf;
+                d->m_pLZ_flags = pLZ_flags;
+                d->m_num_flags_left = num_flags_left;
+                if ((n = tdefl_flush_block(d, 0)) != 0)
+                    return (n < 0) ? MZ_FALSE : MZ_TRUE;
+                total_lz_bytes = d->m_total_lz_bytes;
+                pLZ_code_buf = d->m_pLZ_code_buf;
+                pLZ_flags = d->m_pLZ_flags;
+                num_flags_left = d->m_num_flags_left;
+            }
+        }
+    }
+
+    d->m_lookahead_pos = lookahead_pos;
+    d->m_lookahead_size = lookahead_size;
+    d->m_dict_size = dict_size;
+    d->m_total_lz_bytes = total_lz_bytes;
+    d->m_pLZ_code_buf = pLZ_code_buf;
+    d->m_pLZ_flags = pLZ_flags;
+    d->m_num_flags_left = num_flags_left;
+    return MZ_TRUE;
+}
+#endif /* MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN */
+
+static MZ_FORCEINLINE void tdefl_record_literal(tdefl_compressor *d, mz_uint8 lit)
+{
+    d->m_total_lz_bytes++;
+    *d->m_pLZ_code_buf++ = lit;
+    *d->m_pLZ_flags = (mz_uint8)(*d->m_pLZ_flags >> 1);
+    if (--d->m_num_flags_left == 0)
+    {
+        d->m_num_flags_left = 8;
+        d->m_pLZ_flags = d->m_pLZ_code_buf++;
+    }
+    d->m_huff_count[0][lit]++;
+}
+
+static MZ_FORCEINLINE void tdefl_record_match(tdefl_compressor *d, mz_uint match_len, mz_uint match_dist)
+{
+    mz_uint32 s0, s1;
+
+    MZ_ASSERT((match_len >= TDEFL_MIN_MATCH_LEN) && (match_dist >= 1) && (match_dist <= TDEFL_LZ_DICT_SIZE));
+
+    d->m_total_lz_bytes += match_len;
+
+    d->m_pLZ_code_buf[0] = (mz_uint8)(match_len - TDEFL_MIN_MATCH_LEN);
+
+    match_dist -= 1;
+    d->m_pLZ_code_buf[1] = (mz_uint8)(match_dist & 0xFF);
+    d->m_pLZ_code_buf[2] = (mz_uint8)(match_dist >> 8);
+    d->m_pLZ_code_buf += 3;
+
+    *d->m_pLZ_flags = (mz_uint8)((*d->m_pLZ_flags >> 1) | 0x80);
+    if (--d->m_num_flags_left == 0)
+    {
+        d->m_num_flags_left = 8;
+        d->m_pLZ_flags = d->m_pLZ_code_buf++;
+    }
+
+    s0 = s_tdefl_small_dist_sym[match_dist & 511];
+    s1 = s_tdefl_large_dist_sym[(match_dist >> 8) & 127];
+    d->m_huff_count[1][(match_dist < 512) ? s0 : s1]++;
+
+    if (match_len >= TDEFL_MIN_MATCH_LEN)
+        d->m_huff_count[0][s_tdefl_len_sym[match_len - TDEFL_MIN_MATCH_LEN]]++;
+}
+
+static mz_bool tdefl_compress_normal(tdefl_compressor *d)
+{
+    const mz_uint8 *pSrc = d->m_pSrc;
+    size_t src_buf_left = d->m_src_buf_left;
+    tdefl_flush flush = d->m_flush;
+
+    while ((src_buf_left) || ((flush) && (d->m_lookahead_size)))
+    {
+        mz_uint len_to_move, cur_match_dist, cur_match_len, cur_pos;
+        /* Update dictionary and hash chains. Keeps the lookahead size equal to TDEFL_MAX_MATCH_LEN. */
+        if ((d->m_lookahead_size + d->m_dict_size) >= (TDEFL_MIN_MATCH_LEN - 1))
+        {
+            mz_uint dst_pos = (d->m_lookahead_pos + d->m_lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK, ins_pos = d->m_lookahead_pos + d->m_lookahead_size - 2;
+            mz_uint hash = (d->m_dict[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] << TDEFL_LZ_HASH_SHIFT) ^ d->m_dict[(ins_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK];
+            mz_uint num_bytes_to_process = (mz_uint)MZ_MIN(src_buf_left, TDEFL_MAX_MATCH_LEN - d->m_lookahead_size);
+            const mz_uint8 *pSrc_end = pSrc + num_bytes_to_process;
+            src_buf_left -= num_bytes_to_process;
+            d->m_lookahead_size += num_bytes_to_process;
+            while (pSrc != pSrc_end)
+            {
+                mz_uint8 c = *pSrc++;
+                d->m_dict[dst_pos] = c;
+                if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1))
+                    d->m_dict[TDEFL_LZ_DICT_SIZE + dst_pos] = c;
+                hash = ((hash << TDEFL_LZ_HASH_SHIFT) ^ c) & (TDEFL_LZ_HASH_SIZE - 1);
+                d->m_next[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] = d->m_hash[hash];
+                d->m_hash[hash] = (mz_uint16)(ins_pos);
+                dst_pos = (dst_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK;
+                ins_pos++;
+            }
+        }
+        else
+        {
+            while ((src_buf_left) && (d->m_lookahead_size < TDEFL_MAX_MATCH_LEN))
+            {
+                mz_uint8 c = *pSrc++;
+                mz_uint dst_pos = (d->m_lookahead_pos + d->m_lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK;
+                src_buf_left--;
+                d->m_dict[dst_pos] = c;
+                if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1))
+                    d->m_dict[TDEFL_LZ_DICT_SIZE + dst_pos] = c;
+                if ((++d->m_lookahead_size + d->m_dict_size) >= TDEFL_MIN_MATCH_LEN)
+                {
+                    mz_uint ins_pos = d->m_lookahead_pos + (d->m_lookahead_size - 1) - 2;
+                    mz_uint hash = ((d->m_dict[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] << (TDEFL_LZ_HASH_SHIFT * 2)) ^ (d->m_dict[(ins_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK] << TDEFL_LZ_HASH_SHIFT) ^ c) & (TDEFL_LZ_HASH_SIZE - 1);
+                    d->m_next[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] = d->m_hash[hash];
+                    d->m_hash[hash] = (mz_uint16)(ins_pos);
+                }
+            }
+        }
+        d->m_dict_size = MZ_MIN(TDEFL_LZ_DICT_SIZE - d->m_lookahead_size, d->m_dict_size);
+        if ((!flush) && (d->m_lookahead_size < TDEFL_MAX_MATCH_LEN))
+            break;
+
+        /* Simple lazy/greedy parsing state machine. */
+        len_to_move = 1;
+        cur_match_dist = 0;
+        cur_match_len = d->m_saved_match_len ? d->m_saved_match_len : (TDEFL_MIN_MATCH_LEN - 1);
+        cur_pos = d->m_lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK;
+        if (d->m_flags & (TDEFL_RLE_MATCHES | TDEFL_FORCE_ALL_RAW_BLOCKS))
+        {
+            if ((d->m_dict_size) && (!(d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS)))
+            {
+                mz_uint8 c = d->m_dict[(cur_pos - 1) & TDEFL_LZ_DICT_SIZE_MASK];
+                cur_match_len = 0;
+                while (cur_match_len < d->m_lookahead_size)
+                {
+                    if (d->m_dict[cur_pos + cur_match_len] != c)
+                        break;
+                    cur_match_len++;
+                }
+                if (cur_match_len < TDEFL_MIN_MATCH_LEN)
+                    cur_match_len = 0;
+                else
+                    cur_match_dist = 1;
+            }
+        }
+        else
+        {
+            tdefl_find_match(d, d->m_lookahead_pos, d->m_dict_size, d->m_lookahead_size, &cur_match_dist, &cur_match_len);
+        }
+        if (((cur_match_len == TDEFL_MIN_MATCH_LEN) && (cur_match_dist >= 8U * 1024U)) || (cur_pos == cur_match_dist) || ((d->m_flags & TDEFL_FILTER_MATCHES) && (cur_match_len <= 5)))
+        {
+            cur_match_dist = cur_match_len = 0;
+        }
+        if (d->m_saved_match_len)
+        {
+            if (cur_match_len > d->m_saved_match_len)
+            {
+                tdefl_record_literal(d, (mz_uint8)d->m_saved_lit);
+                if (cur_match_len >= 128)
+                {
+                    tdefl_record_match(d, cur_match_len, cur_match_dist);
+                    d->m_saved_match_len = 0;
+                    len_to_move = cur_match_len;
+                }
+                else
+                {
+                    d->m_saved_lit = d->m_dict[cur_pos];
+                    d->m_saved_match_dist = cur_match_dist;
+                    d->m_saved_match_len = cur_match_len;
+                }
+            }
+            else
+            {
+                tdefl_record_match(d, d->m_saved_match_len, d->m_saved_match_dist);
+                len_to_move = d->m_saved_match_len - 1;
+                d->m_saved_match_len = 0;
+            }
+        }
+        else if (!cur_match_dist)
+            tdefl_record_literal(d, d->m_dict[MZ_MIN(cur_pos, sizeof(d->m_dict) - 1)]);
+        else if ((d->m_greedy_parsing) || (d->m_flags & TDEFL_RLE_MATCHES) || (cur_match_len >= 128))
+        {
+            tdefl_record_match(d, cur_match_len, cur_match_dist);
+            len_to_move = cur_match_len;
+        }
+        else
+        {
+            d->m_saved_lit = d->m_dict[MZ_MIN(cur_pos, sizeof(d->m_dict) - 1)];
+            d->m_saved_match_dist = cur_match_dist;
+            d->m_saved_match_len = cur_match_len;
+        }
+        /* Move the lookahead forward by len_to_move bytes. */
+        d->m_lookahead_pos += len_to_move;
+        MZ_ASSERT(d->m_lookahead_size >= len_to_move);
+        d->m_lookahead_size -= len_to_move;
+        d->m_dict_size = MZ_MIN(d->m_dict_size + len_to_move, (mz_uint)TDEFL_LZ_DICT_SIZE);
+        /* Check if it's time to flush the current LZ codes to the internal output buffer. */
+        if ((d->m_pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8]) ||
+            ((d->m_total_lz_bytes > 31 * 1024) && (((((mz_uint)(d->m_pLZ_code_buf - d->m_lz_code_buf) * 115) >> 7) >= d->m_total_lz_bytes) || (d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS))))
+        {
+            int n;
+            d->m_pSrc = pSrc;
+            d->m_src_buf_left = src_buf_left;
+            if ((n = tdefl_flush_block(d, 0)) != 0)
+                return (n < 0) ? MZ_FALSE : MZ_TRUE;
+        }
+    }
+
+    d->m_pSrc = pSrc;
+    d->m_src_buf_left = src_buf_left;
+    return MZ_TRUE;
+}
+
+static tdefl_status tdefl_flush_output_buffer(tdefl_compressor *d)
+{
+    if (d->m_pIn_buf_size)
+    {
+        *d->m_pIn_buf_size = d->m_pSrc - (const mz_uint8 *)d->m_pIn_buf;
+    }
+
+    if (d->m_pOut_buf_size)
+    {
+        size_t n = MZ_MIN(*d->m_pOut_buf_size - d->m_out_buf_ofs, d->m_output_flush_remaining);
+        memcpy((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs, d->m_output_buf + d->m_output_flush_ofs, n);
+        d->m_output_flush_ofs += (mz_uint)n;
+        d->m_output_flush_remaining -= (mz_uint)n;
+        d->m_out_buf_ofs += n;
+
+        *d->m_pOut_buf_size = d->m_out_buf_ofs;
+    }
+
+    return (d->m_finished && !d->m_output_flush_remaining) ? TDEFL_STATUS_DONE : TDEFL_STATUS_OKAY;
+}
+
+tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf, size_t *pIn_buf_size, void *pOut_buf, size_t *pOut_buf_size, tdefl_flush flush)
+{
+    if (!d)
+    {
+        if (pIn_buf_size)
+            *pIn_buf_size = 0;
+        if (pOut_buf_size)
+            *pOut_buf_size = 0;
+        return TDEFL_STATUS_BAD_PARAM;
+    }
+
+    d->m_pIn_buf = pIn_buf;
+    d->m_pIn_buf_size = pIn_buf_size;
+    d->m_pOut_buf = pOut_buf;
+    d->m_pOut_buf_size = pOut_buf_size;
+    d->m_pSrc = (const mz_uint8 *)(pIn_buf);
+    d->m_src_buf_left = pIn_buf_size ? *pIn_buf_size : 0;
+    d->m_out_buf_ofs = 0;
+    d->m_flush = flush;
+
+    if (((d->m_pPut_buf_func != NULL) == ((pOut_buf != NULL) || (pOut_buf_size != NULL))) || (d->m_prev_return_status != TDEFL_STATUS_OKAY) ||
+        (d->m_wants_to_finish && (flush != TDEFL_FINISH)) || (pIn_buf_size && *pIn_buf_size && !pIn_buf) || (pOut_buf_size && *pOut_buf_size && !pOut_buf))
+    {
+        if (pIn_buf_size)
+            *pIn_buf_size = 0;
+        if (pOut_buf_size)
+            *pOut_buf_size = 0;
+        return (d->m_prev_return_status = TDEFL_STATUS_BAD_PARAM);
+    }
+    d->m_wants_to_finish |= (flush == TDEFL_FINISH);
+
+    if ((d->m_output_flush_remaining) || (d->m_finished))
+        return (d->m_prev_return_status = tdefl_flush_output_buffer(d));
+
+#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN
+    if (((d->m_flags & TDEFL_MAX_PROBES_MASK) == 1) &&
+        ((d->m_flags & TDEFL_GREEDY_PARSING_FLAG) != 0) &&
+        ((d->m_flags & (TDEFL_FILTER_MATCHES | TDEFL_FORCE_ALL_RAW_BLOCKS | TDEFL_RLE_MATCHES)) == 0))
+    {
+        if (!tdefl_compress_fast(d))
+            return d->m_prev_return_status;
+    }
+    else
+#endif /* #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN */
+    {
+        if (!tdefl_compress_normal(d))
+            return d->m_prev_return_status;
+    }
+
+    if ((d->m_flags & (TDEFL_WRITE_ZLIB_HEADER | TDEFL_COMPUTE_ADLER32)) && (pIn_buf))
+        d->m_adler32 = (mz_uint32)mz_adler32(d->m_adler32, (const mz_uint8 *)pIn_buf, d->m_pSrc - (const mz_uint8 *)pIn_buf);
+
+    if ((flush) && (!d->m_lookahead_size) && (!d->m_src_buf_left) && (!d->m_output_flush_remaining))
+    {
+        if (tdefl_flush_block(d, flush) < 0)
+            return d->m_prev_return_status;
+        d->m_finished = (flush == TDEFL_FINISH);
+        if (flush == TDEFL_FULL_FLUSH)
+        {
+            MZ_CLEAR_OBJ(d->m_hash);
+            MZ_CLEAR_OBJ(d->m_next);
+            d->m_dict_size = 0;
+        }
+    }
+
+    return (d->m_prev_return_status = tdefl_flush_output_buffer(d));
+}
+
+tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, size_t in_buf_size, tdefl_flush flush)
+{
+    MZ_ASSERT(d->m_pPut_buf_func);
+    return tdefl_compress(d, pIn_buf, &in_buf_size, NULL, NULL, flush);
+}
+
+tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags)
+{
+    d->m_pPut_buf_func = pPut_buf_func;
+    d->m_pPut_buf_user = pPut_buf_user;
+    d->m_flags = (mz_uint)(flags);
+    d->m_max_probes[0] = 1 + ((flags & 0xFFF) + 2) / 3;
+    d->m_greedy_parsing = (flags & TDEFL_GREEDY_PARSING_FLAG) != 0;
+    d->m_max_probes[1] = 1 + (((flags & 0xFFF) >> 2) + 2) / 3;
+    if (!(flags & TDEFL_NONDETERMINISTIC_PARSING_FLAG))
+        MZ_CLEAR_OBJ(d->m_hash);
+    d->m_lookahead_pos = d->m_lookahead_size = d->m_dict_size = d->m_total_lz_bytes = d->m_lz_code_buf_dict_pos = d->m_bits_in = 0;
+    d->m_output_flush_ofs = d->m_output_flush_remaining = d->m_finished = d->m_block_index = d->m_bit_buffer = d->m_wants_to_finish = 0;
+    d->m_pLZ_code_buf = d->m_lz_code_buf + 1;
+    d->m_pLZ_flags = d->m_lz_code_buf;
+    d->m_num_flags_left = 8;
+    d->m_pOutput_buf = d->m_output_buf;
+    d->m_pOutput_buf_end = d->m_output_buf;
+    d->m_prev_return_status = TDEFL_STATUS_OKAY;
+    d->m_saved_match_dist = d->m_saved_match_len = d->m_saved_lit = 0;
+    d->m_adler32 = 1;
+    d->m_pIn_buf = NULL;
+    d->m_pOut_buf = NULL;
+    d->m_pIn_buf_size = NULL;
+    d->m_pOut_buf_size = NULL;
+    d->m_flush = TDEFL_NO_FLUSH;
+    d->m_pSrc = NULL;
+    d->m_src_buf_left = 0;
+    d->m_out_buf_ofs = 0;
+    if (!(flags & TDEFL_NONDETERMINISTIC_PARSING_FLAG))
+        MZ_CLEAR_OBJ(d->m_dict);
+    memset(&d->m_huff_count[0][0], 0, sizeof(d->m_huff_count[0][0]) * TDEFL_MAX_HUFF_SYMBOLS_0);
+    memset(&d->m_huff_count[1][0], 0, sizeof(d->m_huff_count[1][0]) * TDEFL_MAX_HUFF_SYMBOLS_1);
+    return TDEFL_STATUS_OKAY;
+}
+
+tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d)
+{
+    return d->m_prev_return_status;
+}
+
+mz_uint32 tdefl_get_adler32(tdefl_compressor *d)
+{
+    return d->m_adler32;
+}
+
+mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags)
+{
+    tdefl_compressor *pComp;
+    mz_bool succeeded;
+    if (((buf_len) && (!pBuf)) || (!pPut_buf_func))
+        return MZ_FALSE;
+    pComp = (tdefl_compressor *)MZ_MALLOC(sizeof(tdefl_compressor));
+    if (!pComp)
+        return MZ_FALSE;
+    succeeded = (tdefl_init(pComp, pPut_buf_func, pPut_buf_user, flags) == TDEFL_STATUS_OKAY);
+    succeeded = succeeded && (tdefl_compress_buffer(pComp, pBuf, buf_len, TDEFL_FINISH) == TDEFL_STATUS_DONE);
+    MZ_FREE(pComp);
+    return succeeded;
+}
+
+typedef struct
+{
+    size_t m_size, m_capacity;
+    mz_uint8 *m_pBuf;
+    mz_bool m_expandable;
+} tdefl_output_buffer;
+
+static mz_bool tdefl_output_buffer_putter(const void *pBuf, int len, void *pUser)
+{
+    tdefl_output_buffer *p = (tdefl_output_buffer *)pUser;
+    size_t new_size = p->m_size + len;
+    if (new_size > p->m_capacity)
+    {
+        size_t new_capacity = p->m_capacity;
+        mz_uint8 *pNew_buf;
+        if (!p->m_expandable)
+            return MZ_FALSE;
+        do
+        {
+            new_capacity = MZ_MAX(128U, new_capacity << 1U);
+        } while (new_size > new_capacity);
+        pNew_buf = (mz_uint8 *)MZ_REALLOC(p->m_pBuf, new_capacity);
+        if (!pNew_buf)
+            return MZ_FALSE;
+        p->m_pBuf = pNew_buf;
+        p->m_capacity = new_capacity;
+    }
+    memcpy((mz_uint8 *)p->m_pBuf + p->m_size, pBuf, len);
+    p->m_size = new_size;
+    return MZ_TRUE;
+}
+
+void *tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags)
+{
+    tdefl_output_buffer out_buf;
+    MZ_CLEAR_OBJ(out_buf);
+    if (!pOut_len)
+        return MZ_FALSE;
+    else
+        *pOut_len = 0;
+    out_buf.m_expandable = MZ_TRUE;
+    if (!tdefl_compress_mem_to_output(pSrc_buf, src_buf_len, tdefl_output_buffer_putter, &out_buf, flags))
+        return NULL;
+    *pOut_len = out_buf.m_size;
+    return out_buf.m_pBuf;
+}
+
+size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags)
+{
+    tdefl_output_buffer out_buf;
+    MZ_CLEAR_OBJ(out_buf);
+    if (!pOut_buf)
+        return 0;
+    out_buf.m_pBuf = (mz_uint8 *)pOut_buf;
+    out_buf.m_capacity = out_buf_len;
+    if (!tdefl_compress_mem_to_output(pSrc_buf, src_buf_len, tdefl_output_buffer_putter, &out_buf, flags))
+        return 0;
+    return out_buf.m_size;
+}
+
+static const mz_uint s_tdefl_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 };
+
+/* level may actually range from [0,10] (10 is a "hidden" max level, where we want a bit more compression and it's fine if throughput to fall off a cliff on some files). */
+mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy)
+{
+    mz_uint comp_flags = s_tdefl_num_probes[(level >= 0) ? MZ_MIN(10, level) : MZ_DEFAULT_LEVEL] | ((level <= 3) ? TDEFL_GREEDY_PARSING_FLAG : 0);
+    if (window_bits > 0)
+        comp_flags |= TDEFL_WRITE_ZLIB_HEADER;
+
+    if (!level)
+        comp_flags |= TDEFL_FORCE_ALL_RAW_BLOCKS;
+    else if (strategy == MZ_FILTERED)
+        comp_flags |= TDEFL_FILTER_MATCHES;
+    else if (strategy == MZ_HUFFMAN_ONLY)
+        comp_flags &= ~TDEFL_MAX_PROBES_MASK;
+    else if (strategy == MZ_FIXED)
+        comp_flags |= TDEFL_FORCE_ALL_STATIC_BLOCKS;
+    else if (strategy == MZ_RLE)
+        comp_flags |= TDEFL_RLE_MATCHES;
+
+    return comp_flags;
+}
+
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable : 4204) /* nonstandard extension used : non-constant aggregate initializer (also supported by GNU C and C99, so no big deal) */
+#endif
+
+/* Simple PNG writer function by Alex Evans, 2011. Released into the public domain: https://gist.github.com/908299, more context at
+ http://altdevblogaday.org/2011/04/06/a-smaller-jpg-encoder/.
+ This is actually a modification of Alex's original code so PNG files generated by this function pass pngcheck. */
+void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w, int h, int num_chans, size_t *pLen_out, mz_uint level, mz_bool flip)
+{
+    /* Using a local copy of this array here in case MINIZ_NO_ZLIB_APIS was defined. */
+    static const mz_uint s_tdefl_png_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 };
+    tdefl_compressor *pComp = (tdefl_compressor *)MZ_MALLOC(sizeof(tdefl_compressor));
+    tdefl_output_buffer out_buf;
+    int i, bpl = w * num_chans, y, z;
+    mz_uint32 c;
+    *pLen_out = 0;
+    if (!pComp)
+        return NULL;
+    MZ_CLEAR_OBJ(out_buf);
+    out_buf.m_expandable = MZ_TRUE;
+    out_buf.m_capacity = 57 + MZ_MAX(64, (1 + bpl) * h);
+    if (NULL == (out_buf.m_pBuf = (mz_uint8 *)MZ_MALLOC(out_buf.m_capacity)))
+    {
+        MZ_FREE(pComp);
+        return NULL;
+    }
+    /* write dummy header */
+    for (z = 41; z; --z)
+        tdefl_output_buffer_putter(&z, 1, &out_buf);
+    /* compress image data */
+    tdefl_init(pComp, tdefl_output_buffer_putter, &out_buf, s_tdefl_png_num_probes[MZ_MIN(10, level)] | TDEFL_WRITE_ZLIB_HEADER);
+    for (y = 0; y < h; ++y)
+    {
+        tdefl_compress_buffer(pComp, &z, 1, TDEFL_NO_FLUSH);
+        tdefl_compress_buffer(pComp, (mz_uint8 *)pImage + (flip ? (h - 1 - y) : y) * bpl, bpl, TDEFL_NO_FLUSH);
+    }
+    if (tdefl_compress_buffer(pComp, NULL, 0, TDEFL_FINISH) != TDEFL_STATUS_DONE)
+    {
+        MZ_FREE(pComp);
+        MZ_FREE(out_buf.m_pBuf);
+        return NULL;
+    }
+    /* write real header */
+    *pLen_out = out_buf.m_size - 41;
+    {
+        static const mz_uint8 chans[] = { 0x00, 0x00, 0x04, 0x02, 0x06 };
+        mz_uint8 pnghdr[41] = { 0x89, 0x50, 0x4e, 0x47, 0x0d,
+                                0x0a, 0x1a, 0x0a, 0x00, 0x00,
+                                0x00, 0x0d, 0x49, 0x48, 0x44,
+                                0x52, 0x00, 0x00, 0x00, 0x00,
+                                0x00, 0x00, 0x00, 0x00, 0x08,
+                                0x00, 0x00, 0x00, 0x00, 0x00,
+                                0x00, 0x00, 0x00, 0x00, 0x00,
+                                0x00, 0x00, 0x49, 0x44, 0x41,
+                                0x54 };
+        pnghdr[18] = (mz_uint8)(w >> 8);
+        pnghdr[19] = (mz_uint8)w;
+        pnghdr[22] = (mz_uint8)(h >> 8);
+        pnghdr[23] = (mz_uint8)h;
+        pnghdr[25] = chans[num_chans];
+        pnghdr[33] = (mz_uint8)(*pLen_out >> 24);
+        pnghdr[34] = (mz_uint8)(*pLen_out >> 16);
+        pnghdr[35] = (mz_uint8)(*pLen_out >> 8);
+        pnghdr[36] = (mz_uint8)*pLen_out;
+        c = (mz_uint32)mz_crc32(MZ_CRC32_INIT, pnghdr + 12, 17);
+        for (i = 0; i < 4; ++i, c <<= 8)
+            ((mz_uint8 *)(pnghdr + 29))[i] = (mz_uint8)(c >> 24);
+        memcpy(out_buf.m_pBuf, pnghdr, 41);
+    }
+    /* write footer (IDAT CRC-32, followed by IEND chunk) */
+    if (!tdefl_output_buffer_putter("\0\0\0\0\0\0\0\0\x49\x45\x4e\x44\xae\x42\x60\x82", 16, &out_buf))
+    {
+        *pLen_out = 0;
+        MZ_FREE(pComp);
+        MZ_FREE(out_buf.m_pBuf);
+        return NULL;
+    }
+    c = (mz_uint32)mz_crc32(MZ_CRC32_INIT, out_buf.m_pBuf + 41 - 4, *pLen_out + 4);
+    for (i = 0; i < 4; ++i, c <<= 8)
+        (out_buf.m_pBuf + out_buf.m_size - 16)[i] = (mz_uint8)(c >> 24);
+    /* compute final size of file, grab compressed data buffer and return */
+    *pLen_out += 57;
+    MZ_FREE(pComp);
+    return out_buf.m_pBuf;
+}
+void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out)
+{
+    /* Level 6 corresponds to TDEFL_DEFAULT_MAX_PROBES or MZ_DEFAULT_LEVEL (but we can't depend on MZ_DEFAULT_LEVEL being available in case the zlib API's where #defined out) */
+    return tdefl_write_image_to_png_file_in_memory_ex(pImage, w, h, num_chans, pLen_out, 6, MZ_FALSE);
+}
+
+/* Allocate the tdefl_compressor and tinfl_decompressor structures in C so that */
+/* non-C language bindings to tdefL_ and tinfl_ API don't need to worry about */
+/* structure size and allocation mechanism. */
+tdefl_compressor *tdefl_compressor_alloc()
+{
+    return (tdefl_compressor *)MZ_MALLOC(sizeof(tdefl_compressor));
+}
+
+void tdefl_compressor_free(tdefl_compressor *pComp)
+{
+    MZ_FREE(pComp);
+}
+
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
diff --git a/xs/src/miniz/miniz_tdef.h b/xs/src/miniz/miniz_tdef.h
new file mode 100644
index 000000000..ca63cfd42
--- /dev/null
+++ b/xs/src/miniz/miniz_tdef.h
@@ -0,0 +1,181 @@
+#pragma once
+#include "miniz_common.h"
+
+/* ------------------- Low-level Compression API Definitions */
+
+/* Set TDEFL_LESS_MEMORY to 1 to use less memory (compression will be slightly slower, and raw/dynamic blocks will be output more frequently). */
+#define TDEFL_LESS_MEMORY 0
+
+/* tdefl_init() compression flags logically OR'd together (low 12 bits contain the max. number of probes per dictionary search): */
+/* TDEFL_DEFAULT_MAX_PROBES: The compressor defaults to 128 dictionary probes per dictionary search. 0=Huffman only, 1=Huffman+LZ (fastest/crap compression), 4095=Huffman+LZ (slowest/best compression). */
+enum
+{
+    TDEFL_HUFFMAN_ONLY = 0,
+    TDEFL_DEFAULT_MAX_PROBES = 128,
+    TDEFL_MAX_PROBES_MASK = 0xFFF
+};
+
+/* TDEFL_WRITE_ZLIB_HEADER: If set, the compressor outputs a zlib header before the deflate data, and the Adler-32 of the source data at the end. Otherwise, you'll get raw deflate data. */
+/* TDEFL_COMPUTE_ADLER32: Always compute the adler-32 of the input data (even when not writing zlib headers). */
+/* TDEFL_GREEDY_PARSING_FLAG: Set to use faster greedy parsing, instead of more efficient lazy parsing. */
+/* TDEFL_NONDETERMINISTIC_PARSING_FLAG: Enable to decrease the compressor's initialization time to the minimum, but the output may vary from run to run given the same input (depending on the contents of memory). */
+/* TDEFL_RLE_MATCHES: Only look for RLE matches (matches with a distance of 1) */
+/* TDEFL_FILTER_MATCHES: Discards matches <= 5 chars if enabled. */
+/* TDEFL_FORCE_ALL_STATIC_BLOCKS: Disable usage of optimized Huffman tables. */
+/* TDEFL_FORCE_ALL_RAW_BLOCKS: Only use raw (uncompressed) deflate blocks. */
+/* The low 12 bits are reserved to control the max # of hash probes per dictionary lookup (see TDEFL_MAX_PROBES_MASK). */
+enum
+{
+    TDEFL_WRITE_ZLIB_HEADER = 0x01000,
+    TDEFL_COMPUTE_ADLER32 = 0x02000,
+    TDEFL_GREEDY_PARSING_FLAG = 0x04000,
+    TDEFL_NONDETERMINISTIC_PARSING_FLAG = 0x08000,
+    TDEFL_RLE_MATCHES = 0x10000,
+    TDEFL_FILTER_MATCHES = 0x20000,
+    TDEFL_FORCE_ALL_STATIC_BLOCKS = 0x40000,
+    TDEFL_FORCE_ALL_RAW_BLOCKS = 0x80000
+};
+
+/* High level compression functions: */
+/* tdefl_compress_mem_to_heap() compresses a block in memory to a heap block allocated via malloc(). */
+/* On entry: */
+/*  pSrc_buf, src_buf_len: Pointer and size of source block to compress. */
+/*  flags: The max match finder probes (default is 128) logically OR'd against the above flags. Higher probes are slower but improve compression. */
+/* On return: */
+/*  Function returns a pointer to the compressed data, or NULL on failure. */
+/*  *pOut_len will be set to the compressed data's size, which could be larger than src_buf_len on uncompressible data. */
+/*  The caller must free() the returned block when it's no longer needed. */
+void *tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags);
+
+/* tdefl_compress_mem_to_mem() compresses a block in memory to another block in memory. */
+/* Returns 0 on failure. */
+size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags);
+
+/* Compresses an image to a compressed PNG file in memory. */
+/* On entry: */
+/*  pImage, w, h, and num_chans describe the image to compress. num_chans may be 1, 2, 3, or 4. */
+/*  The image pitch in bytes per scanline will be w*num_chans. The leftmost pixel on the top scanline is stored first in memory. */
+/*  level may range from [0,10], use MZ_NO_COMPRESSION, MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc. or a decent default is MZ_DEFAULT_LEVEL */
+/*  If flip is true, the image will be flipped on the Y axis (useful for OpenGL apps). */
+/* On return: */
+/*  Function returns a pointer to the compressed data, or NULL on failure. */
+/*  *pLen_out will be set to the size of the PNG image file. */
+/*  The caller must mz_free() the returned heap block (which will typically be larger than *pLen_out) when it's no longer needed. */
+void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w, int h, int num_chans, size_t *pLen_out, mz_uint level, mz_bool flip);
+void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out);
+
+/* Output stream interface. The compressor uses this interface to write compressed data. It'll typically be called TDEFL_OUT_BUF_SIZE at a time. */
+typedef mz_bool (*tdefl_put_buf_func_ptr)(const void *pBuf, int len, void *pUser);
+
+/* tdefl_compress_mem_to_output() compresses a block to an output stream. The above helpers use this function internally. */
+mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags);
+
+enum
+{
+    TDEFL_MAX_HUFF_TABLES = 3,
+    TDEFL_MAX_HUFF_SYMBOLS_0 = 288,
+    TDEFL_MAX_HUFF_SYMBOLS_1 = 32,
+    TDEFL_MAX_HUFF_SYMBOLS_2 = 19,
+    TDEFL_LZ_DICT_SIZE = 32768,
+    TDEFL_LZ_DICT_SIZE_MASK = TDEFL_LZ_DICT_SIZE - 1,
+    TDEFL_MIN_MATCH_LEN = 3,
+    TDEFL_MAX_MATCH_LEN = 258
+};
+
+/* TDEFL_OUT_BUF_SIZE MUST be large enough to hold a single entire compressed output block (using static/fixed Huffman codes). */
+#if TDEFL_LESS_MEMORY
+enum
+{
+    TDEFL_LZ_CODE_BUF_SIZE = 24 * 1024,
+    TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13) / 10,
+    TDEFL_MAX_HUFF_SYMBOLS = 288,
+    TDEFL_LZ_HASH_BITS = 12,
+    TDEFL_LEVEL1_HASH_SIZE_MASK = 4095,
+    TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3,
+    TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS
+};
+#else
+enum
+{
+    TDEFL_LZ_CODE_BUF_SIZE = 64 * 1024,
+    TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13) / 10,
+    TDEFL_MAX_HUFF_SYMBOLS = 288,
+    TDEFL_LZ_HASH_BITS = 15,
+    TDEFL_LEVEL1_HASH_SIZE_MASK = 4095,
+    TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3,
+    TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS
+};
+#endif
+
+/* The low-level tdefl functions below may be used directly if the above helper functions aren't flexible enough. The low-level functions don't make any heap allocations, unlike the above helper functions. */
+typedef enum {
+    TDEFL_STATUS_BAD_PARAM = -2,
+    TDEFL_STATUS_PUT_BUF_FAILED = -1,
+    TDEFL_STATUS_OKAY = 0,
+    TDEFL_STATUS_DONE = 1
+} tdefl_status;
+
+/* Must map to MZ_NO_FLUSH, MZ_SYNC_FLUSH, etc. enums */
+typedef enum {
+    TDEFL_NO_FLUSH = 0,
+    TDEFL_SYNC_FLUSH = 2,
+    TDEFL_FULL_FLUSH = 3,
+    TDEFL_FINISH = 4
+} tdefl_flush;
+
+/* tdefl's compression state structure. */
+typedef struct
+{
+    tdefl_put_buf_func_ptr m_pPut_buf_func;
+    void *m_pPut_buf_user;
+    mz_uint m_flags, m_max_probes[2];
+    int m_greedy_parsing;
+    mz_uint m_adler32, m_lookahead_pos, m_lookahead_size, m_dict_size;
+    mz_uint8 *m_pLZ_code_buf, *m_pLZ_flags, *m_pOutput_buf, *m_pOutput_buf_end;
+    mz_uint m_num_flags_left, m_total_lz_bytes, m_lz_code_buf_dict_pos, m_bits_in, m_bit_buffer;
+    mz_uint m_saved_match_dist, m_saved_match_len, m_saved_lit, m_output_flush_ofs, m_output_flush_remaining, m_finished, m_block_index, m_wants_to_finish;
+    tdefl_status m_prev_return_status;
+    const void *m_pIn_buf;
+    void *m_pOut_buf;
+    size_t *m_pIn_buf_size, *m_pOut_buf_size;
+    tdefl_flush m_flush;
+    const mz_uint8 *m_pSrc;
+    size_t m_src_buf_left, m_out_buf_ofs;
+    mz_uint8 m_dict[TDEFL_LZ_DICT_SIZE + TDEFL_MAX_MATCH_LEN - 1];
+    mz_uint16 m_huff_count[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS];
+    mz_uint16 m_huff_codes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS];
+    mz_uint8 m_huff_code_sizes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS];
+    mz_uint8 m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE];
+    mz_uint16 m_next[TDEFL_LZ_DICT_SIZE];
+    mz_uint16 m_hash[TDEFL_LZ_HASH_SIZE];
+    mz_uint8 m_output_buf[TDEFL_OUT_BUF_SIZE];
+} tdefl_compressor;
+
+/* Initializes the compressor. */
+/* There is no corresponding deinit() function because the tdefl API's do not dynamically allocate memory. */
+/* pBut_buf_func: If NULL, output data will be supplied to the specified callback. In this case, the user should call the tdefl_compress_buffer() API for compression. */
+/* If pBut_buf_func is NULL the user should always call the tdefl_compress() API. */
+/* flags: See the above enums (TDEFL_HUFFMAN_ONLY, TDEFL_WRITE_ZLIB_HEADER, etc.) */
+tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags);
+
+/* Compresses a block of data, consuming as much of the specified input buffer as possible, and writing as much compressed data to the specified output buffer as possible. */
+tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf, size_t *pIn_buf_size, void *pOut_buf, size_t *pOut_buf_size, tdefl_flush flush);
+
+/* tdefl_compress_buffer() is only usable when the tdefl_init() is called with a non-NULL tdefl_put_buf_func_ptr. */
+/* tdefl_compress_buffer() always consumes the entire input buffer. */
+tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, size_t in_buf_size, tdefl_flush flush);
+
+tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d);
+mz_uint32 tdefl_get_adler32(tdefl_compressor *d);
+
+/* Create tdefl_compress() flags given zlib-style compression parameters. */
+/* level may range from [0,10] (where 10 is absolute max compression, but may be much slower on some files) */
+/* window_bits may be -15 (raw deflate) or 15 (zlib) */
+/* strategy may be either MZ_DEFAULT_STRATEGY, MZ_FILTERED, MZ_HUFFMAN_ONLY, MZ_RLE, or MZ_FIXED */
+mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy);
+
+/* Allocate the tdefl_compressor structure in C so that */
+/* non-C language bindings to tdefl_ API don't need to worry about */
+/* structure size and allocation mechanism. */
+tdefl_compressor *tdefl_compressor_alloc();
+void tdefl_compressor_free(tdefl_compressor *pComp);
diff --git a/xs/src/miniz/miniz_tinfl.cpp b/xs/src/miniz/miniz_tinfl.cpp
new file mode 100644
index 000000000..59b24d73f
--- /dev/null
+++ b/xs/src/miniz/miniz_tinfl.cpp
@@ -0,0 +1,725 @@
+/**************************************************************************
+ *
+ * Copyright 2013-2014 RAD Game Tools and Valve Software
+ * Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "miniz_tinfl.h"
+
+/* ------------------- Low-level Decompression (completely independent from all compression API's) */
+
+#define TINFL_MEMCPY(d, s, l) memcpy(d, s, l)
+#define TINFL_MEMSET(p, c, l) memset(p, c, l)
+
+#define TINFL_CR_BEGIN  \
+    switch (r->m_state) \
+    {                   \
+        case 0:
+#define TINFL_CR_RETURN(state_index, result) \
+    do                                       \
+    {                                        \
+        status = result;                     \
+        r->m_state = state_index;            \
+        goto common_exit;                    \
+        case state_index:;                   \
+    }                                        \
+    MZ_MACRO_END
+#define TINFL_CR_RETURN_FOREVER(state_index, result) \
+    do                                               \
+    {                                                \
+        for (;;)                                     \
+        {                                            \
+            TINFL_CR_RETURN(state_index, result);    \
+        }                                            \
+    }                                                \
+    MZ_MACRO_END
+#define TINFL_CR_FINISH }
+
+#define TINFL_GET_BYTE(state_index, c)                                                                                                                           \
+    do                                                                                                                                                           \
+    {                                                                                                                                                            \
+        while (pIn_buf_cur >= pIn_buf_end)                                                                                                                       \
+        {                                                                                                                                                        \
+            TINFL_CR_RETURN(state_index, (decomp_flags & TINFL_FLAG_HAS_MORE_INPUT) ? TINFL_STATUS_NEEDS_MORE_INPUT : TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS); \
+        }                                                                                                                                                        \
+        c = *pIn_buf_cur++;                                                                                                                                      \
+    }                                                                                                                                                            \
+    MZ_MACRO_END
+
+#define TINFL_NEED_BITS(state_index, n)                \
+    do                                                 \
+    {                                                  \
+        mz_uint c;                                     \
+        TINFL_GET_BYTE(state_index, c);                \
+        bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); \
+        num_bits += 8;                                 \
+    } while (num_bits < (mz_uint)(n))
+#define TINFL_SKIP_BITS(state_index, n)      \
+    do                                       \
+    {                                        \
+        if (num_bits < (mz_uint)(n))         \
+        {                                    \
+            TINFL_NEED_BITS(state_index, n); \
+        }                                    \
+        bit_buf >>= (n);                     \
+        num_bits -= (n);                     \
+    }                                        \
+    MZ_MACRO_END
+#define TINFL_GET_BITS(state_index, b, n)    \
+    do                                       \
+    {                                        \
+        if (num_bits < (mz_uint)(n))         \
+        {                                    \
+            TINFL_NEED_BITS(state_index, n); \
+        }                                    \
+        b = bit_buf & ((1 << (n)) - 1);      \
+        bit_buf >>= (n);                     \
+        num_bits -= (n);                     \
+    }                                        \
+    MZ_MACRO_END
+
+/* TINFL_HUFF_BITBUF_FILL() is only used rarely, when the number of bytes remaining in the input buffer falls below 2. */
+/* It reads just enough bytes from the input stream that are needed to decode the next Huffman code (and absolutely no more). It works by trying to fully decode a */
+/* Huffman code by using whatever bits are currently present in the bit buffer. If this fails, it reads another byte, and tries again until it succeeds or until the */
+/* bit buffer contains >=15 bits (deflate's max. Huffman code size). */
+#define TINFL_HUFF_BITBUF_FILL(state_index, pHuff)                             \
+    do                                                                         \
+    {                                                                          \
+        temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)];     \
+        if (temp >= 0)                                                         \
+        {                                                                      \
+            code_len = temp >> 9;                                              \
+            if ((code_len) && (num_bits >= code_len))                          \
+                break;                                                         \
+        }                                                                      \
+        else if (num_bits > TINFL_FAST_LOOKUP_BITS)                            \
+        {                                                                      \
+            code_len = TINFL_FAST_LOOKUP_BITS;                                 \
+            do                                                                 \
+            {                                                                  \
+                temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)]; \
+            } while ((temp < 0) && (num_bits >= (code_len + 1)));              \
+            if (temp >= 0)                                                     \
+                break;                                                         \
+        }                                                                      \
+        TINFL_GET_BYTE(state_index, c);                                        \
+        bit_buf |= (((tinfl_bit_buf_t)c) << num_bits);                         \
+        num_bits += 8;                                                         \
+    } while (num_bits < 15);
+
+/* TINFL_HUFF_DECODE() decodes the next Huffman coded symbol. It's more complex than you would initially expect because the zlib API expects the decompressor to never read */
+/* beyond the final byte of the deflate stream. (In other words, when this macro wants to read another byte from the input, it REALLY needs another byte in order to fully */
+/* decode the next Huffman code.) Handling this properly is particularly important on raw deflate (non-zlib) streams, which aren't followed by a byte aligned adler-32. */
+/* The slow path is only executed at the very end of the input buffer. */
+/* v1.16: The original macro handled the case at the very end of the passed-in input buffer, but we also need to handle the case where the user passes in 1+zillion bytes */
+/* following the deflate data and our non-conservative read-ahead path won't kick in here on this code. This is much trickier. */
+#define TINFL_HUFF_DECODE(state_index, sym, pHuff)                                                                                  \
+    do                                                                                                                              \
+    {                                                                                                                               \
+        int temp;                                                                                                                   \
+        mz_uint code_len, c;                                                                                                        \
+        if (num_bits < 15)                                                                                                          \
+        {                                                                                                                           \
+            if ((pIn_buf_end - pIn_buf_cur) < 2)                                                                                    \
+            {                                                                                                                       \
+                TINFL_HUFF_BITBUF_FILL(state_index, pHuff);                                                                         \
+            }                                                                                                                       \
+            else                                                                                                                    \
+            {                                                                                                                       \
+                bit_buf |= (((tinfl_bit_buf_t)pIn_buf_cur[0]) << num_bits) | (((tinfl_bit_buf_t)pIn_buf_cur[1]) << (num_bits + 8)); \
+                pIn_buf_cur += 2;                                                                                                   \
+                num_bits += 16;                                                                                                     \
+            }                                                                                                                       \
+        }                                                                                                                           \
+        if ((temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0)                                               \
+            code_len = temp >> 9, temp &= 511;                                                                                      \
+        else                                                                                                                        \
+        {                                                                                                                           \
+            code_len = TINFL_FAST_LOOKUP_BITS;                                                                                      \
+            do                                                                                                                      \
+            {                                                                                                                       \
+                temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)];                                                      \
+            } while (temp < 0);                                                                                                     \
+        }                                                                                                                           \
+        sym = temp;                                                                                                                 \
+        bit_buf >>= code_len;                                                                                                       \
+        num_bits -= code_len;                                                                                                       \
+    }                                                                                                                               \
+    MZ_MACRO_END
+
+tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags)
+{
+    static const int s_length_base[31] = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 };
+    static const int s_length_extra[31] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 0, 0 };
+    static const int s_dist_base[32] = { 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0 };
+    static const int s_dist_extra[32] = { 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 };
+    static const mz_uint8 s_length_dezigzag[19] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };
+    static const int s_min_table_sizes[3] = { 257, 1, 4 };
+
+    tinfl_status status = TINFL_STATUS_FAILED;
+    mz_uint32 num_bits, dist, counter, num_extra;
+    tinfl_bit_buf_t bit_buf;
+    const mz_uint8 *pIn_buf_cur = pIn_buf_next, *const pIn_buf_end = pIn_buf_next + *pIn_buf_size;
+    mz_uint8 *pOut_buf_cur = pOut_buf_next, *const pOut_buf_end = pOut_buf_next + *pOut_buf_size;
+    size_t out_buf_size_mask = (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF) ? (size_t)-1 : ((pOut_buf_next - pOut_buf_start) + *pOut_buf_size) - 1, dist_from_out_buf_start;
+
+    /* Ensure the output buffer's size is a power of 2, unless the output buffer is large enough to hold the entire output file (in which case it doesn't matter). */
+    if (((out_buf_size_mask + 1) & out_buf_size_mask) || (pOut_buf_next < pOut_buf_start))
+    {
+        *pIn_buf_size = *pOut_buf_size = 0;
+        return TINFL_STATUS_BAD_PARAM;
+    }
+
+    num_bits = r->m_num_bits;
+    bit_buf = r->m_bit_buf;
+    dist = r->m_dist;
+    counter = r->m_counter;
+    num_extra = r->m_num_extra;
+    dist_from_out_buf_start = r->m_dist_from_out_buf_start;
+    TINFL_CR_BEGIN
+
+    bit_buf = num_bits = dist = counter = num_extra = r->m_zhdr0 = r->m_zhdr1 = 0;
+    r->m_z_adler32 = r->m_check_adler32 = 1;
+    if (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER)
+    {
+        TINFL_GET_BYTE(1, r->m_zhdr0);
+        TINFL_GET_BYTE(2, r->m_zhdr1);
+        counter = (((r->m_zhdr0 * 256 + r->m_zhdr1) % 31 != 0) || (r->m_zhdr1 & 32) || ((r->m_zhdr0 & 15) != 8));
+        if (!(decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF))
+            counter |= (((1U << (8U + (r->m_zhdr0 >> 4))) > 32768U) || ((out_buf_size_mask + 1) < (size_t)(1U << (8U + (r->m_zhdr0 >> 4)))));
+        if (counter)
+        {
+            TINFL_CR_RETURN_FOREVER(36, TINFL_STATUS_FAILED);
+        }
+    }
+
+    do
+    {
+        TINFL_GET_BITS(3, r->m_final, 3);
+        r->m_type = r->m_final >> 1;
+        if (r->m_type == 0)
+        {
+            TINFL_SKIP_BITS(5, num_bits & 7);
+            for (counter = 0; counter < 4; ++counter)
+            {
+                if (num_bits)
+                    TINFL_GET_BITS(6, r->m_raw_header[counter], 8);
+                else
+                    TINFL_GET_BYTE(7, r->m_raw_header[counter]);
+            }
+            if ((counter = (r->m_raw_header[0] | (r->m_raw_header[1] << 8))) != (mz_uint)(0xFFFF ^ (r->m_raw_header[2] | (r->m_raw_header[3] << 8))))
+            {
+                TINFL_CR_RETURN_FOREVER(39, TINFL_STATUS_FAILED);
+            }
+            while ((counter) && (num_bits))
+            {
+                TINFL_GET_BITS(51, dist, 8);
+                while (pOut_buf_cur >= pOut_buf_end)
+                {
+                    TINFL_CR_RETURN(52, TINFL_STATUS_HAS_MORE_OUTPUT);
+                }
+                *pOut_buf_cur++ = (mz_uint8)dist;
+                counter--;
+            }
+            while (counter)
+            {
+                size_t n;
+                while (pOut_buf_cur >= pOut_buf_end)
+                {
+                    TINFL_CR_RETURN(9, TINFL_STATUS_HAS_MORE_OUTPUT);
+                }
+                while (pIn_buf_cur >= pIn_buf_end)
+                {
+                    TINFL_CR_RETURN(38, (decomp_flags & TINFL_FLAG_HAS_MORE_INPUT) ? TINFL_STATUS_NEEDS_MORE_INPUT : TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS);
+                }
+                n = MZ_MIN(MZ_MIN((size_t)(pOut_buf_end - pOut_buf_cur), (size_t)(pIn_buf_end - pIn_buf_cur)), counter);
+                TINFL_MEMCPY(pOut_buf_cur, pIn_buf_cur, n);
+                pIn_buf_cur += n;
+                pOut_buf_cur += n;
+                counter -= (mz_uint)n;
+            }
+        }
+        else if (r->m_type == 3)
+        {
+            TINFL_CR_RETURN_FOREVER(10, TINFL_STATUS_FAILED);
+        }
+        else
+        {
+            if (r->m_type == 1)
+            {
+                mz_uint8 *p = r->m_tables[0].m_code_size;
+                mz_uint i;
+                r->m_table_sizes[0] = 288;
+                r->m_table_sizes[1] = 32;
+                TINFL_MEMSET(r->m_tables[1].m_code_size, 5, 32);
+                for (i = 0; i <= 143; ++i)
+                    *p++ = 8;
+                for (; i <= 255; ++i)
+                    *p++ = 9;
+                for (; i <= 279; ++i)
+                    *p++ = 7;
+                for (; i <= 287; ++i)
+                    *p++ = 8;
+            }
+            else
+            {
+                for (counter = 0; counter < 3; counter++)
+                {
+                    TINFL_GET_BITS(11, r->m_table_sizes[counter], "\05\05\04"[counter]);
+                    r->m_table_sizes[counter] += s_min_table_sizes[counter];
+                }
+                MZ_CLEAR_OBJ(r->m_tables[2].m_code_size);
+                for (counter = 0; counter < r->m_table_sizes[2]; counter++)
+                {
+                    mz_uint s;
+                    TINFL_GET_BITS(14, s, 3);
+                    r->m_tables[2].m_code_size[s_length_dezigzag[counter]] = (mz_uint8)s;
+                }
+                r->m_table_sizes[2] = 19;
+            }
+            for (; (int)r->m_type >= 0; r->m_type--)
+            {
+                int tree_next, tree_cur;
+                tinfl_huff_table *pTable;
+                mz_uint i, j, used_syms, total, sym_index, next_code[17], total_syms[16];
+                pTable = &r->m_tables[r->m_type];
+                MZ_CLEAR_OBJ(total_syms);
+                MZ_CLEAR_OBJ(pTable->m_look_up);
+                MZ_CLEAR_OBJ(pTable->m_tree);
+                for (i = 0; i < r->m_table_sizes[r->m_type]; ++i)
+                    total_syms[pTable->m_code_size[i]]++;
+                used_syms = 0, total = 0;
+                next_code[0] = next_code[1] = 0;
+                for (i = 1; i <= 15; ++i)
+                {
+                    used_syms += total_syms[i];
+                    next_code[i + 1] = (total = ((total + total_syms[i]) << 1));
+                }
+                if ((65536 != total) && (used_syms > 1))
+                {
+                    TINFL_CR_RETURN_FOREVER(35, TINFL_STATUS_FAILED);
+                }
+                for (tree_next = -1, sym_index = 0; sym_index < r->m_table_sizes[r->m_type]; ++sym_index)
+                {
+                    mz_uint rev_code = 0, l, cur_code, code_size = pTable->m_code_size[sym_index];
+                    if (!code_size)
+                        continue;
+                    cur_code = next_code[code_size]++;
+                    for (l = code_size; l > 0; l--, cur_code >>= 1)
+                        rev_code = (rev_code << 1) | (cur_code & 1);
+                    if (code_size <= TINFL_FAST_LOOKUP_BITS)
+                    {
+                        mz_int16 k = (mz_int16)((code_size << 9) | sym_index);
+                        while (rev_code < TINFL_FAST_LOOKUP_SIZE)
+                        {
+                            pTable->m_look_up[rev_code] = k;
+                            rev_code += (1 << code_size);
+                        }
+                        continue;
+                    }
+                    if (0 == (tree_cur = pTable->m_look_up[rev_code & (TINFL_FAST_LOOKUP_SIZE - 1)]))
+                    {
+                        pTable->m_look_up[rev_code & (TINFL_FAST_LOOKUP_SIZE - 1)] = (mz_int16)tree_next;
+                        tree_cur = tree_next;
+                        tree_next -= 2;
+                    }
+                    rev_code >>= (TINFL_FAST_LOOKUP_BITS - 1);
+                    for (j = code_size; j > (TINFL_FAST_LOOKUP_BITS + 1); j--)
+                    {
+                        tree_cur -= ((rev_code >>= 1) & 1);
+                        if (!pTable->m_tree[-tree_cur - 1])
+                        {
+                            pTable->m_tree[-tree_cur - 1] = (mz_int16)tree_next;
+                            tree_cur = tree_next;
+                            tree_next -= 2;
+                        }
+                        else
+                            tree_cur = pTable->m_tree[-tree_cur - 1];
+                    }
+                    tree_cur -= ((rev_code >>= 1) & 1);
+                    pTable->m_tree[-tree_cur - 1] = (mz_int16)sym_index;
+                }
+                if (r->m_type == 2)
+                {
+                    for (counter = 0; counter < (r->m_table_sizes[0] + r->m_table_sizes[1]);)
+                    {
+                        mz_uint s;
+                        TINFL_HUFF_DECODE(16, dist, &r->m_tables[2]);
+                        if (dist < 16)
+                        {
+                            r->m_len_codes[counter++] = (mz_uint8)dist;
+                            continue;
+                        }
+                        if ((dist == 16) && (!counter))
+                        {
+                            TINFL_CR_RETURN_FOREVER(17, TINFL_STATUS_FAILED);
+                        }
+                        num_extra = "\02\03\07"[dist - 16];
+                        TINFL_GET_BITS(18, s, num_extra);
+                        s += "\03\03\013"[dist - 16];
+                        TINFL_MEMSET(r->m_len_codes + counter, (dist == 16) ? r->m_len_codes[counter - 1] : 0, s);
+                        counter += s;
+                    }
+                    if ((r->m_table_sizes[0] + r->m_table_sizes[1]) != counter)
+                    {
+                        TINFL_CR_RETURN_FOREVER(21, TINFL_STATUS_FAILED);
+                    }
+                    TINFL_MEMCPY(r->m_tables[0].m_code_size, r->m_len_codes, r->m_table_sizes[0]);
+                    TINFL_MEMCPY(r->m_tables[1].m_code_size, r->m_len_codes + r->m_table_sizes[0], r->m_table_sizes[1]);
+                }
+            }
+            for (;;)
+            {
+                mz_uint8 *pSrc;
+                for (;;)
+                {
+                    if (((pIn_buf_end - pIn_buf_cur) < 4) || ((pOut_buf_end - pOut_buf_cur) < 2))
+                    {
+                        TINFL_HUFF_DECODE(23, counter, &r->m_tables[0]);
+                        if (counter >= 256)
+                            break;
+                        while (pOut_buf_cur >= pOut_buf_end)
+                        {
+                            TINFL_CR_RETURN(24, TINFL_STATUS_HAS_MORE_OUTPUT);
+                        }
+                        *pOut_buf_cur++ = (mz_uint8)counter;
+                    }
+                    else
+                    {
+                        int sym2;
+                        mz_uint code_len;
+#if TINFL_USE_64BIT_BITBUF
+                        if (num_bits < 30)
+                        {
+                            bit_buf |= (((tinfl_bit_buf_t)MZ_READ_LE32(pIn_buf_cur)) << num_bits);
+                            pIn_buf_cur += 4;
+                            num_bits += 32;
+                        }
+#else
+                        if (num_bits < 15)
+                        {
+                            bit_buf |= (((tinfl_bit_buf_t)MZ_READ_LE16(pIn_buf_cur)) << num_bits);
+                            pIn_buf_cur += 2;
+                            num_bits += 16;
+                        }
+#endif
+                        if ((sym2 = r->m_tables[0].m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0)
+                            code_len = sym2 >> 9;
+                        else
+                        {
+                            code_len = TINFL_FAST_LOOKUP_BITS;
+                            do
+                            {
+                                sym2 = r->m_tables[0].m_tree[~sym2 + ((bit_buf >> code_len++) & 1)];
+                            } while (sym2 < 0);
+                        }
+                        counter = sym2;
+                        bit_buf >>= code_len;
+                        num_bits -= code_len;
+                        if (counter & 256)
+                            break;
+
+#if !TINFL_USE_64BIT_BITBUF
+                        if (num_bits < 15)
+                        {
+                            bit_buf |= (((tinfl_bit_buf_t)MZ_READ_LE16(pIn_buf_cur)) << num_bits);
+                            pIn_buf_cur += 2;
+                            num_bits += 16;
+                        }
+#endif
+                        if ((sym2 = r->m_tables[0].m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0)
+                            code_len = sym2 >> 9;
+                        else
+                        {
+                            code_len = TINFL_FAST_LOOKUP_BITS;
+                            do
+                            {
+                                sym2 = r->m_tables[0].m_tree[~sym2 + ((bit_buf >> code_len++) & 1)];
+                            } while (sym2 < 0);
+                        }
+                        bit_buf >>= code_len;
+                        num_bits -= code_len;
+
+                        pOut_buf_cur[0] = (mz_uint8)counter;
+                        if (sym2 & 256)
+                        {
+                            pOut_buf_cur++;
+                            counter = sym2;
+                            break;
+                        }
+                        pOut_buf_cur[1] = (mz_uint8)sym2;
+                        pOut_buf_cur += 2;
+                    }
+                }
+                if ((counter &= 511) == 256)
+                    break;
+
+                num_extra = s_length_extra[counter - 257];
+                counter = s_length_base[counter - 257];
+                if (num_extra)
+                {
+                    mz_uint extra_bits;
+                    TINFL_GET_BITS(25, extra_bits, num_extra);
+                    counter += extra_bits;
+                }
+
+                TINFL_HUFF_DECODE(26, dist, &r->m_tables[1]);
+                num_extra = s_dist_extra[dist];
+                dist = s_dist_base[dist];
+                if (num_extra)
+                {
+                    mz_uint extra_bits;
+                    TINFL_GET_BITS(27, extra_bits, num_extra);
+                    dist += extra_bits;
+                }
+
+                dist_from_out_buf_start = pOut_buf_cur - pOut_buf_start;
+                if ((dist > dist_from_out_buf_start) && (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF))
+                {
+                    TINFL_CR_RETURN_FOREVER(37, TINFL_STATUS_FAILED);
+                }
+
+                pSrc = pOut_buf_start + ((dist_from_out_buf_start - dist) & out_buf_size_mask);
+
+                if ((MZ_MAX(pOut_buf_cur, pSrc) + counter) > pOut_buf_end)
+                {
+                    while (counter--)
+                    {
+                        while (pOut_buf_cur >= pOut_buf_end)
+                        {
+                            TINFL_CR_RETURN(53, TINFL_STATUS_HAS_MORE_OUTPUT);
+                        }
+                        *pOut_buf_cur++ = pOut_buf_start[(dist_from_out_buf_start++ - dist) & out_buf_size_mask];
+                    }
+                    continue;
+                }
+#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES
+                else if ((counter >= 9) && (counter <= dist))
+                {
+                    const mz_uint8 *pSrc_end = pSrc + (counter & ~7);
+                    do
+                    {
+                        ((mz_uint32 *)pOut_buf_cur)[0] = ((const mz_uint32 *)pSrc)[0];
+                        ((mz_uint32 *)pOut_buf_cur)[1] = ((const mz_uint32 *)pSrc)[1];
+                        pOut_buf_cur += 8;
+                    } while ((pSrc += 8) < pSrc_end);
+                    if ((counter &= 7) < 3)
+                    {
+                        if (counter)
+                        {
+                            pOut_buf_cur[0] = pSrc[0];
+                            if (counter > 1)
+                                pOut_buf_cur[1] = pSrc[1];
+                            pOut_buf_cur += counter;
+                        }
+                        continue;
+                    }
+                }
+#endif
+                do
+                {
+                    pOut_buf_cur[0] = pSrc[0];
+                    pOut_buf_cur[1] = pSrc[1];
+                    pOut_buf_cur[2] = pSrc[2];
+                    pOut_buf_cur += 3;
+                    pSrc += 3;
+                } while ((int)(counter -= 3) > 2);
+                if ((int)counter > 0)
+                {
+                    pOut_buf_cur[0] = pSrc[0];
+                    if ((int)counter > 1)
+                        pOut_buf_cur[1] = pSrc[1];
+                    pOut_buf_cur += counter;
+                }
+            }
+        }
+    } while (!(r->m_final & 1));
+
+    /* Ensure byte alignment and put back any bytes from the bitbuf if we've looked ahead too far on gzip, or other Deflate streams followed by arbitrary data. */
+    /* I'm being super conservative here. A number of simplifications can be made to the byte alignment part, and the Adler32 check shouldn't ever need to worry about reading from the bitbuf now. */
+    TINFL_SKIP_BITS(32, num_bits & 7);
+    while ((pIn_buf_cur > pIn_buf_next) && (num_bits >= 8))
+    {
+        --pIn_buf_cur;
+        num_bits -= 8;
+    }
+    bit_buf &= (tinfl_bit_buf_t)((((mz_uint64)1) << num_bits) - (mz_uint64)1);
+    MZ_ASSERT(!num_bits); /* if this assert fires then we've read beyond the end of non-deflate/zlib streams with following data (such as gzip streams). */
+
+    if (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER)
+    {
+        for (counter = 0; counter < 4; ++counter)
+        {
+            mz_uint s;
+            if (num_bits)
+                TINFL_GET_BITS(41, s, 8);
+            else
+                TINFL_GET_BYTE(42, s);
+            r->m_z_adler32 = (r->m_z_adler32 << 8) | s;
+        }
+    }
+    TINFL_CR_RETURN_FOREVER(34, TINFL_STATUS_DONE);
+
+    TINFL_CR_FINISH
+
+common_exit:
+    /* As long as we aren't telling the caller that we NEED more input to make forward progress: */
+    /* Put back any bytes from the bitbuf in case we've looked ahead too far on gzip, or other Deflate streams followed by arbitrary data. */
+    /* We need to be very careful here to NOT push back any bytes we definitely know we need to make forward progress, though, or we'll lock the caller up into an inf loop. */
+    if ((status != TINFL_STATUS_NEEDS_MORE_INPUT) && (status != TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS))
+    {
+        while ((pIn_buf_cur > pIn_buf_next) && (num_bits >= 8))
+        {
+            --pIn_buf_cur;
+            num_bits -= 8;
+        }
+    }
+    r->m_num_bits = num_bits;
+    r->m_bit_buf = bit_buf & (tinfl_bit_buf_t)((((mz_uint64)1) << num_bits) - (mz_uint64)1);
+    r->m_dist = dist;
+    r->m_counter = counter;
+    r->m_num_extra = num_extra;
+    r->m_dist_from_out_buf_start = dist_from_out_buf_start;
+    *pIn_buf_size = pIn_buf_cur - pIn_buf_next;
+    *pOut_buf_size = pOut_buf_cur - pOut_buf_next;
+    if ((decomp_flags & (TINFL_FLAG_PARSE_ZLIB_HEADER | TINFL_FLAG_COMPUTE_ADLER32)) && (status >= 0))
+    {
+        const mz_uint8 *ptr = pOut_buf_next;
+        size_t buf_len = *pOut_buf_size;
+        mz_uint32 i, s1 = r->m_check_adler32 & 0xffff, s2 = r->m_check_adler32 >> 16;
+        size_t block_len = buf_len % 5552;
+        while (buf_len)
+        {
+            for (i = 0; i + 7 < block_len; i += 8, ptr += 8)
+            {
+                s1 += ptr[0], s2 += s1;
+                s1 += ptr[1], s2 += s1;
+                s1 += ptr[2], s2 += s1;
+                s1 += ptr[3], s2 += s1;
+                s1 += ptr[4], s2 += s1;
+                s1 += ptr[5], s2 += s1;
+                s1 += ptr[6], s2 += s1;
+                s1 += ptr[7], s2 += s1;
+            }
+            for (; i < block_len; ++i)
+                s1 += *ptr++, s2 += s1;
+            s1 %= 65521U, s2 %= 65521U;
+            buf_len -= block_len;
+            block_len = 5552;
+        }
+        r->m_check_adler32 = (s2 << 16) + s1;
+        if ((status == TINFL_STATUS_DONE) && (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) && (r->m_check_adler32 != r->m_z_adler32))
+            status = TINFL_STATUS_ADLER32_MISMATCH;
+    }
+    return status;
+}
+
+/* Higher level helper functions. */
+void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags)
+{
+    tinfl_decompressor decomp;
+    void *pBuf = NULL, *pNew_buf;
+    size_t src_buf_ofs = 0, out_buf_capacity = 0;
+    *pOut_len = 0;
+    tinfl_init(&decomp);
+    for (;;)
+    {
+        size_t src_buf_size = src_buf_len - src_buf_ofs, dst_buf_size = out_buf_capacity - *pOut_len, new_out_buf_capacity;
+        tinfl_status status = tinfl_decompress(&decomp, (const mz_uint8 *)pSrc_buf + src_buf_ofs, &src_buf_size, (mz_uint8 *)pBuf, pBuf ? (mz_uint8 *)pBuf + *pOut_len : NULL, &dst_buf_size,
+                                               (flags & ~TINFL_FLAG_HAS_MORE_INPUT) | TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF);
+        if ((status < 0) || (status == TINFL_STATUS_NEEDS_MORE_INPUT))
+        {
+            MZ_FREE(pBuf);
+            *pOut_len = 0;
+            return NULL;
+        }
+        src_buf_ofs += src_buf_size;
+        *pOut_len += dst_buf_size;
+        if (status == TINFL_STATUS_DONE)
+            break;
+        new_out_buf_capacity = out_buf_capacity * 2;
+        if (new_out_buf_capacity < 128)
+            new_out_buf_capacity = 128;
+        pNew_buf = MZ_REALLOC(pBuf, new_out_buf_capacity);
+        if (!pNew_buf)
+        {
+            MZ_FREE(pBuf);
+            *pOut_len = 0;
+            return NULL;
+        }
+        pBuf = pNew_buf;
+        out_buf_capacity = new_out_buf_capacity;
+    }
+    return pBuf;
+}
+
+size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags)
+{
+    tinfl_decompressor decomp;
+    tinfl_status status;
+    tinfl_init(&decomp);
+    status = tinfl_decompress(&decomp, (const mz_uint8 *)pSrc_buf, &src_buf_len, (mz_uint8 *)pOut_buf, (mz_uint8 *)pOut_buf, &out_buf_len, (flags & ~TINFL_FLAG_HAS_MORE_INPUT) | TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF);
+    return (status != TINFL_STATUS_DONE) ? TINFL_DECOMPRESS_MEM_TO_MEM_FAILED : out_buf_len;
+}
+
+int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, tinfl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags)
+{
+    int result = 0;
+    tinfl_decompressor decomp;
+    mz_uint8 *pDict = (mz_uint8 *)MZ_MALLOC(TINFL_LZ_DICT_SIZE);
+    size_t in_buf_ofs = 0, dict_ofs = 0;
+    if (!pDict)
+        return TINFL_STATUS_FAILED;
+    tinfl_init(&decomp);
+    for (;;)
+    {
+        size_t in_buf_size = *pIn_buf_size - in_buf_ofs, dst_buf_size = TINFL_LZ_DICT_SIZE - dict_ofs;
+        tinfl_status status = tinfl_decompress(&decomp, (const mz_uint8 *)pIn_buf + in_buf_ofs, &in_buf_size, pDict, pDict + dict_ofs, &dst_buf_size,
+                                               (flags & ~(TINFL_FLAG_HAS_MORE_INPUT | TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF)));
+        in_buf_ofs += in_buf_size;
+        if ((dst_buf_size) && (!(*pPut_buf_func)(pDict + dict_ofs, (int)dst_buf_size, pPut_buf_user)))
+            break;
+        if (status != TINFL_STATUS_HAS_MORE_OUTPUT)
+        {
+            result = (status == TINFL_STATUS_DONE);
+            break;
+        }
+        dict_ofs = (dict_ofs + dst_buf_size) & (TINFL_LZ_DICT_SIZE - 1);
+    }
+    MZ_FREE(pDict);
+    *pIn_buf_size = in_buf_ofs;
+    return result;
+}
+
+tinfl_decompressor *tinfl_decompressor_alloc()
+{
+    tinfl_decompressor *pDecomp = (tinfl_decompressor *)MZ_MALLOC(sizeof(tinfl_decompressor));
+    if (pDecomp)
+        tinfl_init(pDecomp);
+    return pDecomp;
+}
+
+void tinfl_decompressor_free(tinfl_decompressor *pDecomp)
+{
+    MZ_FREE(pDecomp);
+}
diff --git a/xs/src/miniz/miniz_tinfl.h b/xs/src/miniz/miniz_tinfl.h
new file mode 100644
index 000000000..b90f22749
--- /dev/null
+++ b/xs/src/miniz/miniz_tinfl.h
@@ -0,0 +1,137 @@
+#pragma once
+#include "miniz_common.h"
+/* ------------------- Low-level Decompression API Definitions */
+
+/* Decompression flags used by tinfl_decompress(). */
+/* TINFL_FLAG_PARSE_ZLIB_HEADER: If set, the input has a valid zlib header and ends with an adler32 checksum (it's a valid zlib stream). Otherwise, the input is a raw deflate stream. */
+/* TINFL_FLAG_HAS_MORE_INPUT: If set, there are more input bytes available beyond the end of the supplied input buffer. If clear, the input buffer contains all remaining input. */
+/* TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF: If set, the output buffer is large enough to hold the entire decompressed stream. If clear, the output buffer is at least the size of the dictionary (typically 32KB). */
+/* TINFL_FLAG_COMPUTE_ADLER32: Force adler-32 checksum computation of the decompressed bytes. */
+enum
+{
+    TINFL_FLAG_PARSE_ZLIB_HEADER = 1,
+    TINFL_FLAG_HAS_MORE_INPUT = 2,
+    TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF = 4,
+    TINFL_FLAG_COMPUTE_ADLER32 = 8
+};
+
+/* High level decompression functions: */
+/* tinfl_decompress_mem_to_heap() decompresses a block in memory to a heap block allocated via malloc(). */
+/* On entry: */
+/*  pSrc_buf, src_buf_len: Pointer and size of the Deflate or zlib source data to decompress. */
+/* On return: */
+/*  Function returns a pointer to the decompressed data, or NULL on failure. */
+/*  *pOut_len will be set to the decompressed data's size, which could be larger than src_buf_len on uncompressible data. */
+/*  The caller must call mz_free() on the returned block when it's no longer needed. */
+void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags);
+
+/* tinfl_decompress_mem_to_mem() decompresses a block in memory to another block in memory. */
+/* Returns TINFL_DECOMPRESS_MEM_TO_MEM_FAILED on failure, or the number of bytes written on success. */
+#define TINFL_DECOMPRESS_MEM_TO_MEM_FAILED ((size_t)(-1))
+size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags);
+
+/* tinfl_decompress_mem_to_callback() decompresses a block in memory to an internal 32KB buffer, and a user provided callback function will be called to flush the buffer. */
+/* Returns 1 on success or 0 on failure. */
+typedef int (*tinfl_put_buf_func_ptr)(const void *pBuf, int len, void *pUser);
+int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, tinfl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags);
+
+struct tinfl_decompressor_tag;
+typedef struct tinfl_decompressor_tag tinfl_decompressor;
+
+/* Allocate the tinfl_decompressor structure in C so that */
+/* non-C language bindings to tinfl_ API don't need to worry about */
+/* structure size and allocation mechanism. */
+
+tinfl_decompressor *tinfl_decompressor_alloc();
+void tinfl_decompressor_free(tinfl_decompressor *pDecomp);
+
+/* Max size of LZ dictionary. */
+#define TINFL_LZ_DICT_SIZE 32768
+
+/* Return status. */
+typedef enum {
+    /* This flags indicates the inflator needs 1 or more input bytes to make forward progress, but the caller is indicating that no more are available. The compressed data */
+    /* is probably corrupted. If you call the inflator again with more bytes it'll try to continue processing the input but this is a BAD sign (either the data is corrupted or you called it incorrectly). */
+    /* If you call it again with no input you'll just get TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS again. */
+    TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS = -4,
+
+    /* This flag indicates that one or more of the input parameters was obviously bogus. (You can try calling it again, but if you get this error the calling code is wrong.) */
+    TINFL_STATUS_BAD_PARAM = -3,
+
+    /* This flags indicate the inflator is finished but the adler32 check of the uncompressed data didn't match. If you call it again it'll return TINFL_STATUS_DONE. */
+    TINFL_STATUS_ADLER32_MISMATCH = -2,
+
+    /* This flags indicate the inflator has somehow failed (bad code, corrupted input, etc.). If you call it again without resetting via tinfl_init() it it'll just keep on returning the same status failure code. */
+    TINFL_STATUS_FAILED = -1,
+
+    /* Any status code less than TINFL_STATUS_DONE must indicate a failure. */
+
+    /* This flag indicates the inflator has returned every byte of uncompressed data that it can, has consumed every byte that it needed, has successfully reached the end of the deflate stream, and */
+    /* if zlib headers and adler32 checking enabled that it has successfully checked the uncompressed data's adler32. If you call it again you'll just get TINFL_STATUS_DONE over and over again. */
+    TINFL_STATUS_DONE = 0,
+
+    /* This flag indicates the inflator MUST have more input data (even 1 byte) before it can make any more forward progress, or you need to clear the TINFL_FLAG_HAS_MORE_INPUT */
+    /* flag on the next call if you don't have any more source data. If the source data was somehow corrupted it's also possible (but unlikely) for the inflator to keep on demanding input to */
+    /* proceed, so be sure to properly set the TINFL_FLAG_HAS_MORE_INPUT flag. */
+    TINFL_STATUS_NEEDS_MORE_INPUT = 1,
+
+    /* This flag indicates the inflator definitely has 1 or more bytes of uncompressed data available, but it cannot write this data into the output buffer. */
+    /* Note if the source compressed data was corrupted it's possible for the inflator to return a lot of uncompressed data to the caller. I've been assuming you know how much uncompressed data to expect */
+    /* (either exact or worst case) and will stop calling the inflator and fail after receiving too much. In pure streaming scenarios where you have no idea how many bytes to expect this may not be possible */
+    /* so I may need to add some code to address this. */
+    TINFL_STATUS_HAS_MORE_OUTPUT = 2
+} tinfl_status;
+
+/* Initializes the decompressor to its initial state. */
+#define tinfl_init(r)     \
+    do                    \
+    {                     \
+        (r)->m_state = 0; \
+    }                     \
+    MZ_MACRO_END
+#define tinfl_get_adler32(r) (r)->m_check_adler32
+
+/* Main low-level decompressor coroutine function. This is the only function actually needed for decompression. All the other functions are just high-level helpers for improved usability. */
+/* This is a universal API, i.e. it can be used as a building block to build any desired higher level decompression API. In the limit case, it can be called once per every byte input or output. */
+tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags);
+
+/* Internal/private bits follow. */
+enum
+{
+    TINFL_MAX_HUFF_TABLES = 3,
+    TINFL_MAX_HUFF_SYMBOLS_0 = 288,
+    TINFL_MAX_HUFF_SYMBOLS_1 = 32,
+    TINFL_MAX_HUFF_SYMBOLS_2 = 19,
+    TINFL_FAST_LOOKUP_BITS = 10,
+    TINFL_FAST_LOOKUP_SIZE = 1 << TINFL_FAST_LOOKUP_BITS
+};
+
+typedef struct
+{
+    mz_uint8 m_code_size[TINFL_MAX_HUFF_SYMBOLS_0];
+    mz_int16 m_look_up[TINFL_FAST_LOOKUP_SIZE], m_tree[TINFL_MAX_HUFF_SYMBOLS_0 * 2];
+} tinfl_huff_table;
+
+#if MINIZ_HAS_64BIT_REGISTERS
+#define TINFL_USE_64BIT_BITBUF 1
+#else
+#define TINFL_USE_64BIT_BITBUF 0
+#endif
+
+#if TINFL_USE_64BIT_BITBUF
+typedef mz_uint64 tinfl_bit_buf_t;
+#define TINFL_BITBUF_SIZE (64)
+#else
+typedef mz_uint32 tinfl_bit_buf_t;
+#define TINFL_BITBUF_SIZE (32)
+#endif
+
+struct tinfl_decompressor_tag
+{
+    mz_uint32 m_state, m_num_bits, m_zhdr0, m_zhdr1, m_z_adler32, m_final, m_type, m_check_adler32, m_dist, m_counter, m_num_extra, m_table_sizes[TINFL_MAX_HUFF_TABLES];
+    tinfl_bit_buf_t m_bit_buf;
+    size_t m_dist_from_out_buf_start;
+    tinfl_huff_table m_tables[TINFL_MAX_HUFF_TABLES];
+    mz_uint8 m_raw_header[4], m_len_codes[TINFL_MAX_HUFF_SYMBOLS_0 + TINFL_MAX_HUFF_SYMBOLS_1 + 137];
+};
+
diff --git a/xs/src/miniz/miniz_zip.cpp b/xs/src/miniz/miniz_zip.cpp
new file mode 100644
index 000000000..463660c1c
--- /dev/null
+++ b/xs/src/miniz/miniz_zip.cpp
@@ -0,0 +1,4659 @@
+/**************************************************************************
+ *
+ * Copyright 2013-2014 RAD Game Tools and Valve Software
+ * Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC
+ * Copyright 2016 Martin Raiber
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+#include "miniz_zip.h"
+
+#include <boost/nowide/cstdio.hpp>
+
+#ifndef MINIZ_NO_ARCHIVE_APIS
+
+/* ------------------- .ZIP archive reading */
+
+#ifdef MINIZ_NO_STDIO
+#define MZ_FILE void *
+#else
+#include <sys/stat.h>
+
+#if defined(_MSC_VER) || defined(__MINGW64__)
+
+static FILE *mz_fopen(const char *pFilename, const char *pMode)
+{
+    FILE *pFile = NULL;
+    pFile = boost::nowide::fopen(pFilename, pMode);
+    return pFile;
+}
+static FILE *mz_freopen(const char *pPath, const char *pMode, FILE *pStream)
+{
+    FILE *pFile = NULL;
+    pFile = boost::nowide::freopen(pPath, pMode, pStream);
+    return pFile;
+}
+#ifndef MINIZ_NO_TIME
+#include <sys/utime.h>
+#endif
+#define MZ_FOPEN mz_fopen
+#define MZ_FCLOSE fclose
+#define MZ_FREAD fread
+#define MZ_FWRITE fwrite
+#define MZ_FTELL64 _ftelli64
+#define MZ_FSEEK64 _fseeki64
+#define MZ_FILE_STAT_STRUCT _stat
+#define MZ_FILE_STAT _stat
+#define MZ_FFLUSH fflush
+#define MZ_FREOPEN mz_freopen
+#define MZ_DELETE_FILE remove
+#elif defined(__MINGW32__)
+#ifndef MINIZ_NO_TIME
+#include <sys/utime.h>
+#endif
+#define MZ_FOPEN(f, m) fopen(f, m)
+#define MZ_FCLOSE fclose
+#define MZ_FREAD fread
+#define MZ_FWRITE fwrite
+#define MZ_FTELL64 ftello64
+#define MZ_FSEEK64 fseeko64
+#define MZ_FILE_STAT_STRUCT _stat
+#define MZ_FILE_STAT _stat
+#define MZ_FFLUSH fflush
+#define MZ_FREOPEN(f, m, s) freopen(f, m, s)
+#define MZ_DELETE_FILE remove
+#elif defined(__TINYC__)
+#ifndef MINIZ_NO_TIME
+#include <sys/utime.h>
+#endif
+#define MZ_FOPEN(f, m) fopen(f, m)
+#define MZ_FCLOSE fclose
+#define MZ_FREAD fread
+#define MZ_FWRITE fwrite
+#define MZ_FTELL64 ftell
+#define MZ_FSEEK64 fseek
+#define MZ_FILE_STAT_STRUCT stat
+#define MZ_FILE_STAT stat
+#define MZ_FFLUSH fflush
+#define MZ_FREOPEN(f, m, s) freopen(f, m, s)
+#define MZ_DELETE_FILE remove
+#elif defined(__GNUC__) && _LARGEFILE64_SOURCE
+#ifndef MINIZ_NO_TIME
+#include <utime.h>
+#endif
+#define MZ_FOPEN(f, m) fopen64(f, m)
+#define MZ_FCLOSE fclose
+#define MZ_FREAD fread
+#define MZ_FWRITE fwrite
+#define MZ_FTELL64 ftello64
+#define MZ_FSEEK64 fseeko64
+#define MZ_FILE_STAT_STRUCT stat64
+#define MZ_FILE_STAT stat64
+#define MZ_FFLUSH fflush
+#define MZ_FREOPEN(p, m, s) freopen64(p, m, s)
+#define MZ_DELETE_FILE remove
+#elif defined(__APPLE__) && _LARGEFILE64_SOURCE
+#ifndef MINIZ_NO_TIME
+#include <utime.h>
+#endif
+#define MZ_FOPEN(f, m) fopen(f, m)
+#define MZ_FCLOSE fclose
+#define MZ_FREAD fread
+#define MZ_FWRITE fwrite
+#define MZ_FTELL64 ftello
+#define MZ_FSEEK64 fseeko
+#define MZ_FILE_STAT_STRUCT stat
+#define MZ_FILE_STAT stat
+#define MZ_FFLUSH fflush
+#define MZ_FREOPEN(p, m, s) freopen(p, m, s)
+#define MZ_DELETE_FILE remove
+
+#else
+#pragma message("Using fopen, ftello, fseeko, stat() etc. path for file I/O - this path may not support large files.")
+#ifndef MINIZ_NO_TIME
+#include <utime.h>
+#endif
+#define MZ_FOPEN(f, m) fopen(f, m)
+#define MZ_FCLOSE fclose
+#define MZ_FREAD fread
+#define MZ_FWRITE fwrite
+#ifdef __STRICT_ANSI__
+#define MZ_FTELL64 ftell
+#define MZ_FSEEK64 fseek
+#else
+#define MZ_FTELL64 ftello
+#define MZ_FSEEK64 fseeko
+#endif
+#define MZ_FILE_STAT_STRUCT stat
+#define MZ_FILE_STAT stat
+#define MZ_FFLUSH fflush
+#define MZ_FREOPEN(f, m, s) freopen(f, m, s)
+#define MZ_DELETE_FILE remove
+#endif /* #ifdef _MSC_VER */
+#endif /* #ifdef MINIZ_NO_STDIO */
+
+#define MZ_TOLOWER(c) ((((c) >= 'A') && ((c) <= 'Z')) ? ((c) - 'A' + 'a') : (c))
+
+/* Various ZIP archive enums. To completely avoid cross platform compiler alignment and platform endian issues, miniz.c doesn't use structs for any of this stuff. */
+enum
+{
+    /* ZIP archive identifiers and record sizes */
+    MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG = 0x06054b50,
+    MZ_ZIP_CENTRAL_DIR_HEADER_SIG = 0x02014b50,
+    MZ_ZIP_LOCAL_DIR_HEADER_SIG = 0x04034b50,
+    MZ_ZIP_LOCAL_DIR_HEADER_SIZE = 30,
+    MZ_ZIP_CENTRAL_DIR_HEADER_SIZE = 46,
+    MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE = 22,
+
+    /* ZIP64 archive identifier and record sizes */
+    MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIG = 0x06064b50,
+    MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIG = 0x07064b50,
+    MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIZE = 56,
+    MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIZE = 20,
+    MZ_ZIP64_EXTENDED_INFORMATION_FIELD_HEADER_ID = 0x0001,
+    MZ_ZIP_DATA_DESCRIPTOR_ID = 0x08074b50,
+    MZ_ZIP_DATA_DESCRIPTER_SIZE64 = 24,
+    MZ_ZIP_DATA_DESCRIPTER_SIZE32 = 16,
+
+    /* Central directory header record offsets */
+    MZ_ZIP_CDH_SIG_OFS = 0,
+    MZ_ZIP_CDH_VERSION_MADE_BY_OFS = 4,
+    MZ_ZIP_CDH_VERSION_NEEDED_OFS = 6,
+    MZ_ZIP_CDH_BIT_FLAG_OFS = 8,
+    MZ_ZIP_CDH_METHOD_OFS = 10,
+    MZ_ZIP_CDH_FILE_TIME_OFS = 12,
+    MZ_ZIP_CDH_FILE_DATE_OFS = 14,
+    MZ_ZIP_CDH_CRC32_OFS = 16,
+    MZ_ZIP_CDH_COMPRESSED_SIZE_OFS = 20,
+    MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS = 24,
+    MZ_ZIP_CDH_FILENAME_LEN_OFS = 28,
+    MZ_ZIP_CDH_EXTRA_LEN_OFS = 30,
+    MZ_ZIP_CDH_COMMENT_LEN_OFS = 32,
+    MZ_ZIP_CDH_DISK_START_OFS = 34,
+    MZ_ZIP_CDH_INTERNAL_ATTR_OFS = 36,
+    MZ_ZIP_CDH_EXTERNAL_ATTR_OFS = 38,
+    MZ_ZIP_CDH_LOCAL_HEADER_OFS = 42,
+
+    /* Local directory header offsets */
+    MZ_ZIP_LDH_SIG_OFS = 0,
+    MZ_ZIP_LDH_VERSION_NEEDED_OFS = 4,
+    MZ_ZIP_LDH_BIT_FLAG_OFS = 6,
+    MZ_ZIP_LDH_METHOD_OFS = 8,
+    MZ_ZIP_LDH_FILE_TIME_OFS = 10,
+    MZ_ZIP_LDH_FILE_DATE_OFS = 12,
+    MZ_ZIP_LDH_CRC32_OFS = 14,
+    MZ_ZIP_LDH_COMPRESSED_SIZE_OFS = 18,
+    MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS = 22,
+    MZ_ZIP_LDH_FILENAME_LEN_OFS = 26,
+    MZ_ZIP_LDH_EXTRA_LEN_OFS = 28,
+    MZ_ZIP_LDH_BIT_FLAG_HAS_LOCATOR = 1 << 3,
+
+    /* End of central directory offsets */
+    MZ_ZIP_ECDH_SIG_OFS = 0,
+    MZ_ZIP_ECDH_NUM_THIS_DISK_OFS = 4,
+    MZ_ZIP_ECDH_NUM_DISK_CDIR_OFS = 6,
+    MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS = 8,
+    MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS = 10,
+    MZ_ZIP_ECDH_CDIR_SIZE_OFS = 12,
+    MZ_ZIP_ECDH_CDIR_OFS_OFS = 16,
+    MZ_ZIP_ECDH_COMMENT_SIZE_OFS = 20,
+
+    /* ZIP64 End of central directory locator offsets */
+    MZ_ZIP64_ECDL_SIG_OFS = 0,                    /* 4 bytes */
+    MZ_ZIP64_ECDL_NUM_DISK_CDIR_OFS = 4,          /* 4 bytes */
+    MZ_ZIP64_ECDL_REL_OFS_TO_ZIP64_ECDR_OFS = 8,  /* 8 bytes */
+    MZ_ZIP64_ECDL_TOTAL_NUMBER_OF_DISKS_OFS = 16, /* 4 bytes */
+
+    /* ZIP64 End of central directory header offsets */
+    MZ_ZIP64_ECDH_SIG_OFS = 0,                       /* 4 bytes */
+    MZ_ZIP64_ECDH_SIZE_OF_RECORD_OFS = 4,            /* 8 bytes */
+    MZ_ZIP64_ECDH_VERSION_MADE_BY_OFS = 12,          /* 2 bytes */
+    MZ_ZIP64_ECDH_VERSION_NEEDED_OFS = 14,           /* 2 bytes */
+    MZ_ZIP64_ECDH_NUM_THIS_DISK_OFS = 16,            /* 4 bytes */
+    MZ_ZIP64_ECDH_NUM_DISK_CDIR_OFS = 20,            /* 4 bytes */
+    MZ_ZIP64_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS = 24, /* 8 bytes */
+    MZ_ZIP64_ECDH_CDIR_TOTAL_ENTRIES_OFS = 32,       /* 8 bytes */
+    MZ_ZIP64_ECDH_CDIR_SIZE_OFS = 40,                /* 8 bytes */
+    MZ_ZIP64_ECDH_CDIR_OFS_OFS = 48,                 /* 8 bytes */
+    MZ_ZIP_VERSION_MADE_BY_DOS_FILESYSTEM_ID = 0,
+    MZ_ZIP_DOS_DIR_ATTRIBUTE_BITFLAG = 0x10,
+    MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_IS_ENCRYPTED = 1,
+    MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_COMPRESSED_PATCH_FLAG = 32,
+    MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_USES_STRONG_ENCRYPTION = 64,
+    MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_LOCAL_DIR_IS_MASKED = 8192,
+    MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_UTF8 = 1 << 11
+};
+
+typedef struct
+{
+    void *m_p;
+    size_t m_size, m_capacity;
+    mz_uint m_element_size;
+} mz_zip_array;
+
+struct mz_zip_internal_state_tag
+{
+    mz_zip_array m_central_dir;
+    mz_zip_array m_central_dir_offsets;
+    mz_zip_array m_sorted_central_dir_offsets;
+
+    /* The flags passed in when the archive is initially opened. */
+    uint32_t m_init_flags;
+
+    /* MZ_TRUE if the archive has a zip64 end of central directory headers, etc. */
+    mz_bool m_zip64;
+
+    /* MZ_TRUE if we found zip64 extended info in the central directory (m_zip64 will also be slammed to true too, even if we didn't find a zip64 end of central dir header, etc.) */
+    mz_bool m_zip64_has_extended_info_fields;
+
+    /* These fields are used by the file, FILE, memory, and memory/heap read/write helpers. */
+    MZ_FILE *m_pFile;
+    mz_uint64 m_file_archive_start_ofs;
+
+    void *m_pMem;
+    size_t m_mem_size;
+    size_t m_mem_capacity;
+};
+
+#define MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(array_ptr, element_size) (array_ptr)->m_element_size = element_size
+
+#if defined(DEBUG) || defined(_DEBUG) || defined(NDEBUG)
+static MZ_FORCEINLINE mz_uint mz_zip_array_range_check(const mz_zip_array *pArray, mz_uint index)
+{
+    MZ_ASSERT(index < pArray->m_size);
+    return index;
+}
+#define MZ_ZIP_ARRAY_ELEMENT(array_ptr, element_type, index) ((element_type *)((array_ptr)->m_p))[mz_zip_array_range_check(array_ptr, index)]
+#else
+#define MZ_ZIP_ARRAY_ELEMENT(array_ptr, element_type, index) ((element_type *)((array_ptr)->m_p))[index]
+#endif
+
+static MZ_FORCEINLINE void mz_zip_array_init(mz_zip_array *pArray, mz_uint32 element_size)
+{
+    memset(pArray, 0, sizeof(mz_zip_array));
+    pArray->m_element_size = element_size;
+}
+
+static MZ_FORCEINLINE void mz_zip_array_clear(mz_zip_archive *pZip, mz_zip_array *pArray)
+{
+    pZip->m_pFree(pZip->m_pAlloc_opaque, pArray->m_p);
+    memset(pArray, 0, sizeof(mz_zip_array));
+}
+
+static mz_bool mz_zip_array_ensure_capacity(mz_zip_archive *pZip, mz_zip_array *pArray, size_t min_new_capacity, mz_uint growing)
+{
+    void *pNew_p;
+    size_t new_capacity = min_new_capacity;
+    MZ_ASSERT(pArray->m_element_size);
+    if (pArray->m_capacity >= min_new_capacity)
+        return MZ_TRUE;
+    if (growing)
+    {
+        new_capacity = MZ_MAX(1, pArray->m_capacity);
+        while (new_capacity < min_new_capacity)
+            new_capacity *= 2;
+    }
+    if (NULL == (pNew_p = pZip->m_pRealloc(pZip->m_pAlloc_opaque, pArray->m_p, pArray->m_element_size, new_capacity)))
+        return MZ_FALSE;
+    pArray->m_p = pNew_p;
+    pArray->m_capacity = new_capacity;
+    return MZ_TRUE;
+}
+
+static MZ_FORCEINLINE mz_bool mz_zip_array_reserve(mz_zip_archive *pZip, mz_zip_array *pArray, size_t new_capacity, mz_uint growing)
+{
+    if (new_capacity > pArray->m_capacity)
+    {
+        if (!mz_zip_array_ensure_capacity(pZip, pArray, new_capacity, growing))
+            return MZ_FALSE;
+    }
+    return MZ_TRUE;
+}
+
+static MZ_FORCEINLINE mz_bool mz_zip_array_resize(mz_zip_archive *pZip, mz_zip_array *pArray, size_t new_size, mz_uint growing)
+{
+    if (new_size > pArray->m_capacity)
+    {
+        if (!mz_zip_array_ensure_capacity(pZip, pArray, new_size, growing))
+            return MZ_FALSE;
+    }
+    pArray->m_size = new_size;
+    return MZ_TRUE;
+}
+
+static MZ_FORCEINLINE mz_bool mz_zip_array_ensure_room(mz_zip_archive *pZip, mz_zip_array *pArray, size_t n)
+{
+    return mz_zip_array_reserve(pZip, pArray, pArray->m_size + n, MZ_TRUE);
+}
+
+static MZ_FORCEINLINE mz_bool mz_zip_array_push_back(mz_zip_archive *pZip, mz_zip_array *pArray, const void *pElements, size_t n)
+{
+    size_t orig_size = pArray->m_size;
+    if (!mz_zip_array_resize(pZip, pArray, orig_size + n, MZ_TRUE))
+        return MZ_FALSE;
+    memcpy((mz_uint8 *)pArray->m_p + orig_size * pArray->m_element_size, pElements, n * pArray->m_element_size);
+    return MZ_TRUE;
+}
+
+#ifndef MINIZ_NO_TIME
+static MZ_TIME_T mz_zip_dos_to_time_t(int dos_time, int dos_date)
+{
+    struct tm tm;
+    memset(&tm, 0, sizeof(tm));
+    tm.tm_isdst = -1;
+    tm.tm_year = ((dos_date >> 9) & 127) + 1980 - 1900;
+    tm.tm_mon = ((dos_date >> 5) & 15) - 1;
+    tm.tm_mday = dos_date & 31;
+    tm.tm_hour = (dos_time >> 11) & 31;
+    tm.tm_min = (dos_time >> 5) & 63;
+    tm.tm_sec = (dos_time << 1) & 62;
+    return mktime(&tm);
+}
+
+#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS
+static void mz_zip_time_t_to_dos_time(MZ_TIME_T time, mz_uint16 *pDOS_time, mz_uint16 *pDOS_date)
+{
+#ifdef _MSC_VER
+    struct tm tm_struct;
+    struct tm *tm = &tm_struct;
+    errno_t err = localtime_s(tm, &time);
+    if (err)
+    {
+        *pDOS_date = 0;
+        *pDOS_time = 0;
+        return;
+    }
+#else
+    struct tm *tm = localtime(&time);
+#endif /* #ifdef _MSC_VER */
+
+    *pDOS_time = (mz_uint16)(((tm->tm_hour) << 11) + ((tm->tm_min) << 5) + ((tm->tm_sec) >> 1));
+    *pDOS_date = (mz_uint16)(((tm->tm_year + 1900 - 1980) << 9) + ((tm->tm_mon + 1) << 5) + tm->tm_mday);
+}
+#endif /* MINIZ_NO_ARCHIVE_WRITING_APIS */
+
+#ifndef MINIZ_NO_STDIO
+#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS
+static mz_bool mz_zip_get_file_modified_time(const char *pFilename, MZ_TIME_T *pTime)
+{
+    struct MZ_FILE_STAT_STRUCT file_stat;
+
+    /* On Linux with x86 glibc, this call will fail on large files (I think >= 0x80000000 bytes) unless you compiled with _LARGEFILE64_SOURCE. Argh. */
+    if (MZ_FILE_STAT(pFilename, &file_stat) != 0)
+        return MZ_FALSE;
+
+    *pTime = file_stat.st_mtime;
+
+    return MZ_TRUE;
+}
+#endif /* #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS*/
+
+static mz_bool mz_zip_set_file_times(const char *pFilename, MZ_TIME_T access_time, MZ_TIME_T modified_time)
+{
+    struct utimbuf t;
+
+    memset(&t, 0, sizeof(t));
+    t.actime = access_time;
+    t.modtime = modified_time;
+
+    return !utime(pFilename, &t);
+}
+#endif /* #ifndef MINIZ_NO_STDIO */
+#endif /* #ifndef MINIZ_NO_TIME */
+
+static MZ_FORCEINLINE mz_bool mz_zip_set_error(mz_zip_archive *pZip, mz_zip_error err_num)
+{
+    if (pZip)
+        pZip->m_last_error = err_num;
+    return MZ_FALSE;
+}
+
+static mz_bool mz_zip_reader_init_internal(mz_zip_archive *pZip, mz_uint flags)
+{
+    (void)flags;
+    if ((!pZip) || (pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_INVALID))
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    if (!pZip->m_pAlloc)
+        pZip->m_pAlloc = miniz_def_alloc_func;
+    if (!pZip->m_pFree)
+        pZip->m_pFree = miniz_def_free_func;
+    if (!pZip->m_pRealloc)
+        pZip->m_pRealloc = miniz_def_realloc_func;
+
+    pZip->m_archive_size = 0;
+    pZip->m_central_directory_file_ofs = 0;
+    pZip->m_total_files = 0;
+    pZip->m_last_error = MZ_ZIP_NO_ERROR;
+
+    if (NULL == (pZip->m_pState = (mz_zip_internal_state *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(mz_zip_internal_state))))
+        return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+
+    memset(pZip->m_pState, 0, sizeof(mz_zip_internal_state));
+    MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir, sizeof(mz_uint8));
+    MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir_offsets, sizeof(mz_uint32));
+    MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_sorted_central_dir_offsets, sizeof(mz_uint32));
+    pZip->m_pState->m_init_flags = flags;
+    pZip->m_pState->m_zip64 = MZ_FALSE;
+    pZip->m_pState->m_zip64_has_extended_info_fields = MZ_FALSE;
+
+    pZip->m_zip_mode = MZ_ZIP_MODE_READING;
+
+    return MZ_TRUE;
+}
+
+static MZ_FORCEINLINE mz_bool mz_zip_reader_filename_less(const mz_zip_array *pCentral_dir_array, const mz_zip_array *pCentral_dir_offsets, mz_uint l_index, mz_uint r_index)
+{
+    const mz_uint8 *pL = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, l_index)), *pE;
+    const mz_uint8 *pR = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, r_index));
+    mz_uint l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS), r_len = MZ_READ_LE16(pR + MZ_ZIP_CDH_FILENAME_LEN_OFS);
+    mz_uint8 l = 0, r = 0;
+    pL += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE;
+    pR += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE;
+    pE = pL + MZ_MIN(l_len, r_len);
+    while (pL < pE)
+    {
+        if ((l = MZ_TOLOWER(*pL)) != (r = MZ_TOLOWER(*pR)))
+            break;
+        pL++;
+        pR++;
+    }
+    return (pL == pE) ? (l_len < r_len) : (l < r);
+}
+
+#define MZ_SWAP_UINT32(a, b) \
+    do                       \
+    {                        \
+        mz_uint32 t = a;     \
+        a = b;               \
+        b = t;               \
+    }                        \
+    MZ_MACRO_END
+
+/* Heap sort of lowercased filenames, used to help accelerate plain central directory searches by mz_zip_reader_locate_file(). (Could also use qsort(), but it could allocate memory.) */
+static void mz_zip_reader_sort_central_dir_offsets_by_filename(mz_zip_archive *pZip)
+{
+    mz_zip_internal_state *pState = pZip->m_pState;
+    const mz_zip_array *pCentral_dir_offsets = &pState->m_central_dir_offsets;
+    const mz_zip_array *pCentral_dir = &pState->m_central_dir;
+    mz_uint32 *pIndices;
+    mz_uint32 start, end;
+    const mz_uint32 size = pZip->m_total_files;
+
+    if (size <= 1U)
+        return;
+
+    pIndices = &MZ_ZIP_ARRAY_ELEMENT(&pState->m_sorted_central_dir_offsets, mz_uint32, 0);
+
+    start = (size - 2U) >> 1U;
+    for (;;)
+    {
+        mz_uint64 child, root = start;
+        for (;;)
+        {
+            if ((child = (root << 1U) + 1U) >= size)
+                break;
+            child += (((child + 1U) < size) && (mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[child], pIndices[child + 1U])));
+            if (!mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[root], pIndices[child]))
+                break;
+            MZ_SWAP_UINT32(pIndices[root], pIndices[child]);
+            root = child;
+        }
+        if (!start)
+            break;
+        start--;
+    }
+
+    end = size - 1;
+    while (end > 0)
+    {
+        mz_uint64 child, root = 0;
+        MZ_SWAP_UINT32(pIndices[end], pIndices[0]);
+        for (;;)
+        {
+            if ((child = (root << 1U) + 1U) >= end)
+                break;
+            child += (((child + 1U) < end) && mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[child], pIndices[child + 1U]));
+            if (!mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[root], pIndices[child]))
+                break;
+            MZ_SWAP_UINT32(pIndices[root], pIndices[child]);
+            root = child;
+        }
+        end--;
+    }
+}
+
+static mz_bool mz_zip_reader_locate_header_sig(mz_zip_archive *pZip, mz_uint32 record_sig, mz_uint32 record_size, mz_int64 *pOfs)
+{
+    mz_int64 cur_file_ofs;
+    mz_uint32 buf_u32[4096 / sizeof(mz_uint32)];
+    mz_uint8 *pBuf = (mz_uint8 *)buf_u32;
+
+    /* Basic sanity checks - reject files which are too small */
+    if (pZip->m_archive_size < record_size)
+        return MZ_FALSE;
+
+    /* Find the record by scanning the file from the end towards the beginning. */
+    cur_file_ofs = MZ_MAX((mz_int64)pZip->m_archive_size - (mz_int64)sizeof(buf_u32), 0);
+    for (;;)
+    {
+        int i, n = (int)MZ_MIN(sizeof(buf_u32), pZip->m_archive_size - cur_file_ofs);
+
+        if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, n) != (mz_uint)n)
+            return MZ_FALSE;
+
+        for (i = n - 4; i >= 0; --i)
+        {
+            mz_uint s = MZ_READ_LE32(pBuf + i);
+            if (s == record_sig)
+            {
+                if ((pZip->m_archive_size - (cur_file_ofs + i)) >= record_size)
+                    break;
+            }
+        }
+
+        if (i >= 0)
+        {
+            cur_file_ofs += i;
+            break;
+        }
+
+        /* Give up if we've searched the entire file, or we've gone back "too far" (~64kb) */
+        if ((!cur_file_ofs) || ((pZip->m_archive_size - cur_file_ofs) >= (MZ_UINT16_MAX + record_size)))
+            return MZ_FALSE;
+
+        cur_file_ofs = MZ_MAX(cur_file_ofs - (sizeof(buf_u32) - 3), 0);
+    }
+
+    *pOfs = cur_file_ofs;
+    return MZ_TRUE;
+}
+
+static mz_bool mz_zip_reader_read_central_dir(mz_zip_archive *pZip, mz_uint flags)
+{
+    mz_uint cdir_size = 0, cdir_entries_on_this_disk = 0, num_this_disk = 0, cdir_disk_index = 0;
+    mz_uint64 cdir_ofs = 0;
+    mz_int64 cur_file_ofs = 0;
+    const mz_uint8 *p;
+
+    mz_uint32 buf_u32[4096 / sizeof(mz_uint32)];
+    mz_uint8 *pBuf = (mz_uint8 *)buf_u32;
+    mz_bool sort_central_dir = ((flags & MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY) == 0);
+    mz_uint32 zip64_end_of_central_dir_locator_u32[(MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)];
+    mz_uint8 *pZip64_locator = (mz_uint8 *)zip64_end_of_central_dir_locator_u32;
+
+    mz_uint32 zip64_end_of_central_dir_header_u32[(MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)];
+    mz_uint8 *pZip64_end_of_central_dir = (mz_uint8 *)zip64_end_of_central_dir_header_u32;
+
+    mz_uint64 zip64_end_of_central_dir_ofs = 0;
+
+    /* Basic sanity checks - reject files which are too small, and check the first 4 bytes of the file to make sure a local header is there. */
+    if (pZip->m_archive_size < MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE)
+        return mz_zip_set_error(pZip, MZ_ZIP_NOT_AN_ARCHIVE);
+
+    if (!mz_zip_reader_locate_header_sig(pZip, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE, &cur_file_ofs))
+        return mz_zip_set_error(pZip, MZ_ZIP_FAILED_FINDING_CENTRAL_DIR);
+
+    /* Read and verify the end of central directory record. */
+    if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) != MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE)
+        return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
+
+    if (MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_SIG_OFS) != MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG)
+        return mz_zip_set_error(pZip, MZ_ZIP_NOT_AN_ARCHIVE);
+
+    if (cur_file_ofs >= (MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIZE + MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIZE))
+    {
+        if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs - MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIZE, pZip64_locator, MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIZE) == MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIZE)
+        {
+            if (MZ_READ_LE32(pZip64_locator + MZ_ZIP64_ECDL_SIG_OFS) == MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIG)
+            {
+                zip64_end_of_central_dir_ofs = MZ_READ_LE64(pZip64_locator + MZ_ZIP64_ECDL_REL_OFS_TO_ZIP64_ECDR_OFS);
+                if (zip64_end_of_central_dir_ofs > (pZip->m_archive_size - MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIZE))
+                    return mz_zip_set_error(pZip, MZ_ZIP_NOT_AN_ARCHIVE);
+
+                if (pZip->m_pRead(pZip->m_pIO_opaque, zip64_end_of_central_dir_ofs, pZip64_end_of_central_dir, MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIZE) == MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIZE)
+                {
+                    if (MZ_READ_LE32(pZip64_end_of_central_dir + MZ_ZIP64_ECDH_SIG_OFS) == MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIG)
+                    {
+                        pZip->m_pState->m_zip64 = MZ_TRUE;
+                    }
+                }
+            }
+        }
+    }
+
+    pZip->m_total_files = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS);
+    cdir_entries_on_this_disk = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS);
+    num_this_disk = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_NUM_THIS_DISK_OFS);
+    cdir_disk_index = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_NUM_DISK_CDIR_OFS);
+    cdir_size = MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_CDIR_SIZE_OFS);
+    cdir_ofs = MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_CDIR_OFS_OFS);
+
+    if (pZip->m_pState->m_zip64)
+    {
+        mz_uint32 zip64_total_num_of_disks = MZ_READ_LE32(pZip64_locator + MZ_ZIP64_ECDL_TOTAL_NUMBER_OF_DISKS_OFS);
+        mz_uint64 zip64_cdir_total_entries = MZ_READ_LE64(pZip64_end_of_central_dir + MZ_ZIP64_ECDH_CDIR_TOTAL_ENTRIES_OFS);
+        mz_uint64 zip64_cdir_total_entries_on_this_disk = MZ_READ_LE64(pZip64_end_of_central_dir + MZ_ZIP64_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS);
+        mz_uint64 zip64_size_of_end_of_central_dir_record = MZ_READ_LE64(pZip64_end_of_central_dir + MZ_ZIP64_ECDH_SIZE_OF_RECORD_OFS);
+        mz_uint64 zip64_size_of_central_directory = MZ_READ_LE64(pZip64_end_of_central_dir + MZ_ZIP64_ECDH_CDIR_SIZE_OFS);
+
+        if (zip64_size_of_end_of_central_dir_record < (MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIZE - 12))
+            return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+
+        if (zip64_total_num_of_disks != 1U)
+            return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_MULTIDISK);
+
+        /* Check for miniz's practical limits */
+        if (zip64_cdir_total_entries > MZ_UINT32_MAX)
+            return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES);
+
+        pZip->m_total_files = (mz_uint32)zip64_cdir_total_entries;
+
+        if (zip64_cdir_total_entries_on_this_disk > MZ_UINT32_MAX)
+            return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES);
+
+        cdir_entries_on_this_disk = (mz_uint32)zip64_cdir_total_entries_on_this_disk;
+
+        /* Check for miniz's current practical limits (sorry, this should be enough for millions of files) */
+        if (zip64_size_of_central_directory > MZ_UINT32_MAX)
+            return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_CDIR_SIZE);
+
+        cdir_size = (mz_uint32)zip64_size_of_central_directory;
+
+        num_this_disk = MZ_READ_LE32(pZip64_end_of_central_dir + MZ_ZIP64_ECDH_NUM_THIS_DISK_OFS);
+
+        cdir_disk_index = MZ_READ_LE32(pZip64_end_of_central_dir + MZ_ZIP64_ECDH_NUM_DISK_CDIR_OFS);
+
+        cdir_ofs = MZ_READ_LE64(pZip64_end_of_central_dir + MZ_ZIP64_ECDH_CDIR_OFS_OFS);
+    }
+
+    if (pZip->m_total_files != cdir_entries_on_this_disk)
+        return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_MULTIDISK);
+
+    if (((num_this_disk | cdir_disk_index) != 0) && ((num_this_disk != 1) || (cdir_disk_index != 1)))
+        return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_MULTIDISK);
+
+    if (cdir_size < pZip->m_total_files * MZ_ZIP_CENTRAL_DIR_HEADER_SIZE)
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+
+    if ((cdir_ofs + (mz_uint64)cdir_size) > pZip->m_archive_size)
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+
+    pZip->m_central_directory_file_ofs = cdir_ofs;
+
+    if (pZip->m_total_files)
+    {
+        mz_uint i, n;
+        /* Read the entire central directory into a heap block, and allocate another heap block to hold the unsorted central dir file record offsets, and possibly another to hold the sorted indices. */
+        if ((!mz_zip_array_resize(pZip, &pZip->m_pState->m_central_dir, cdir_size, MZ_FALSE)) ||
+            (!mz_zip_array_resize(pZip, &pZip->m_pState->m_central_dir_offsets, pZip->m_total_files, MZ_FALSE)))
+            return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+
+        if (sort_central_dir)
+        {
+            if (!mz_zip_array_resize(pZip, &pZip->m_pState->m_sorted_central_dir_offsets, pZip->m_total_files, MZ_FALSE))
+                return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+        }
+
+        if (pZip->m_pRead(pZip->m_pIO_opaque, cdir_ofs, pZip->m_pState->m_central_dir.m_p, cdir_size) != cdir_size)
+            return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
+
+        /* Now create an index into the central directory file records, do some basic sanity checking on each record */
+        p = (const mz_uint8 *)pZip->m_pState->m_central_dir.m_p;
+        for (n = cdir_size, i = 0; i < pZip->m_total_files; ++i)
+        {
+            mz_uint total_header_size, disk_index, bit_flags, filename_size, ext_data_size;
+            mz_uint64 comp_size, decomp_size, local_header_ofs;
+
+            if ((n < MZ_ZIP_CENTRAL_DIR_HEADER_SIZE) || (MZ_READ_LE32(p) != MZ_ZIP_CENTRAL_DIR_HEADER_SIG))
+                return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+
+            MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, i) = (mz_uint32)(p - (const mz_uint8 *)pZip->m_pState->m_central_dir.m_p);
+
+            if (sort_central_dir)
+                MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_sorted_central_dir_offsets, mz_uint32, i) = i;
+
+            comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS);
+            decomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS);
+            local_header_ofs = MZ_READ_LE32(p + MZ_ZIP_CDH_LOCAL_HEADER_OFS);
+            filename_size = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS);
+            ext_data_size = MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS);
+
+            if ((!pZip->m_pState->m_zip64_has_extended_info_fields) &&
+                (ext_data_size) &&
+                (MZ_MAX(MZ_MAX(comp_size, decomp_size), local_header_ofs) == MZ_UINT32_MAX))
+            {
+                /* Attempt to find zip64 extended information field in the entry's extra data */
+                mz_uint32 extra_size_remaining = ext_data_size;
+
+                if (extra_size_remaining)
+                {
+                    const mz_uint8 *pExtra_data = p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_size;
+
+                    do
+                    {
+                        mz_uint32 field_id;
+                        mz_uint32 field_data_size;
+
+                        if (extra_size_remaining < (sizeof(mz_uint16) * 2))
+                            return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+
+                        field_id = MZ_READ_LE16(pExtra_data);
+                        field_data_size = MZ_READ_LE16(pExtra_data + sizeof(mz_uint16));
+
+                        if ((field_data_size + sizeof(mz_uint16) * 2) > extra_size_remaining)
+                            return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+
+                        if (field_id == MZ_ZIP64_EXTENDED_INFORMATION_FIELD_HEADER_ID)
+                        {
+                            /* Ok, the archive didn't have any zip64 headers but it uses a zip64 extended information field so mark it as zip64 anyway (this can occur with infozip's zip util when it reads compresses files from stdin). */
+                            pZip->m_pState->m_zip64 = MZ_TRUE;
+                            pZip->m_pState->m_zip64_has_extended_info_fields = MZ_TRUE;
+                            break;
+                        }
+
+                        pExtra_data += sizeof(mz_uint16) * 2 + field_data_size;
+                        extra_size_remaining = extra_size_remaining - sizeof(mz_uint16) * 2 - field_data_size;
+                    } while (extra_size_remaining);
+                }
+            }
+
+            /* I've seen archives that aren't marked as zip64 that uses zip64 ext data, argh */
+            if ((comp_size != MZ_UINT32_MAX) && (decomp_size != MZ_UINT32_MAX))
+            {
+                if (((!MZ_READ_LE32(p + MZ_ZIP_CDH_METHOD_OFS)) && (decomp_size != comp_size)) || (decomp_size && !comp_size))
+                    return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+            }
+
+            disk_index = MZ_READ_LE16(p + MZ_ZIP_CDH_DISK_START_OFS);
+            if ((disk_index == MZ_UINT16_MAX) || ((disk_index != num_this_disk) && (disk_index != 1)))
+                return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_MULTIDISK);
+
+            if (comp_size != MZ_UINT32_MAX)
+            {
+                if (((mz_uint64)MZ_READ_LE32(p + MZ_ZIP_CDH_LOCAL_HEADER_OFS) + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + comp_size) > pZip->m_archive_size)
+                    return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+            }
+
+            bit_flags = MZ_READ_LE16(p + MZ_ZIP_CDH_BIT_FLAG_OFS);
+            if (bit_flags & MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_LOCAL_DIR_IS_MASKED)
+                return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_ENCRYPTION);
+
+            if ((total_header_size = MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS) + MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS) + MZ_READ_LE16(p + MZ_ZIP_CDH_COMMENT_LEN_OFS)) > n)
+                return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+
+            n -= total_header_size;
+            p += total_header_size;
+        }
+    }
+
+    if (sort_central_dir)
+        mz_zip_reader_sort_central_dir_offsets_by_filename(pZip);
+
+    return MZ_TRUE;
+}
+
+void mz_zip_zero_struct(mz_zip_archive *pZip)
+{
+    if (pZip)
+        MZ_CLEAR_OBJ(*pZip);
+}
+
+static mz_bool mz_zip_reader_end_internal(mz_zip_archive *pZip, mz_bool set_last_error)
+{
+    mz_bool status = MZ_TRUE;
+
+    if (!pZip)
+        return MZ_FALSE;
+
+    if ((!pZip->m_pState) || (!pZip->m_pAlloc) || (!pZip->m_pFree) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING))
+    {
+        if (set_last_error)
+            pZip->m_last_error = MZ_ZIP_INVALID_PARAMETER;
+
+        return MZ_FALSE;
+    }
+
+    if (pZip->m_pState)
+    {
+        mz_zip_internal_state *pState = pZip->m_pState;
+        pZip->m_pState = NULL;
+
+        mz_zip_array_clear(pZip, &pState->m_central_dir);
+        mz_zip_array_clear(pZip, &pState->m_central_dir_offsets);
+        mz_zip_array_clear(pZip, &pState->m_sorted_central_dir_offsets);
+
+#ifndef MINIZ_NO_STDIO
+        if (pState->m_pFile)
+        {
+            if (pZip->m_zip_type == MZ_ZIP_TYPE_FILE)
+            {
+                if (MZ_FCLOSE(pState->m_pFile) == EOF)
+                {
+                    if (set_last_error)
+                        pZip->m_last_error = MZ_ZIP_FILE_CLOSE_FAILED;
+                    status = MZ_FALSE;
+                }
+            }
+            pState->m_pFile = NULL;
+        }
+#endif /* #ifndef MINIZ_NO_STDIO */
+
+        pZip->m_pFree(pZip->m_pAlloc_opaque, pState);
+    }
+    pZip->m_zip_mode = MZ_ZIP_MODE_INVALID;
+
+    return status;
+}
+
+mz_bool mz_zip_reader_end(mz_zip_archive *pZip)
+{
+    return mz_zip_reader_end_internal(pZip, MZ_TRUE);
+}
+mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, mz_uint flags)
+{
+    if ((!pZip) || (!pZip->m_pRead))
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    if (!mz_zip_reader_init_internal(pZip, flags))
+        return MZ_FALSE;
+
+    pZip->m_zip_type = MZ_ZIP_TYPE_USER;
+    pZip->m_archive_size = size;
+
+    if (!mz_zip_reader_read_central_dir(pZip, flags))
+    {
+        mz_zip_reader_end_internal(pZip, MZ_FALSE);
+        return MZ_FALSE;
+    }
+
+    return MZ_TRUE;
+}
+
+static size_t mz_zip_mem_read_func(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n)
+{
+    mz_zip_archive *pZip = (mz_zip_archive *)pOpaque;
+    size_t s = (file_ofs >= pZip->m_archive_size) ? 0 : (size_t)MZ_MIN(pZip->m_archive_size - file_ofs, n);
+    memcpy(pBuf, (const mz_uint8 *)pZip->m_pState->m_pMem + file_ofs, s);
+    return s;
+}
+
+mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint flags)
+{
+    if (!pMem)
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    if (size < MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE)
+        return mz_zip_set_error(pZip, MZ_ZIP_NOT_AN_ARCHIVE);
+
+    if (!mz_zip_reader_init_internal(pZip, flags))
+        return MZ_FALSE;
+
+    pZip->m_zip_type = MZ_ZIP_TYPE_MEMORY;
+    pZip->m_archive_size = size;
+    pZip->m_pRead = mz_zip_mem_read_func;
+    pZip->m_pIO_opaque = pZip;
+    pZip->m_pNeeds_keepalive = NULL;
+
+#ifdef __cplusplus
+    pZip->m_pState->m_pMem = const_cast<void *>(pMem);
+#else
+    pZip->m_pState->m_pMem = (void *)pMem;
+#endif
+
+    pZip->m_pState->m_mem_size = size;
+
+    if (!mz_zip_reader_read_central_dir(pZip, flags))
+    {
+        mz_zip_reader_end_internal(pZip, MZ_FALSE);
+        return MZ_FALSE;
+    }
+
+    return MZ_TRUE;
+}
+
+#ifndef MINIZ_NO_STDIO
+static size_t mz_zip_file_read_func(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n)
+{
+    mz_zip_archive *pZip = (mz_zip_archive *)pOpaque;
+    mz_int64 cur_ofs = MZ_FTELL64(pZip->m_pState->m_pFile);
+
+    file_ofs += pZip->m_pState->m_file_archive_start_ofs;
+
+    if (((mz_int64)file_ofs < 0) || (((cur_ofs != (mz_int64)file_ofs)) && (MZ_FSEEK64(pZip->m_pState->m_pFile, (mz_int64)file_ofs, SEEK_SET))))
+        return 0;
+
+    return MZ_FREAD(pBuf, 1, n, pZip->m_pState->m_pFile);
+}
+
+mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags)
+{
+    return mz_zip_reader_init_file_v2(pZip, pFilename, flags, 0, 0);
+}
+
+mz_bool mz_zip_reader_init_file_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint flags, mz_uint64 file_start_ofs, mz_uint64 archive_size)
+{
+    mz_uint64 file_size;
+    MZ_FILE *pFile;
+
+    if ((!pZip) || (!pFilename) || ((archive_size) && (archive_size < MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE)))
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    pFile = MZ_FOPEN(pFilename, "rb");
+    if (!pFile)
+        return mz_zip_set_error(pZip, MZ_ZIP_FILE_OPEN_FAILED);
+
+    file_size = archive_size;
+    if (!file_size)
+    {
+        if (MZ_FSEEK64(pFile, 0, SEEK_END))
+        {
+            MZ_FCLOSE(pFile);
+            return mz_zip_set_error(pZip, MZ_ZIP_FILE_SEEK_FAILED);
+        }
+
+        file_size = MZ_FTELL64(pFile);
+    }
+
+    /* TODO: Better sanity check archive_size and the # of actual remaining bytes */
+
+    if (file_size < MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE)
+    {
+	MZ_FCLOSE(pFile);
+        return mz_zip_set_error(pZip, MZ_ZIP_NOT_AN_ARCHIVE);
+    }
+
+    if (!mz_zip_reader_init_internal(pZip, flags))
+    {
+        MZ_FCLOSE(pFile);
+        return MZ_FALSE;
+    }
+
+    pZip->m_zip_type = MZ_ZIP_TYPE_FILE;
+    pZip->m_pRead = mz_zip_file_read_func;
+    pZip->m_pIO_opaque = pZip;
+    pZip->m_pState->m_pFile = pFile;
+    pZip->m_archive_size = file_size;
+    pZip->m_pState->m_file_archive_start_ofs = file_start_ofs;
+
+    if (!mz_zip_reader_read_central_dir(pZip, flags))
+    {
+        mz_zip_reader_end_internal(pZip, MZ_FALSE);
+        return MZ_FALSE;
+    }
+
+    return MZ_TRUE;
+}
+
+mz_bool mz_zip_reader_init_cfile(mz_zip_archive *pZip, MZ_FILE *pFile, mz_uint64 archive_size, mz_uint flags)
+{
+    mz_uint64 cur_file_ofs;
+
+    if ((!pZip) || (!pFile))
+        return mz_zip_set_error(pZip, MZ_ZIP_FILE_OPEN_FAILED);
+
+    cur_file_ofs = MZ_FTELL64(pFile);
+
+    if (!archive_size)
+    {
+        if (MZ_FSEEK64(pFile, 0, SEEK_END))
+            return mz_zip_set_error(pZip, MZ_ZIP_FILE_SEEK_FAILED);
+
+        archive_size = MZ_FTELL64(pFile) - cur_file_ofs;
+
+        if (archive_size < MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE)
+            return mz_zip_set_error(pZip, MZ_ZIP_NOT_AN_ARCHIVE);
+    }
+
+    if (!mz_zip_reader_init_internal(pZip, flags))
+        return MZ_FALSE;
+
+    pZip->m_zip_type = MZ_ZIP_TYPE_CFILE;
+    pZip->m_pRead = mz_zip_file_read_func;
+
+    pZip->m_pIO_opaque = pZip;
+    pZip->m_pState->m_pFile = pFile;
+    pZip->m_archive_size = archive_size;
+    pZip->m_pState->m_file_archive_start_ofs = cur_file_ofs;
+
+    if (!mz_zip_reader_read_central_dir(pZip, flags))
+    {
+        mz_zip_reader_end_internal(pZip, MZ_FALSE);
+        return MZ_FALSE;
+    }
+
+    return MZ_TRUE;
+}
+
+#endif /* #ifndef MINIZ_NO_STDIO */
+
+static MZ_FORCEINLINE const mz_uint8 *mz_zip_get_cdh(mz_zip_archive *pZip, mz_uint file_index)
+{
+    if ((!pZip) || (!pZip->m_pState) || (file_index >= pZip->m_total_files))
+        return NULL;
+    return &MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index));
+}
+
+mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index)
+{
+    mz_uint m_bit_flag;
+    const mz_uint8 *p = mz_zip_get_cdh(pZip, file_index);
+    if (!p)
+    {
+        mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+        return MZ_FALSE;
+    }
+
+    m_bit_flag = MZ_READ_LE16(p + MZ_ZIP_CDH_BIT_FLAG_OFS);
+    return (m_bit_flag & (MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_IS_ENCRYPTED | MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_USES_STRONG_ENCRYPTION)) != 0;
+}
+
+mz_bool mz_zip_reader_is_file_supported(mz_zip_archive *pZip, mz_uint file_index)
+{
+    mz_uint bit_flag;
+    mz_uint method;
+
+    const mz_uint8 *p = mz_zip_get_cdh(pZip, file_index);
+    if (!p)
+    {
+        mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+        return MZ_FALSE;
+    }
+
+    method = MZ_READ_LE16(p + MZ_ZIP_CDH_METHOD_OFS);
+    bit_flag = MZ_READ_LE16(p + MZ_ZIP_CDH_BIT_FLAG_OFS);
+
+    if ((method != 0) && (method != MZ_DEFLATED))
+    {
+        mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_METHOD);
+        return MZ_FALSE;
+    }
+
+    if (bit_flag & (MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_IS_ENCRYPTED | MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_USES_STRONG_ENCRYPTION))
+    {
+        mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_ENCRYPTION);
+        return MZ_FALSE;
+    }
+
+    if (bit_flag & MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_COMPRESSED_PATCH_FLAG)
+    {
+        mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_FEATURE);
+        return MZ_FALSE;
+    }
+
+    return MZ_TRUE;
+}
+
+mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index)
+{
+    mz_uint filename_len, attribute_mapping_id, external_attr;
+    const mz_uint8 *p = mz_zip_get_cdh(pZip, file_index);
+    if (!p)
+    {
+        mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+        return MZ_FALSE;
+    }
+
+    filename_len = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS);
+    if (filename_len)
+    {
+        if (*(p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_len - 1) == '/')
+            return MZ_TRUE;
+    }
+
+    /* Bugfix: This code was also checking if the internal attribute was non-zero, which wasn't correct. */
+    /* Most/all zip writers (hopefully) set DOS file/directory attributes in the low 16-bits, so check for the DOS directory flag and ignore the source OS ID in the created by field. */
+    /* FIXME: Remove this check? Is it necessary - we already check the filename. */
+    attribute_mapping_id = MZ_READ_LE16(p + MZ_ZIP_CDH_VERSION_MADE_BY_OFS) >> 8;
+    (void)attribute_mapping_id;
+
+    external_attr = MZ_READ_LE32(p + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS);
+    if ((external_attr & MZ_ZIP_DOS_DIR_ATTRIBUTE_BITFLAG) != 0)
+    {
+        return MZ_TRUE;
+    }
+
+    return MZ_FALSE;
+}
+
+static mz_bool mz_zip_file_stat_internal(mz_zip_archive *pZip, mz_uint file_index, const mz_uint8 *pCentral_dir_header, mz_zip_archive_file_stat *pStat, mz_bool *pFound_zip64_extra_data)
+{
+    mz_uint n;
+    const mz_uint8 *p = pCentral_dir_header;
+
+    if (pFound_zip64_extra_data)
+        *pFound_zip64_extra_data = MZ_FALSE;
+
+    if ((!p) || (!pStat))
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    /* Extract fields from the central directory record. */
+    pStat->m_file_index = file_index;
+    pStat->m_central_dir_ofs = MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index);
+    pStat->m_version_made_by = MZ_READ_LE16(p + MZ_ZIP_CDH_VERSION_MADE_BY_OFS);
+    pStat->m_version_needed = MZ_READ_LE16(p + MZ_ZIP_CDH_VERSION_NEEDED_OFS);
+    pStat->m_bit_flag = MZ_READ_LE16(p + MZ_ZIP_CDH_BIT_FLAG_OFS);
+    pStat->m_method = MZ_READ_LE16(p + MZ_ZIP_CDH_METHOD_OFS);
+#ifndef MINIZ_NO_TIME
+    pStat->m_time = mz_zip_dos_to_time_t(MZ_READ_LE16(p + MZ_ZIP_CDH_FILE_TIME_OFS), MZ_READ_LE16(p + MZ_ZIP_CDH_FILE_DATE_OFS));
+#endif
+    pStat->m_crc32 = MZ_READ_LE32(p + MZ_ZIP_CDH_CRC32_OFS);
+    pStat->m_comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS);
+    pStat->m_uncomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS);
+    pStat->m_internal_attr = MZ_READ_LE16(p + MZ_ZIP_CDH_INTERNAL_ATTR_OFS);
+    pStat->m_external_attr = MZ_READ_LE32(p + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS);
+    pStat->m_local_header_ofs = MZ_READ_LE32(p + MZ_ZIP_CDH_LOCAL_HEADER_OFS);
+
+    /* Copy as much of the filename and comment as possible. */
+    n = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS);
+    n = MZ_MIN(n, MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE - 1);
+    memcpy(pStat->m_filename, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n);
+    pStat->m_filename[n] = '\0';
+
+    n = MZ_READ_LE16(p + MZ_ZIP_CDH_COMMENT_LEN_OFS);
+    n = MZ_MIN(n, MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE - 1);
+    pStat->m_comment_size = n;
+    memcpy(pStat->m_comment, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS) + MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS), n);
+    pStat->m_comment[n] = '\0';
+
+    /* Set some flags for convienance */
+    pStat->m_is_directory = mz_zip_reader_is_file_a_directory(pZip, file_index);
+    pStat->m_is_encrypted = mz_zip_reader_is_file_encrypted(pZip, file_index);
+    pStat->m_is_supported = mz_zip_reader_is_file_supported(pZip, file_index);
+
+    /* See if we need to read any zip64 extended information fields. */
+    /* Confusingly, these zip64 fields can be present even on non-zip64 archives (Debian zip on a huge files from stdin piped to stdout creates them). */
+    if (MZ_MAX(MZ_MAX(pStat->m_comp_size, pStat->m_uncomp_size), pStat->m_local_header_ofs) == MZ_UINT32_MAX)
+    {
+        /* Attempt to find zip64 extended information field in the entry's extra data */
+        mz_uint32 extra_size_remaining = MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS);
+
+        if (extra_size_remaining)
+        {
+            const mz_uint8 *pExtra_data = p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS);
+
+            do
+            {
+                mz_uint32 field_id;
+                mz_uint32 field_data_size;
+
+                if (extra_size_remaining < (sizeof(mz_uint16) * 2))
+                    return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+
+                field_id = MZ_READ_LE16(pExtra_data);
+                field_data_size = MZ_READ_LE16(pExtra_data + sizeof(mz_uint16));
+
+                if ((field_data_size + sizeof(mz_uint16) * 2) > extra_size_remaining)
+                    return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+
+                if (field_id == MZ_ZIP64_EXTENDED_INFORMATION_FIELD_HEADER_ID)
+                {
+                    const mz_uint8 *pField_data = pExtra_data + sizeof(mz_uint16) * 2;
+                    mz_uint32 field_data_remaining = field_data_size;
+
+                    if (pFound_zip64_extra_data)
+                        *pFound_zip64_extra_data = MZ_TRUE;
+
+                    if (pStat->m_uncomp_size == MZ_UINT32_MAX)
+                    {
+                        if (field_data_remaining < sizeof(mz_uint64))
+                            return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+
+                        pStat->m_uncomp_size = MZ_READ_LE64(pField_data);
+                        pField_data += sizeof(mz_uint64);
+                        field_data_remaining -= sizeof(mz_uint64);
+                    }
+
+                    if (pStat->m_comp_size == MZ_UINT32_MAX)
+                    {
+                        if (field_data_remaining < sizeof(mz_uint64))
+                            return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+
+                        pStat->m_comp_size = MZ_READ_LE64(pField_data);
+                        pField_data += sizeof(mz_uint64);
+                        field_data_remaining -= sizeof(mz_uint64);
+                    }
+
+                    if (pStat->m_local_header_ofs == MZ_UINT32_MAX)
+                    {
+                        if (field_data_remaining < sizeof(mz_uint64))
+                            return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+
+                        pStat->m_local_header_ofs = MZ_READ_LE64(pField_data);
+                        pField_data += sizeof(mz_uint64);
+                        field_data_remaining -= sizeof(mz_uint64);
+                    }
+
+                    break;
+                }
+
+                pExtra_data += sizeof(mz_uint16) * 2 + field_data_size;
+                extra_size_remaining = extra_size_remaining - sizeof(mz_uint16) * 2 - field_data_size;
+            } while (extra_size_remaining);
+        }
+    }
+
+    return MZ_TRUE;
+}
+
+static MZ_FORCEINLINE mz_bool mz_zip_string_equal(const char *pA, const char *pB, mz_uint len, mz_uint flags)
+{
+    mz_uint i;
+    if (flags & MZ_ZIP_FLAG_CASE_SENSITIVE)
+        return 0 == memcmp(pA, pB, len);
+    for (i = 0; i < len; ++i)
+        if (MZ_TOLOWER(pA[i]) != MZ_TOLOWER(pB[i]))
+            return MZ_FALSE;
+    return MZ_TRUE;
+}
+
+static MZ_FORCEINLINE int mz_zip_filename_compare(const mz_zip_array *pCentral_dir_array, const mz_zip_array *pCentral_dir_offsets, mz_uint l_index, const char *pR, mz_uint r_len)
+{
+    const mz_uint8 *pL = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, l_index)), *pE;
+    mz_uint l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS);
+    mz_uint8 l = 0, r = 0;
+    pL += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE;
+    pE = pL + MZ_MIN(l_len, r_len);
+    while (pL < pE)
+    {
+        if ((l = MZ_TOLOWER(*pL)) != (r = MZ_TOLOWER(*pR)))
+            break;
+        pL++;
+        pR++;
+    }
+    return (pL == pE) ? (int)(l_len - r_len) : (l - r);
+}
+
+static mz_bool mz_zip_locate_file_binary_search(mz_zip_archive *pZip, const char *pFilename, mz_uint32 *pIndex)
+{
+    mz_zip_internal_state *pState = pZip->m_pState;
+    const mz_zip_array *pCentral_dir_offsets = &pState->m_central_dir_offsets;
+    const mz_zip_array *pCentral_dir = &pState->m_central_dir;
+    mz_uint32 *pIndices = &MZ_ZIP_ARRAY_ELEMENT(&pState->m_sorted_central_dir_offsets, mz_uint32, 0);
+    const uint32_t size = pZip->m_total_files;
+    const mz_uint filename_len = (mz_uint)strlen(pFilename);
+
+    if (pIndex)
+        *pIndex = 0;
+
+    if (size)
+    {
+        /* yes I could use uint32_t's, but then we would have to add some special case checks in the loop, argh, and */
+        /* honestly the major expense here on 32-bit CPU's will still be the filename compare */
+        mz_int64 l = 0, h = (mz_int64)size - 1;
+
+        while (l <= h)
+        {
+            mz_int64 m = l + ((h - l) >> 1);
+            uint32_t file_index = pIndices[(uint32_t)m];
+
+            int comp = mz_zip_filename_compare(pCentral_dir, pCentral_dir_offsets, file_index, pFilename, filename_len);
+            if (!comp)
+            {
+                if (pIndex)
+                    *pIndex = file_index;
+                return MZ_TRUE;
+            }
+            else if (comp < 0)
+                l = m + 1;
+            else
+                h = m - 1;
+        }
+    }
+
+    return mz_zip_set_error(pZip, MZ_ZIP_FILE_NOT_FOUND);
+}
+
+int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags)
+{
+    mz_uint32 index;
+    if (!mz_zip_reader_locate_file_v2(pZip, pName, pComment, flags, &index))
+        return -1;
+    else
+        return (int)index;
+}
+
+mz_bool mz_zip_reader_locate_file_v2(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags, mz_uint32 *pIndex)
+{
+    mz_uint file_index;
+    size_t name_len, comment_len;
+
+    if (pIndex)
+        *pIndex = 0;
+
+    if ((!pZip) || (!pZip->m_pState) || (!pName))
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    /* See if we can use a binary search */
+    if (((pZip->m_pState->m_init_flags & MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY) == 0) &&
+        (pZip->m_zip_mode == MZ_ZIP_MODE_READING) &&
+        ((flags & (MZ_ZIP_FLAG_IGNORE_PATH | MZ_ZIP_FLAG_CASE_SENSITIVE)) == 0) && (!pComment) && (pZip->m_pState->m_sorted_central_dir_offsets.m_size))
+    {
+        return mz_zip_locate_file_binary_search(pZip, pName, pIndex);
+    }
+
+    /* Locate the entry by scanning the entire central directory */
+    name_len = strlen(pName);
+    if (name_len > MZ_UINT16_MAX)
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    comment_len = pComment ? strlen(pComment) : 0;
+    if (comment_len > MZ_UINT16_MAX)
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    for (file_index = 0; file_index < pZip->m_total_files; file_index++)
+    {
+        const mz_uint8 *pHeader = &MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index));
+        mz_uint filename_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_FILENAME_LEN_OFS);
+        const char *pFilename = (const char *)pHeader + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE;
+        if (filename_len < name_len)
+            continue;
+        if (comment_len)
+        {
+            mz_uint file_extra_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_EXTRA_LEN_OFS), file_comment_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_COMMENT_LEN_OFS);
+            const char *pFile_comment = pFilename + filename_len + file_extra_len;
+            if ((file_comment_len != comment_len) || (!mz_zip_string_equal(pComment, pFile_comment, file_comment_len, flags)))
+                continue;
+        }
+        if ((flags & MZ_ZIP_FLAG_IGNORE_PATH) && (filename_len))
+        {
+            int ofs = filename_len - 1;
+            do
+            {
+                if ((pFilename[ofs] == '/') || (pFilename[ofs] == '\\') || (pFilename[ofs] == ':'))
+                    break;
+            } while (--ofs >= 0);
+            ofs++;
+            pFilename += ofs;
+            filename_len -= ofs;
+        }
+        if ((filename_len == name_len) && (mz_zip_string_equal(pName, pFilename, filename_len, flags)))
+        {
+            if (pIndex)
+                *pIndex = file_index;
+            return MZ_TRUE;
+        }
+    }
+
+    return mz_zip_set_error(pZip, MZ_ZIP_FILE_NOT_FOUND);
+}
+
+mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size)
+{
+    int status = TINFL_STATUS_DONE;
+    mz_uint64 needed_size, cur_file_ofs, comp_remaining, out_buf_ofs = 0, read_buf_size, read_buf_ofs = 0, read_buf_avail;
+    mz_zip_archive_file_stat file_stat;
+    void *pRead_buf;
+    mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)];
+    mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32;
+    tinfl_decompressor inflator;
+
+    if ((!pZip) || (!pZip->m_pState) || ((buf_size) && (!pBuf)) || ((user_read_buf_size) && (!pUser_read_buf)) || (!pZip->m_pRead))
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat))
+        return MZ_FALSE;
+
+    /* A directory or zero length file */
+    if ((file_stat.m_is_directory) || (!file_stat.m_comp_size))
+        return MZ_TRUE;
+
+    /* Encryption and patch files are not supported. */
+    if (file_stat.m_bit_flag & (MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_IS_ENCRYPTED | MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_USES_STRONG_ENCRYPTION | MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_COMPRESSED_PATCH_FLAG))
+        return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_ENCRYPTION);
+
+    /* This function only supports decompressing stored and deflate. */
+    if ((!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (file_stat.m_method != 0) && (file_stat.m_method != MZ_DEFLATED))
+        return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_METHOD);
+
+    /* Ensure supplied output buffer is large enough. */
+    needed_size = (flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ? file_stat.m_comp_size : file_stat.m_uncomp_size;
+    if (buf_size < needed_size)
+        return mz_zip_set_error(pZip, MZ_ZIP_BUF_TOO_SMALL);
+
+    /* Read and parse the local directory entry. */
+    cur_file_ofs = file_stat.m_local_header_ofs;
+    if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE)
+        return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
+
+    if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG)
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+
+    cur_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS);
+    if ((cur_file_ofs + file_stat.m_comp_size) > pZip->m_archive_size)
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+
+    if ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!file_stat.m_method))
+    {
+        /* The file is stored or the caller has requested the compressed data. */
+        if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, (size_t)needed_size) != needed_size)
+            return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
+
+#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
+        if ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) == 0)
+        {
+            if (mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf, (size_t)file_stat.m_uncomp_size) != file_stat.m_crc32)
+                return mz_zip_set_error(pZip, MZ_ZIP_CRC_CHECK_FAILED);
+        }
+#endif
+
+        return MZ_TRUE;
+    }
+
+    /* Decompress the file either directly from memory or from a file input buffer. */
+    tinfl_init(&inflator);
+
+    if (pZip->m_pState->m_pMem)
+    {
+        /* Read directly from the archive in memory. */
+        pRead_buf = (mz_uint8 *)pZip->m_pState->m_pMem + cur_file_ofs;
+        read_buf_size = read_buf_avail = file_stat.m_comp_size;
+        comp_remaining = 0;
+    }
+    else if (pUser_read_buf)
+    {
+        /* Use a user provided read buffer. */
+        if (!user_read_buf_size)
+            return MZ_FALSE;
+        pRead_buf = (mz_uint8 *)pUser_read_buf;
+        read_buf_size = user_read_buf_size;
+        read_buf_avail = 0;
+        comp_remaining = file_stat.m_comp_size;
+    }
+    else
+    {
+        /* Temporarily allocate a read buffer. */
+        read_buf_size = MZ_MIN(file_stat.m_comp_size, (mz_uint64)MZ_ZIP_MAX_IO_BUF_SIZE);
+        if (((sizeof(size_t) == sizeof(mz_uint32))) && (read_buf_size > 0x7FFFFFFF))
+            return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR);
+
+        if (NULL == (pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)read_buf_size)))
+            return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+
+        read_buf_avail = 0;
+        comp_remaining = file_stat.m_comp_size;
+    }
+
+    do
+    {
+        /* The size_t cast here should be OK because we've verified that the output buffer is >= file_stat.m_uncomp_size above */
+        size_t in_buf_size, out_buf_size = (size_t)(file_stat.m_uncomp_size - out_buf_ofs);
+        if ((!read_buf_avail) && (!pZip->m_pState->m_pMem))
+        {
+            read_buf_avail = MZ_MIN(read_buf_size, comp_remaining);
+            if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail)
+            {
+                status = TINFL_STATUS_FAILED;
+                mz_zip_set_error(pZip, MZ_ZIP_DECOMPRESSION_FAILED);
+                break;
+            }
+            cur_file_ofs += read_buf_avail;
+            comp_remaining -= read_buf_avail;
+            read_buf_ofs = 0;
+        }
+        in_buf_size = (size_t)read_buf_avail;
+        status = tinfl_decompress(&inflator, (mz_uint8 *)pRead_buf + read_buf_ofs, &in_buf_size, (mz_uint8 *)pBuf, (mz_uint8 *)pBuf + out_buf_ofs, &out_buf_size, TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF | (comp_remaining ? TINFL_FLAG_HAS_MORE_INPUT : 0));
+        read_buf_avail -= in_buf_size;
+        read_buf_ofs += in_buf_size;
+        out_buf_ofs += out_buf_size;
+    } while (status == TINFL_STATUS_NEEDS_MORE_INPUT);
+
+    if (status == TINFL_STATUS_DONE)
+    {
+        /* Make sure the entire file was decompressed, and check its CRC. */
+        if (out_buf_ofs != file_stat.m_uncomp_size)
+        {
+            mz_zip_set_error(pZip, MZ_ZIP_UNEXPECTED_DECOMPRESSED_SIZE);
+            status = TINFL_STATUS_FAILED;
+        }
+#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
+        else if (mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf, (size_t)file_stat.m_uncomp_size) != file_stat.m_crc32)
+        {
+            mz_zip_set_error(pZip, MZ_ZIP_CRC_CHECK_FAILED);
+            status = TINFL_STATUS_FAILED;
+        }
+#endif
+    }
+
+    if ((!pZip->m_pState->m_pMem) && (!pUser_read_buf))
+        pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);
+
+    return status == TINFL_STATUS_DONE;
+}
+
+mz_bool mz_zip_reader_extract_file_to_mem_no_alloc(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size)
+{
+    mz_uint32 file_index;
+    if (!mz_zip_reader_locate_file_v2(pZip, pFilename, NULL, flags, &file_index))
+        return MZ_FALSE;
+    return mz_zip_reader_extract_to_mem_no_alloc(pZip, file_index, pBuf, buf_size, flags, pUser_read_buf, user_read_buf_size);
+}
+
+mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags)
+{
+    return mz_zip_reader_extract_to_mem_no_alloc(pZip, file_index, pBuf, buf_size, flags, NULL, 0);
+}
+
+mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags)
+{
+    return mz_zip_reader_extract_file_to_mem_no_alloc(pZip, pFilename, pBuf, buf_size, flags, NULL, 0);
+}
+
+void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, size_t *pSize, mz_uint flags)
+{
+    mz_uint64 comp_size, uncomp_size, alloc_size;
+    const mz_uint8 *p = mz_zip_get_cdh(pZip, file_index);
+    void *pBuf;
+
+    if (pSize)
+        *pSize = 0;
+
+    if (!p)
+    {
+        mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+        return NULL;
+    }
+
+    comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS);
+    uncomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS);
+
+    alloc_size = (flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ? comp_size : uncomp_size;
+    if (((sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF))
+    {
+        mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR);
+        return NULL;
+    }
+
+    if (NULL == (pBuf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)alloc_size)))
+    {
+        mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+        return NULL;
+    }
+
+    if (!mz_zip_reader_extract_to_mem(pZip, file_index, pBuf, (size_t)alloc_size, flags))
+    {
+        pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);
+        return NULL;
+    }
+
+    if (pSize)
+        *pSize = (size_t)alloc_size;
+    return pBuf;
+}
+
+void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFilename, size_t *pSize, mz_uint flags)
+{
+    mz_uint32 file_index;
+    if (!mz_zip_reader_locate_file_v2(pZip, pFilename, NULL, flags, &file_index))
+    {
+        if (pSize)
+            *pSize = 0;
+        return MZ_FALSE;
+    }
+    return mz_zip_reader_extract_to_heap(pZip, file_index, pSize, flags);
+}
+
+mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_index, mz_file_write_func pCallback, void *pOpaque, mz_uint flags)
+{
+    int status = TINFL_STATUS_DONE;
+    mz_uint file_crc32 = MZ_CRC32_INIT;
+    mz_uint64 read_buf_size, read_buf_ofs = 0, read_buf_avail, comp_remaining, out_buf_ofs = 0, cur_file_ofs;
+    mz_zip_archive_file_stat file_stat;
+    void *pRead_buf = NULL;
+    void *pWrite_buf = NULL;
+    mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)];
+    mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32;
+
+    if ((!pZip) || (!pZip->m_pState) || (!pCallback) || (!pZip->m_pRead))
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat))
+        return MZ_FALSE;
+
+    /* A directory or zero length file */
+    if ((file_stat.m_is_directory) || (!file_stat.m_comp_size))
+        return MZ_TRUE;
+
+    /* Encryption and patch files are not supported. */
+    if (file_stat.m_bit_flag & (MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_IS_ENCRYPTED | MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_USES_STRONG_ENCRYPTION | MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_COMPRESSED_PATCH_FLAG))
+        return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_ENCRYPTION);
+
+    /* This function only supports decompressing stored and deflate. */
+    if ((!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (file_stat.m_method != 0) && (file_stat.m_method != MZ_DEFLATED))
+        return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_METHOD);
+
+    /* Read and do some minimal validation of the local directory entry (this doesn't crack the zip64 stuff, which we already have from the central dir) */
+    cur_file_ofs = file_stat.m_local_header_ofs;
+    if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE)
+        return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
+
+    if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG)
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+
+    cur_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS);
+    if ((cur_file_ofs + file_stat.m_comp_size) > pZip->m_archive_size)
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+
+    /* Decompress the file either directly from memory or from a file input buffer. */
+    if (pZip->m_pState->m_pMem)
+    {
+        pRead_buf = (mz_uint8 *)pZip->m_pState->m_pMem + cur_file_ofs;
+        read_buf_size = read_buf_avail = file_stat.m_comp_size;
+        comp_remaining = 0;
+    }
+    else
+    {
+        read_buf_size = MZ_MIN(file_stat.m_comp_size, (mz_uint64)MZ_ZIP_MAX_IO_BUF_SIZE);
+        if (NULL == (pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)read_buf_size)))
+            return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+
+        read_buf_avail = 0;
+        comp_remaining = file_stat.m_comp_size;
+    }
+
+    if ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!file_stat.m_method))
+    {
+        /* The file is stored or the caller has requested the compressed data. */
+        if (pZip->m_pState->m_pMem)
+        {
+            if (((sizeof(size_t) == sizeof(mz_uint32))) && (file_stat.m_comp_size > MZ_UINT32_MAX))
+                return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR);
+
+            if (pCallback(pOpaque, out_buf_ofs, pRead_buf, (size_t)file_stat.m_comp_size) != file_stat.m_comp_size)
+            {
+                mz_zip_set_error(pZip, MZ_ZIP_WRITE_CALLBACK_FAILED);
+                status = TINFL_STATUS_FAILED;
+            }
+            else if (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA))
+            {
+#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
+                file_crc32 = (mz_uint32)mz_crc32(file_crc32, (const mz_uint8 *)pRead_buf, (size_t)file_stat.m_comp_size);
+#endif
+            }
+
+            cur_file_ofs += file_stat.m_comp_size;
+            out_buf_ofs += file_stat.m_comp_size;
+            comp_remaining = 0;
+        }
+        else
+        {
+            while (comp_remaining)
+            {
+                read_buf_avail = MZ_MIN(read_buf_size, comp_remaining);
+                if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail)
+                {
+                    mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
+                    status = TINFL_STATUS_FAILED;
+                    break;
+                }
+
+#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
+                if (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA))
+                {
+                    file_crc32 = (mz_uint32)mz_crc32(file_crc32, (const mz_uint8 *)pRead_buf, (size_t)read_buf_avail);
+                }
+#endif
+
+                if (pCallback(pOpaque, out_buf_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail)
+                {
+                    mz_zip_set_error(pZip, MZ_ZIP_WRITE_CALLBACK_FAILED);
+                    status = TINFL_STATUS_FAILED;
+                    break;
+                }
+
+                cur_file_ofs += read_buf_avail;
+                out_buf_ofs += read_buf_avail;
+                comp_remaining -= read_buf_avail;
+            }
+        }
+    }
+    else
+    {
+        tinfl_decompressor inflator;
+        tinfl_init(&inflator);
+
+        if (NULL == (pWrite_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, TINFL_LZ_DICT_SIZE)))
+        {
+            mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+            status = TINFL_STATUS_FAILED;
+        }
+        else
+        {
+            do
+            {
+                mz_uint8 *pWrite_buf_cur = (mz_uint8 *)pWrite_buf + (out_buf_ofs & (TINFL_LZ_DICT_SIZE - 1));
+                size_t in_buf_size, out_buf_size = TINFL_LZ_DICT_SIZE - (out_buf_ofs & (TINFL_LZ_DICT_SIZE - 1));
+                if ((!read_buf_avail) && (!pZip->m_pState->m_pMem))
+                {
+                    read_buf_avail = MZ_MIN(read_buf_size, comp_remaining);
+                    if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail)
+                    {
+                        mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
+                        status = TINFL_STATUS_FAILED;
+                        break;
+                    }
+                    cur_file_ofs += read_buf_avail;
+                    comp_remaining -= read_buf_avail;
+                    read_buf_ofs = 0;
+                }
+
+                in_buf_size = (size_t)read_buf_avail;
+                status = tinfl_decompress(&inflator, (const mz_uint8 *)pRead_buf + read_buf_ofs, &in_buf_size, (mz_uint8 *)pWrite_buf, pWrite_buf_cur, &out_buf_size, comp_remaining ? TINFL_FLAG_HAS_MORE_INPUT : 0);
+                read_buf_avail -= in_buf_size;
+                read_buf_ofs += in_buf_size;
+
+                if (out_buf_size)
+                {
+                    if (pCallback(pOpaque, out_buf_ofs, pWrite_buf_cur, out_buf_size) != out_buf_size)
+                    {
+                        mz_zip_set_error(pZip, MZ_ZIP_WRITE_CALLBACK_FAILED);
+                        status = TINFL_STATUS_FAILED;
+                        break;
+                    }
+
+#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
+                    file_crc32 = (mz_uint32)mz_crc32(file_crc32, pWrite_buf_cur, out_buf_size);
+#endif
+                    if ((out_buf_ofs += out_buf_size) > file_stat.m_uncomp_size)
+                    {
+                        mz_zip_set_error(pZip, MZ_ZIP_DECOMPRESSION_FAILED);
+                        status = TINFL_STATUS_FAILED;
+                        break;
+                    }
+                }
+            } while ((status == TINFL_STATUS_NEEDS_MORE_INPUT) || (status == TINFL_STATUS_HAS_MORE_OUTPUT));
+        }
+    }
+
+    if ((status == TINFL_STATUS_DONE) && (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)))
+    {
+        /* Make sure the entire file was decompressed, and check its CRC. */
+        if (out_buf_ofs != file_stat.m_uncomp_size)
+        {
+            mz_zip_set_error(pZip, MZ_ZIP_UNEXPECTED_DECOMPRESSED_SIZE);
+            status = TINFL_STATUS_FAILED;
+        }
+#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
+        else if (file_crc32 != file_stat.m_crc32)
+        {
+            mz_zip_set_error(pZip, MZ_ZIP_DECOMPRESSION_FAILED);
+            status = TINFL_STATUS_FAILED;
+        }
+#endif
+    }
+
+    if (!pZip->m_pState->m_pMem)
+        pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);
+
+    if (pWrite_buf)
+        pZip->m_pFree(pZip->m_pAlloc_opaque, pWrite_buf);
+
+    return status == TINFL_STATUS_DONE;
+}
+
+mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip, const char *pFilename, mz_file_write_func pCallback, void *pOpaque, mz_uint flags)
+{
+    mz_uint32 file_index;
+    if (!mz_zip_reader_locate_file_v2(pZip, pFilename, NULL, flags, &file_index))
+        return MZ_FALSE;
+
+    return mz_zip_reader_extract_to_callback(pZip, file_index, pCallback, pOpaque, flags);
+}
+
+mz_zip_reader_extract_iter_state* mz_zip_reader_extract_iter_new(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags)
+{
+    mz_zip_reader_extract_iter_state *pState;
+    mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)];
+    mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32;
+
+    /* Argument sanity check */
+    if ((!pZip) || (!pZip->m_pState))
+        return NULL;
+
+    /* Allocate an iterator status structure */
+    pState = (mz_zip_reader_extract_iter_state*)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(mz_zip_reader_extract_iter_state));
+    if (!pState)
+    {
+        mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+        return NULL;
+    }
+
+    /* Fetch file details */
+    if (!mz_zip_reader_file_stat(pZip, file_index, &pState->file_stat))
+    {
+        pZip->m_pFree(pZip->m_pAlloc_opaque, pState);
+        return NULL;
+    }
+
+    /* Encryption and patch files are not supported. */
+    if (pState->file_stat.m_bit_flag & (MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_IS_ENCRYPTED | MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_USES_STRONG_ENCRYPTION | MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_COMPRESSED_PATCH_FLAG))
+    {
+        mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_ENCRYPTION);
+        pZip->m_pFree(pZip->m_pAlloc_opaque, pState);
+        return NULL;
+    }
+
+    /* This function only supports decompressing stored and deflate. */
+    if ((!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (pState->file_stat.m_method != 0) && (pState->file_stat.m_method != MZ_DEFLATED))
+    {
+        mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_METHOD);
+        pZip->m_pFree(pZip->m_pAlloc_opaque, pState);
+        return NULL;
+    }
+
+    /* Init state - save args */
+    pState->pZip = pZip;
+    pState->flags = flags;
+
+    /* Init state - reset variables to defaults */
+    pState->status = TINFL_STATUS_DONE;
+#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
+    pState->file_crc32 = MZ_CRC32_INIT;
+#endif
+    pState->read_buf_ofs = 0;
+    pState->out_buf_ofs = 0;
+    pState->pRead_buf = NULL;
+    pState->pWrite_buf = NULL;
+    pState->out_blk_remain = 0;
+
+    /* Read and parse the local directory entry. */
+    pState->cur_file_ofs = pState->file_stat.m_local_header_ofs;
+    if (pZip->m_pRead(pZip->m_pIO_opaque, pState->cur_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE)
+    {
+        mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
+        pZip->m_pFree(pZip->m_pAlloc_opaque, pState);
+        return NULL;
+    }
+
+    if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG)
+    {
+        mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+        pZip->m_pFree(pZip->m_pAlloc_opaque, pState);
+        return NULL;
+    }
+
+    pState->cur_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS);
+    if ((pState->cur_file_ofs + pState->file_stat.m_comp_size) > pZip->m_archive_size)
+    {
+        mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+        pZip->m_pFree(pZip->m_pAlloc_opaque, pState);
+        return NULL;
+    }
+
+    /* Decompress the file either directly from memory or from a file input buffer. */
+    if (pZip->m_pState->m_pMem)
+    {
+        pState->pRead_buf = (mz_uint8 *)pZip->m_pState->m_pMem + pState->cur_file_ofs;
+        pState->read_buf_size = pState->read_buf_avail = pState->file_stat.m_comp_size;
+        pState->comp_remaining = pState->file_stat.m_comp_size;
+    }
+    else
+    {
+        if (!((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!pState->file_stat.m_method)))
+        {
+            /* Decompression required, therefore intermediate read buffer required */
+            pState->read_buf_size = MZ_MIN(pState->file_stat.m_comp_size, MZ_ZIP_MAX_IO_BUF_SIZE);
+            if (NULL == (pState->pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)pState->read_buf_size)))
+            {
+                mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+                pZip->m_pFree(pZip->m_pAlloc_opaque, pState);
+                return NULL;
+            }
+        }
+        else
+        {
+            /* Decompression not required - we will be reading directly into user buffer, no temp buf required */
+            pState->read_buf_size = 0;
+        }
+        pState->read_buf_avail = 0;
+        pState->comp_remaining = pState->file_stat.m_comp_size;
+    }
+
+    if (!((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!pState->file_stat.m_method)))
+    {
+        /* Decompression required, init decompressor */
+        tinfl_init( &pState->inflator );
+
+        /* Allocate write buffer */
+        if (NULL == (pState->pWrite_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, TINFL_LZ_DICT_SIZE)))
+        {
+            mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+            if (pState->pRead_buf)
+                pZip->m_pFree(pZip->m_pAlloc_opaque, pState->pRead_buf);
+            pZip->m_pFree(pZip->m_pAlloc_opaque, pState);
+            return NULL;
+        }
+    }
+
+    return pState;
+}
+
+mz_zip_reader_extract_iter_state* mz_zip_reader_extract_file_iter_new(mz_zip_archive *pZip, const char *pFilename, mz_uint flags)
+{
+    mz_uint32 file_index;
+
+    /* Locate file index by name */
+    if (!mz_zip_reader_locate_file_v2(pZip, pFilename, NULL, flags, &file_index))
+        return NULL;
+
+    /* Construct iterator */
+    return mz_zip_reader_extract_iter_new(pZip, file_index, flags);
+}
+
+size_t mz_zip_reader_extract_iter_read(mz_zip_reader_extract_iter_state* pState, void* pvBuf, size_t buf_size)
+{
+    size_t copied_to_caller = 0;
+
+    /* Argument sanity check */
+    if ((!pState) || (!pState->pZip) || (!pState->pZip->m_pState) || (!pvBuf))
+        return 0;
+
+    if ((pState->flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!pState->file_stat.m_method))
+    {
+        /* The file is stored or the caller has requested the compressed data, calc amount to return. */
+        copied_to_caller = MZ_MIN( buf_size, pState->comp_remaining );
+
+        /* Zip is in memory....or requires reading from a file? */
+        if (pState->pZip->m_pState->m_pMem)
+        {
+            /* Copy data to caller's buffer */
+            memcpy( pvBuf, pState->pRead_buf, copied_to_caller );
+            pState->pRead_buf = ((mz_uint8*)pState->pRead_buf) + copied_to_caller;
+        }
+        else
+        {
+            /* Read directly into caller's buffer */
+            if (pState->pZip->m_pRead(pState->pZip->m_pIO_opaque, pState->cur_file_ofs, pvBuf, copied_to_caller) != copied_to_caller)
+            {
+                /* Failed to read all that was asked for, flag failure and alert user */
+                mz_zip_set_error(pState->pZip, MZ_ZIP_FILE_READ_FAILED);
+                pState->status = TINFL_STATUS_FAILED;
+                copied_to_caller = 0;
+            }
+        }
+
+#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
+        /* Compute CRC if not returning compressed data only */
+        if (!(pState->flags & MZ_ZIP_FLAG_COMPRESSED_DATA))
+            pState->file_crc32 = (mz_uint32)mz_crc32(pState->file_crc32, (const mz_uint8 *)pvBuf, copied_to_caller);
+#endif
+
+        /* Advance offsets, dec counters */
+        pState->cur_file_ofs += copied_to_caller;
+        pState->out_buf_ofs += copied_to_caller;
+        pState->comp_remaining -= copied_to_caller;
+    }
+    else
+    {
+        do
+        {
+            /* Calc ptr to write buffer - given current output pos and block size */
+            mz_uint8 *pWrite_buf_cur = (mz_uint8 *)pState->pWrite_buf + (pState->out_buf_ofs & (TINFL_LZ_DICT_SIZE - 1));
+
+            /* Calc max output size - given current output pos and block size */
+            size_t in_buf_size, out_buf_size = TINFL_LZ_DICT_SIZE - (pState->out_buf_ofs & (TINFL_LZ_DICT_SIZE - 1));
+
+            if (!pState->out_blk_remain)
+            {
+                /* Read more data from file if none available (and reading from file) */
+                if ((!pState->read_buf_avail) && (!pState->pZip->m_pState->m_pMem))
+                {
+                    /* Calc read size */
+                    pState->read_buf_avail = MZ_MIN(pState->read_buf_size, pState->comp_remaining);
+                    if (pState->pZip->m_pRead(pState->pZip->m_pIO_opaque, pState->cur_file_ofs, pState->pRead_buf, (size_t)pState->read_buf_avail) != pState->read_buf_avail)
+                    {
+                        mz_zip_set_error(pState->pZip, MZ_ZIP_FILE_READ_FAILED);
+                        pState->status = TINFL_STATUS_FAILED;
+                        break;
+                    }
+
+                    /* Advance offsets, dec counters */
+                    pState->cur_file_ofs += pState->read_buf_avail;
+                    pState->comp_remaining -= pState->read_buf_avail;
+                    pState->read_buf_ofs = 0;
+                }
+
+                /* Perform decompression */
+                in_buf_size = (size_t)pState->read_buf_avail;
+                pState->status = tinfl_decompress(&pState->inflator, (const mz_uint8 *)pState->pRead_buf + pState->read_buf_ofs, &in_buf_size, (mz_uint8 *)pState->pWrite_buf, pWrite_buf_cur, &out_buf_size, pState->comp_remaining ? TINFL_FLAG_HAS_MORE_INPUT : 0);
+                pState->read_buf_avail -= in_buf_size;
+                pState->read_buf_ofs += in_buf_size;
+
+                /* Update current output block size remaining */
+                pState->out_blk_remain = out_buf_size;
+            }
+
+            if (pState->out_blk_remain)
+            {
+                /* Calc amount to return. */
+                size_t to_copy = MZ_MIN( (buf_size - copied_to_caller), pState->out_blk_remain );
+
+                /* Copy data to caller's buffer */
+                memcpy( (uint8_t*)pvBuf + copied_to_caller, pWrite_buf_cur, to_copy );
+
+#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
+                /* Perform CRC */
+                pState->file_crc32 = (mz_uint32)mz_crc32(pState->file_crc32, pWrite_buf_cur, to_copy);
+#endif
+
+                /* Decrement data consumed from block */
+                pState->out_blk_remain -= to_copy;
+
+                /* Inc output offset, while performing sanity check */
+                if ((pState->out_buf_ofs += to_copy) > pState->file_stat.m_uncomp_size)
+                {
+                    mz_zip_set_error(pState->pZip, MZ_ZIP_DECOMPRESSION_FAILED);
+                    pState->status = TINFL_STATUS_FAILED;
+                    break;
+                }
+
+                /* Increment counter of data copied to caller */
+                copied_to_caller += to_copy;
+            }
+        } while ( (copied_to_caller < buf_size) && ((pState->status == TINFL_STATUS_NEEDS_MORE_INPUT) || (pState->status == TINFL_STATUS_HAS_MORE_OUTPUT)) );
+    }
+
+    /* Return how many bytes were copied into user buffer */
+    return copied_to_caller;
+}
+
+mz_bool mz_zip_reader_extract_iter_free(mz_zip_reader_extract_iter_state* pState)
+{
+    int status;
+
+    /* Argument sanity check */
+    if ((!pState) || (!pState->pZip) || (!pState->pZip->m_pState))
+        return MZ_FALSE;
+
+    /* Was decompression completed and requested? */
+    if ((pState->status == TINFL_STATUS_DONE) && (!(pState->flags & MZ_ZIP_FLAG_COMPRESSED_DATA)))
+    {
+        /* Make sure the entire file was decompressed, and check its CRC. */
+        if (pState->out_buf_ofs != pState->file_stat.m_uncomp_size)
+        {
+            mz_zip_set_error(pState->pZip, MZ_ZIP_UNEXPECTED_DECOMPRESSED_SIZE);
+            pState->status = TINFL_STATUS_FAILED;
+        }
+#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
+        else if (pState->file_crc32 != pState->file_stat.m_crc32)
+        {
+            mz_zip_set_error(pState->pZip, MZ_ZIP_DECOMPRESSION_FAILED);
+            pState->status = TINFL_STATUS_FAILED;
+        }
+#endif
+    }
+
+    /* Free buffers */
+    if (!pState->pZip->m_pState->m_pMem)
+        pState->pZip->m_pFree(pState->pZip->m_pAlloc_opaque, pState->pRead_buf);
+    if (pState->pWrite_buf)
+        pState->pZip->m_pFree(pState->pZip->m_pAlloc_opaque, pState->pWrite_buf);
+
+    /* Save status */
+    status = pState->status;
+
+    /* Free context */
+    pState->pZip->m_pFree(pState->pZip->m_pAlloc_opaque, pState);
+
+    return status == TINFL_STATUS_DONE;
+}
+
+#ifndef MINIZ_NO_STDIO
+static size_t mz_zip_file_write_callback(void *pOpaque, mz_uint64 ofs, const void *pBuf, size_t n)
+{
+    (void)ofs;
+
+    return MZ_FWRITE(pBuf, 1, n, (MZ_FILE *)pOpaque);
+}
+
+mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, mz_uint flags)
+{
+    mz_bool status;
+    mz_zip_archive_file_stat file_stat;
+    MZ_FILE *pFile;
+
+    if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat))
+        return MZ_FALSE;
+
+    if ((file_stat.m_is_directory) || (!file_stat.m_is_supported))
+        return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_FEATURE);
+
+    pFile = MZ_FOPEN(pDst_filename, "wb");
+    if (!pFile)
+        return mz_zip_set_error(pZip, MZ_ZIP_FILE_OPEN_FAILED);
+
+    status = mz_zip_reader_extract_to_callback(pZip, file_index, mz_zip_file_write_callback, pFile, flags);
+
+    if (MZ_FCLOSE(pFile) == EOF)
+    {
+        if (status)
+            mz_zip_set_error(pZip, MZ_ZIP_FILE_CLOSE_FAILED);
+
+        status = MZ_FALSE;
+    }
+
+#if !defined(MINIZ_NO_TIME) && !defined(MINIZ_NO_STDIO)
+    if (status)
+        mz_zip_set_file_times(pDst_filename, file_stat.m_time, file_stat.m_time);
+#endif
+
+    return status;
+}
+
+mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, const char *pArchive_filename, const char *pDst_filename, mz_uint flags)
+{
+    mz_uint32 file_index;
+    if (!mz_zip_reader_locate_file_v2(pZip, pArchive_filename, NULL, flags, &file_index))
+        return MZ_FALSE;
+
+    return mz_zip_reader_extract_to_file(pZip, file_index, pDst_filename, flags);
+}
+
+mz_bool mz_zip_reader_extract_to_cfile(mz_zip_archive *pZip, mz_uint file_index, MZ_FILE *pFile, mz_uint flags)
+{
+    mz_zip_archive_file_stat file_stat;
+
+    if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat))
+        return MZ_FALSE;
+
+    if ((file_stat.m_is_directory) || (!file_stat.m_is_supported))
+        return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_FEATURE);
+
+    return mz_zip_reader_extract_to_callback(pZip, file_index, mz_zip_file_write_callback, pFile, flags);
+}
+
+mz_bool mz_zip_reader_extract_file_to_cfile(mz_zip_archive *pZip, const char *pArchive_filename, MZ_FILE *pFile, mz_uint flags)
+{
+    mz_uint32 file_index;
+    if (!mz_zip_reader_locate_file_v2(pZip, pArchive_filename, NULL, flags, &file_index))
+        return MZ_FALSE;
+
+    return mz_zip_reader_extract_to_cfile(pZip, file_index, pFile, flags);
+}
+#endif /* #ifndef MINIZ_NO_STDIO */
+
+static size_t mz_zip_compute_crc32_callback(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n)
+{
+    mz_uint32 *p = (mz_uint32 *)pOpaque;
+    (void)file_ofs;
+    *p = (mz_uint32)mz_crc32(*p, (const mz_uint8 *)pBuf, n);
+    return n;
+}
+
+mz_bool mz_zip_validate_file(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags)
+{
+    mz_zip_archive_file_stat file_stat;
+    mz_zip_internal_state *pState;
+    const mz_uint8 *pCentral_dir_header;
+    mz_bool found_zip64_ext_data_in_cdir = MZ_FALSE;
+    mz_bool found_zip64_ext_data_in_ldir = MZ_FALSE;
+    mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)];
+    mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32;
+    mz_uint64 local_header_ofs = 0;
+    mz_uint32 local_header_filename_len, local_header_extra_len, local_header_crc32;
+    mz_uint64 local_header_comp_size, local_header_uncomp_size;
+    mz_uint32 uncomp_crc32 = MZ_CRC32_INIT;
+    mz_bool has_data_descriptor;
+    mz_uint32 local_header_bit_flags;
+
+    mz_zip_array file_data_array;
+    mz_zip_array_init(&file_data_array, 1);
+
+    if ((!pZip) || (!pZip->m_pState) || (!pZip->m_pAlloc) || (!pZip->m_pFree) || (!pZip->m_pRead))
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    if (file_index > pZip->m_total_files)
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    pState = pZip->m_pState;
+
+    pCentral_dir_header = mz_zip_get_cdh(pZip, file_index);
+
+    if (!mz_zip_file_stat_internal(pZip, file_index, pCentral_dir_header, &file_stat, &found_zip64_ext_data_in_cdir))
+        return MZ_FALSE;
+
+    /* A directory or zero length file */
+    if ((file_stat.m_is_directory) || (!file_stat.m_uncomp_size))
+        return MZ_TRUE;
+
+    /* Encryption and patch files are not supported. */
+    if (file_stat.m_is_encrypted)
+        return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_ENCRYPTION);
+
+    /* This function only supports stored and deflate. */
+    if ((file_stat.m_method != 0) && (file_stat.m_method != MZ_DEFLATED))
+        return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_METHOD);
+
+    if (!file_stat.m_is_supported)
+        return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_FEATURE);
+
+    /* Read and parse the local directory entry. */
+    local_header_ofs = file_stat.m_local_header_ofs;
+    if (pZip->m_pRead(pZip->m_pIO_opaque, local_header_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE)
+        return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
+
+    if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG)
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+
+    local_header_filename_len = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS);
+    local_header_extra_len = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS);
+    local_header_comp_size = MZ_READ_LE32(pLocal_header + MZ_ZIP_LDH_COMPRESSED_SIZE_OFS);
+    local_header_uncomp_size = MZ_READ_LE32(pLocal_header + MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS);
+    local_header_crc32 = MZ_READ_LE32(pLocal_header + MZ_ZIP_LDH_CRC32_OFS);
+    local_header_bit_flags = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_BIT_FLAG_OFS);
+    has_data_descriptor = (local_header_bit_flags & 8) != 0;
+
+    if (local_header_filename_len != strlen(file_stat.m_filename))
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+
+    if ((local_header_ofs + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + local_header_filename_len + local_header_extra_len + file_stat.m_comp_size) > pZip->m_archive_size)
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+
+    if (!mz_zip_array_resize(pZip, &file_data_array, MZ_MAX(local_header_filename_len, local_header_extra_len), MZ_FALSE))
+        return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+
+    if (local_header_filename_len)
+    {
+        if (pZip->m_pRead(pZip->m_pIO_opaque, local_header_ofs + MZ_ZIP_LOCAL_DIR_HEADER_SIZE, file_data_array.m_p, local_header_filename_len) != local_header_filename_len)
+        {
+            mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
+            goto handle_failure;
+        }
+
+        /* I've seen 1 archive that had the same pathname, but used backslashes in the local dir and forward slashes in the central dir. Do we care about this? For now, this case will fail validation. */
+        if (memcmp(file_stat.m_filename, file_data_array.m_p, local_header_filename_len) != 0)
+        {
+            mz_zip_set_error(pZip, MZ_ZIP_VALIDATION_FAILED);
+            goto handle_failure;
+        }
+    }
+
+    if ((local_header_extra_len) && ((local_header_comp_size == MZ_UINT32_MAX) || (local_header_uncomp_size == MZ_UINT32_MAX)))
+    {
+        mz_uint32 extra_size_remaining = local_header_extra_len;
+        const mz_uint8 *pExtra_data = (const mz_uint8 *)file_data_array.m_p;
+
+        if (pZip->m_pRead(pZip->m_pIO_opaque, local_header_ofs + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + local_header_filename_len, file_data_array.m_p, local_header_extra_len) != local_header_extra_len)
+        {
+            mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
+            goto handle_failure;
+        }
+
+        do
+        {
+            mz_uint32 field_id, field_data_size, field_total_size;
+
+            if (extra_size_remaining < (sizeof(mz_uint16) * 2))
+                return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+
+            field_id = MZ_READ_LE16(pExtra_data);
+            field_data_size = MZ_READ_LE16(pExtra_data + sizeof(mz_uint16));
+            field_total_size = field_data_size + sizeof(mz_uint16) * 2;
+
+            if (field_total_size > extra_size_remaining)
+                return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+
+            if (field_id == MZ_ZIP64_EXTENDED_INFORMATION_FIELD_HEADER_ID)
+            {
+                const mz_uint8 *pSrc_field_data = pExtra_data + sizeof(mz_uint32);
+
+                if (field_data_size < sizeof(mz_uint64) * 2)
+                {
+                    mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+                    goto handle_failure;
+                }
+
+                local_header_uncomp_size = MZ_READ_LE64(pSrc_field_data);
+                local_header_comp_size = MZ_READ_LE64(pSrc_field_data + sizeof(mz_uint64));
+
+                found_zip64_ext_data_in_ldir = MZ_TRUE;
+                break;
+            }
+
+            pExtra_data += field_total_size;
+            extra_size_remaining -= field_total_size;
+        } while (extra_size_remaining);
+    }
+
+    /* TODO: parse local header extra data when local_header_comp_size is 0xFFFFFFFF! (big_descriptor.zip) */
+    /* I've seen zips in the wild with the data descriptor bit set, but proper local header values and bogus data descriptors */
+    if ((has_data_descriptor) && (!local_header_comp_size) && (!local_header_crc32))
+    {
+        mz_uint8 descriptor_buf[32];
+        mz_bool has_id;
+        const mz_uint8 *pSrc;
+        mz_uint32 file_crc32;
+        mz_uint64 comp_size = 0, uncomp_size = 0;
+
+        mz_uint32 num_descriptor_uint32s = ((pState->m_zip64) || (found_zip64_ext_data_in_ldir)) ? 6 : 4;
+
+        if (pZip->m_pRead(pZip->m_pIO_opaque, local_header_ofs + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + local_header_filename_len + local_header_extra_len + file_stat.m_comp_size, descriptor_buf, sizeof(mz_uint32) * num_descriptor_uint32s) != (sizeof(mz_uint32) * num_descriptor_uint32s))
+        {
+            mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
+            goto handle_failure;
+        }
+
+        has_id = (MZ_READ_LE32(descriptor_buf) == MZ_ZIP_DATA_DESCRIPTOR_ID);
+        pSrc = has_id ? (descriptor_buf + sizeof(mz_uint32)) : descriptor_buf;
+
+        file_crc32 = MZ_READ_LE32(pSrc);
+
+        if ((pState->m_zip64) || (found_zip64_ext_data_in_ldir))
+        {
+            comp_size = MZ_READ_LE64(pSrc + sizeof(mz_uint32));
+            uncomp_size = MZ_READ_LE64(pSrc + sizeof(mz_uint32) + sizeof(mz_uint64));
+        }
+        else
+        {
+            comp_size = MZ_READ_LE32(pSrc + sizeof(mz_uint32));
+            uncomp_size = MZ_READ_LE32(pSrc + sizeof(mz_uint32) + sizeof(mz_uint32));
+        }
+
+        if ((file_crc32 != file_stat.m_crc32) || (comp_size != file_stat.m_comp_size) || (uncomp_size != file_stat.m_uncomp_size))
+        {
+            mz_zip_set_error(pZip, MZ_ZIP_VALIDATION_FAILED);
+            goto handle_failure;
+        }
+    }
+    else
+    {
+        if ((local_header_crc32 != file_stat.m_crc32) || (local_header_comp_size != file_stat.m_comp_size) || (local_header_uncomp_size != file_stat.m_uncomp_size))
+        {
+            mz_zip_set_error(pZip, MZ_ZIP_VALIDATION_FAILED);
+            goto handle_failure;
+        }
+    }
+
+    mz_zip_array_clear(pZip, &file_data_array);
+
+    if ((flags & MZ_ZIP_FLAG_VALIDATE_HEADERS_ONLY) == 0)
+    {
+        if (!mz_zip_reader_extract_to_callback(pZip, file_index, mz_zip_compute_crc32_callback, &uncomp_crc32, 0))
+            return MZ_FALSE;
+
+        /* 1 more check to be sure, although the extract checks too. */
+        if (uncomp_crc32 != file_stat.m_crc32)
+        {
+            mz_zip_set_error(pZip, MZ_ZIP_VALIDATION_FAILED);
+            return MZ_FALSE;
+        }
+    }
+
+    return MZ_TRUE;
+
+handle_failure:
+    mz_zip_array_clear(pZip, &file_data_array);
+    return MZ_FALSE;
+}
+
+mz_bool mz_zip_validate_archive(mz_zip_archive *pZip, mz_uint flags)
+{
+    mz_zip_internal_state *pState;
+    uint32_t i;
+
+    if ((!pZip) || (!pZip->m_pState) || (!pZip->m_pAlloc) || (!pZip->m_pFree) || (!pZip->m_pRead))
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    pState = pZip->m_pState;
+
+    /* Basic sanity checks */
+    if (!pState->m_zip64)
+    {
+        if (pZip->m_total_files > MZ_UINT16_MAX)
+            return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);
+
+        if (pZip->m_archive_size > MZ_UINT32_MAX)
+            return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);
+    }
+    else
+    {
+        if (pZip->m_total_files >= MZ_UINT32_MAX)
+            return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);
+
+        if (pState->m_central_dir.m_size >= MZ_UINT32_MAX)
+            return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);
+    }
+
+    for (i = 0; i < pZip->m_total_files; i++)
+    {
+        if (MZ_ZIP_FLAG_VALIDATE_LOCATE_FILE_FLAG & flags)
+        {
+            mz_uint32 found_index;
+            mz_zip_archive_file_stat stat;
+
+            if (!mz_zip_reader_file_stat(pZip, i, &stat))
+                return MZ_FALSE;
+
+            if (!mz_zip_reader_locate_file_v2(pZip, stat.m_filename, NULL, 0, &found_index))
+                return MZ_FALSE;
+
+            /* This check can fail if there are duplicate filenames in the archive (which we don't check for when writing - that's up to the user) */
+            if (found_index != i)
+                return mz_zip_set_error(pZip, MZ_ZIP_VALIDATION_FAILED);
+        }
+
+        if (!mz_zip_validate_file(pZip, i, flags))
+            return MZ_FALSE;
+    }
+
+    return MZ_TRUE;
+}
+
+mz_bool mz_zip_validate_mem_archive(const void *pMem, size_t size, mz_uint flags, mz_zip_error *pErr)
+{
+    mz_bool success = MZ_TRUE;
+    mz_zip_archive zip;
+    mz_zip_error actual_err = MZ_ZIP_NO_ERROR;
+
+    if ((!pMem) || (!size))
+    {
+        if (pErr)
+            *pErr = MZ_ZIP_INVALID_PARAMETER;
+        return MZ_FALSE;
+    }
+
+    mz_zip_zero_struct(&zip);
+
+    if (!mz_zip_reader_init_mem(&zip, pMem, size, flags))
+    {
+        if (pErr)
+            *pErr = zip.m_last_error;
+        return MZ_FALSE;
+    }
+
+    if (!mz_zip_validate_archive(&zip, flags))
+    {
+        actual_err = zip.m_last_error;
+        success = MZ_FALSE;
+    }
+
+    if (!mz_zip_reader_end_internal(&zip, success))
+    {
+        if (!actual_err)
+            actual_err = zip.m_last_error;
+        success = MZ_FALSE;
+    }
+
+    if (pErr)
+        *pErr = actual_err;
+
+    return success;
+}
+
+#ifndef MINIZ_NO_STDIO
+mz_bool mz_zip_validate_file_archive(const char *pFilename, mz_uint flags, mz_zip_error *pErr)
+{
+    mz_bool success = MZ_TRUE;
+    mz_zip_archive zip;
+    mz_zip_error actual_err = MZ_ZIP_NO_ERROR;
+
+    if (!pFilename)
+    {
+        if (pErr)
+            *pErr = MZ_ZIP_INVALID_PARAMETER;
+        return MZ_FALSE;
+    }
+
+    mz_zip_zero_struct(&zip);
+
+    if (!mz_zip_reader_init_file_v2(&zip, pFilename, flags, 0, 0))
+    {
+        if (pErr)
+            *pErr = zip.m_last_error;
+        return MZ_FALSE;
+    }
+
+    if (!mz_zip_validate_archive(&zip, flags))
+    {
+        actual_err = zip.m_last_error;
+        success = MZ_FALSE;
+    }
+
+    if (!mz_zip_reader_end_internal(&zip, success))
+    {
+        if (!actual_err)
+            actual_err = zip.m_last_error;
+        success = MZ_FALSE;
+    }
+
+    if (pErr)
+        *pErr = actual_err;
+
+    return success;
+}
+#endif /* #ifndef MINIZ_NO_STDIO */
+
+/* ------------------- .ZIP archive writing */
+
+#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS
+
+static MZ_FORCEINLINE void mz_write_le16(mz_uint8 *p, mz_uint16 v)
+{
+    p[0] = (mz_uint8)v;
+    p[1] = (mz_uint8)(v >> 8);
+}
+static MZ_FORCEINLINE void mz_write_le32(mz_uint8 *p, mz_uint32 v)
+{
+    p[0] = (mz_uint8)v;
+    p[1] = (mz_uint8)(v >> 8);
+    p[2] = (mz_uint8)(v >> 16);
+    p[3] = (mz_uint8)(v >> 24);
+}
+static MZ_FORCEINLINE void mz_write_le64(mz_uint8 *p, mz_uint64 v)
+{
+    mz_write_le32(p, (mz_uint32)v);
+    mz_write_le32(p + sizeof(mz_uint32), (mz_uint32)(v >> 32));
+}
+
+#define MZ_WRITE_LE16(p, v) mz_write_le16((mz_uint8 *)(p), (mz_uint16)(v))
+#define MZ_WRITE_LE32(p, v) mz_write_le32((mz_uint8 *)(p), (mz_uint32)(v))
+#define MZ_WRITE_LE64(p, v) mz_write_le64((mz_uint8 *)(p), (mz_uint64)(v))
+
+static size_t mz_zip_heap_write_func(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n)
+{
+    mz_zip_archive *pZip = (mz_zip_archive *)pOpaque;
+    mz_zip_internal_state *pState = pZip->m_pState;
+    mz_uint64 new_size = MZ_MAX(file_ofs + n, pState->m_mem_size);
+
+    if (!n)
+        return 0;
+
+    /* An allocation this big is likely to just fail on 32-bit systems, so don't even go there. */
+    if ((sizeof(size_t) == sizeof(mz_uint32)) && (new_size > 0x7FFFFFFF))
+    {
+        mz_zip_set_error(pZip, MZ_ZIP_FILE_TOO_LARGE);
+        return 0;
+    }
+
+    if (new_size > pState->m_mem_capacity)
+    {
+        void *pNew_block;
+        size_t new_capacity = MZ_MAX(64, pState->m_mem_capacity);
+
+        while (new_capacity < new_size)
+            new_capacity *= 2;
+
+        if (NULL == (pNew_block = pZip->m_pRealloc(pZip->m_pAlloc_opaque, pState->m_pMem, 1, new_capacity)))
+        {
+            mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+            return 0;
+        }
+
+        pState->m_pMem = pNew_block;
+        pState->m_mem_capacity = new_capacity;
+    }
+    memcpy((mz_uint8 *)pState->m_pMem + file_ofs, pBuf, n);
+    pState->m_mem_size = (size_t)new_size;
+    return n;
+}
+
+static mz_bool mz_zip_writer_end_internal(mz_zip_archive *pZip, mz_bool set_last_error)
+{
+    mz_zip_internal_state *pState;
+    mz_bool status = MZ_TRUE;
+
+    if ((!pZip) || (!pZip->m_pState) || (!pZip->m_pAlloc) || (!pZip->m_pFree) || ((pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) && (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED)))
+    {
+        if (set_last_error)
+            mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+        return MZ_FALSE;
+    }
+
+    pState = pZip->m_pState;
+    pZip->m_pState = NULL;
+    mz_zip_array_clear(pZip, &pState->m_central_dir);
+    mz_zip_array_clear(pZip, &pState->m_central_dir_offsets);
+    mz_zip_array_clear(pZip, &pState->m_sorted_central_dir_offsets);
+
+#ifndef MINIZ_NO_STDIO
+    if (pState->m_pFile)
+    {
+        if (pZip->m_zip_type == MZ_ZIP_TYPE_FILE)
+        {
+            if (MZ_FCLOSE(pState->m_pFile) == EOF)
+            {
+                if (set_last_error)
+                    mz_zip_set_error(pZip, MZ_ZIP_FILE_CLOSE_FAILED);
+                status = MZ_FALSE;
+            }
+        }
+
+        pState->m_pFile = NULL;
+    }
+#endif /* #ifndef MINIZ_NO_STDIO */
+
+    if ((pZip->m_pWrite == mz_zip_heap_write_func) && (pState->m_pMem))
+    {
+        pZip->m_pFree(pZip->m_pAlloc_opaque, pState->m_pMem);
+        pState->m_pMem = NULL;
+    }
+
+    pZip->m_pFree(pZip->m_pAlloc_opaque, pState);
+    pZip->m_zip_mode = MZ_ZIP_MODE_INVALID;
+    return status;
+}
+
+mz_bool mz_zip_writer_init_v2(mz_zip_archive *pZip, mz_uint64 existing_size, mz_uint flags)
+{
+    mz_bool zip64 = (flags & MZ_ZIP_FLAG_WRITE_ZIP64) != 0;
+
+    if ((!pZip) || (pZip->m_pState) || (!pZip->m_pWrite) || (pZip->m_zip_mode != MZ_ZIP_MODE_INVALID))
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    if (flags & MZ_ZIP_FLAG_WRITE_ALLOW_READING)
+    {
+        if (!pZip->m_pRead)
+            return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+    }
+
+    if (pZip->m_file_offset_alignment)
+    {
+        /* Ensure user specified file offset alignment is a power of 2. */
+        if (pZip->m_file_offset_alignment & (pZip->m_file_offset_alignment - 1))
+            return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+    }
+
+    if (!pZip->m_pAlloc)
+        pZip->m_pAlloc = miniz_def_alloc_func;
+    if (!pZip->m_pFree)
+        pZip->m_pFree = miniz_def_free_func;
+    if (!pZip->m_pRealloc)
+        pZip->m_pRealloc = miniz_def_realloc_func;
+
+    pZip->m_archive_size = existing_size;
+    pZip->m_central_directory_file_ofs = 0;
+    pZip->m_total_files = 0;
+
+    if (NULL == (pZip->m_pState = (mz_zip_internal_state *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(mz_zip_internal_state))))
+        return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+
+    memset(pZip->m_pState, 0, sizeof(mz_zip_internal_state));
+
+    MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir, sizeof(mz_uint8));
+    MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir_offsets, sizeof(mz_uint32));
+    MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_sorted_central_dir_offsets, sizeof(mz_uint32));
+
+    pZip->m_pState->m_zip64 = zip64;
+    pZip->m_pState->m_zip64_has_extended_info_fields = zip64;
+
+    pZip->m_zip_type = MZ_ZIP_TYPE_USER;
+    pZip->m_zip_mode = MZ_ZIP_MODE_WRITING;
+
+    return MZ_TRUE;
+}
+
+mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size)
+{
+    return mz_zip_writer_init_v2(pZip, existing_size, 0);
+}
+
+mz_bool mz_zip_writer_init_heap_v2(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size, mz_uint flags)
+{
+    pZip->m_pWrite = mz_zip_heap_write_func;
+    pZip->m_pNeeds_keepalive = NULL;
+
+    if (flags & MZ_ZIP_FLAG_WRITE_ALLOW_READING)
+        pZip->m_pRead = mz_zip_mem_read_func;
+
+    pZip->m_pIO_opaque = pZip;
+
+    if (!mz_zip_writer_init_v2(pZip, size_to_reserve_at_beginning, flags))
+        return MZ_FALSE;
+
+    pZip->m_zip_type = MZ_ZIP_TYPE_HEAP;
+
+    if (0 != (initial_allocation_size = MZ_MAX(initial_allocation_size, size_to_reserve_at_beginning)))
+    {
+        if (NULL == (pZip->m_pState->m_pMem = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, initial_allocation_size)))
+        {
+            mz_zip_writer_end_internal(pZip, MZ_FALSE);
+            return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+        }
+        pZip->m_pState->m_mem_capacity = initial_allocation_size;
+    }
+
+    return MZ_TRUE;
+}
+
+mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size)
+{
+    return mz_zip_writer_init_heap_v2(pZip, size_to_reserve_at_beginning, initial_allocation_size, 0);
+}
+
+#ifndef MINIZ_NO_STDIO
+static size_t mz_zip_file_write_func(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n)
+{
+    mz_zip_archive *pZip = (mz_zip_archive *)pOpaque;
+    mz_int64 cur_ofs = MZ_FTELL64(pZip->m_pState->m_pFile);
+
+    file_ofs += pZip->m_pState->m_file_archive_start_ofs;
+
+    if (((mz_int64)file_ofs < 0) || (((cur_ofs != (mz_int64)file_ofs)) && (MZ_FSEEK64(pZip->m_pState->m_pFile, (mz_int64)file_ofs, SEEK_SET))))
+    {
+        mz_zip_set_error(pZip, MZ_ZIP_FILE_SEEK_FAILED);
+        return 0;
+    }
+
+    return MZ_FWRITE(pBuf, 1, n, pZip->m_pState->m_pFile);
+}
+
+mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning)
+{
+    return mz_zip_writer_init_file_v2(pZip, pFilename, size_to_reserve_at_beginning, 0);
+}
+
+mz_bool mz_zip_writer_init_file_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning, mz_uint flags)
+{
+    MZ_FILE *pFile;
+
+    pZip->m_pWrite = mz_zip_file_write_func;
+    pZip->m_pNeeds_keepalive = NULL;
+
+    if (flags & MZ_ZIP_FLAG_WRITE_ALLOW_READING)
+        pZip->m_pRead = mz_zip_file_read_func;
+
+    pZip->m_pIO_opaque = pZip;
+
+    if (!mz_zip_writer_init_v2(pZip, size_to_reserve_at_beginning, flags))
+        return MZ_FALSE;
+
+    if (NULL == (pFile = MZ_FOPEN(pFilename, (flags & MZ_ZIP_FLAG_WRITE_ALLOW_READING) ? "w+b" : "wb")))
+    {
+        mz_zip_writer_end(pZip);
+        return mz_zip_set_error(pZip, MZ_ZIP_FILE_OPEN_FAILED);
+    }
+
+    pZip->m_pState->m_pFile = pFile;
+    pZip->m_zip_type = MZ_ZIP_TYPE_FILE;
+
+    if (size_to_reserve_at_beginning)
+    {
+        mz_uint64 cur_ofs = 0;
+        char buf[4096];
+
+        MZ_CLEAR_OBJ(buf);
+
+        do
+        {
+            size_t n = (size_t)MZ_MIN(sizeof(buf), size_to_reserve_at_beginning);
+            if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_ofs, buf, n) != n)
+            {
+                mz_zip_writer_end(pZip);
+                return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
+            }
+            cur_ofs += n;
+            size_to_reserve_at_beginning -= n;
+        } while (size_to_reserve_at_beginning);
+    }
+
+    return MZ_TRUE;
+}
+
+mz_bool mz_zip_writer_init_cfile(mz_zip_archive *pZip, MZ_FILE *pFile, mz_uint flags)
+{
+    pZip->m_pWrite = mz_zip_file_write_func;
+    pZip->m_pNeeds_keepalive = NULL;
+
+    if (flags & MZ_ZIP_FLAG_WRITE_ALLOW_READING)
+        pZip->m_pRead = mz_zip_file_read_func;
+
+    pZip->m_pIO_opaque = pZip;
+
+    if (!mz_zip_writer_init_v2(pZip, 0, flags))
+        return MZ_FALSE;
+
+    pZip->m_pState->m_pFile = pFile;
+    pZip->m_pState->m_file_archive_start_ofs = MZ_FTELL64(pZip->m_pState->m_pFile);
+    pZip->m_zip_type = MZ_ZIP_TYPE_CFILE;
+
+    return MZ_TRUE;
+}
+#endif /* #ifndef MINIZ_NO_STDIO */
+
+mz_bool mz_zip_writer_init_from_reader_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint flags)
+{
+    mz_zip_internal_state *pState;
+
+    if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING))
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    if (flags & MZ_ZIP_FLAG_WRITE_ZIP64)
+    {
+        /* We don't support converting a non-zip64 file to zip64 - this seems like more trouble than it's worth. (What about the existing 32-bit data descriptors that could follow the compressed data?) */
+        if (!pZip->m_pState->m_zip64)
+            return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+    }
+
+    /* No sense in trying to write to an archive that's already at the support max size */
+    if (pZip->m_pState->m_zip64)
+    {
+        if (pZip->m_total_files == MZ_UINT32_MAX)
+            return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES);
+    }
+    else
+    {
+        if (pZip->m_total_files == MZ_UINT16_MAX)
+            return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES);
+
+        if ((pZip->m_archive_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_ZIP_LOCAL_DIR_HEADER_SIZE) > MZ_UINT32_MAX)
+            return mz_zip_set_error(pZip, MZ_ZIP_FILE_TOO_LARGE);
+    }
+
+    pState = pZip->m_pState;
+
+    if (pState->m_pFile)
+    {
+#ifdef MINIZ_NO_STDIO
+        (void)pFilename;
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+#else
+        if (pZip->m_pIO_opaque != pZip)
+            return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+        if (pZip->m_zip_type == MZ_ZIP_TYPE_FILE)
+        {
+            if (!pFilename)
+                return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+            /* Archive is being read from stdio and was originally opened only for reading. Try to reopen as writable. */
+            if (NULL == (pState->m_pFile = MZ_FREOPEN(pFilename, "r+b", pState->m_pFile)))
+            {
+                /* The mz_zip_archive is now in a bogus state because pState->m_pFile is NULL, so just close it. */
+                mz_zip_reader_end_internal(pZip, MZ_FALSE);
+                return mz_zip_set_error(pZip, MZ_ZIP_FILE_OPEN_FAILED);
+            }
+        }
+
+        pZip->m_pWrite = mz_zip_file_write_func;
+        pZip->m_pNeeds_keepalive = NULL;
+#endif /* #ifdef MINIZ_NO_STDIO */
+    }
+    else if (pState->m_pMem)
+    {
+        /* Archive lives in a memory block. Assume it's from the heap that we can resize using the realloc callback. */
+        if (pZip->m_pIO_opaque != pZip)
+            return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+        pState->m_mem_capacity = pState->m_mem_size;
+        pZip->m_pWrite = mz_zip_heap_write_func;
+        pZip->m_pNeeds_keepalive = NULL;
+    }
+    /* Archive is being read via a user provided read function - make sure the user has specified a write function too. */
+    else if (!pZip->m_pWrite)
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    /* Start writing new files at the archive's current central directory location. */
+    /* TODO: We could add a flag that lets the user start writing immediately AFTER the existing central dir - this would be safer. */
+    pZip->m_archive_size = pZip->m_central_directory_file_ofs;
+    pZip->m_central_directory_file_ofs = 0;
+
+    /* Clear the sorted central dir offsets, they aren't useful or maintained now. */
+    /* Even though we're now in write mode, files can still be extracted and verified, but file locates will be slow. */
+    /* TODO: We could easily maintain the sorted central directory offsets. */
+    mz_zip_array_clear(pZip, &pZip->m_pState->m_sorted_central_dir_offsets);
+
+    pZip->m_zip_mode = MZ_ZIP_MODE_WRITING;
+
+    return MZ_TRUE;
+}
+
+mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilename)
+{
+    return mz_zip_writer_init_from_reader_v2(pZip, pFilename, 0);
+}
+
+/* TODO: pArchive_name is a terrible name here! */
+mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, mz_uint level_and_flags)
+{
+    return mz_zip_writer_add_mem_ex(pZip, pArchive_name, pBuf, buf_size, NULL, 0, level_and_flags, 0, 0);
+}
+
+typedef struct
+{
+    mz_zip_archive *m_pZip;
+    mz_uint64 m_cur_archive_file_ofs;
+    mz_uint64 m_comp_size;
+} mz_zip_writer_add_state;
+
+static mz_bool mz_zip_writer_add_put_buf_callback(const void *pBuf, int len, void *pUser)
+{
+    mz_zip_writer_add_state *pState = (mz_zip_writer_add_state *)pUser;
+    if ((int)pState->m_pZip->m_pWrite(pState->m_pZip->m_pIO_opaque, pState->m_cur_archive_file_ofs, pBuf, len) != len)
+        return MZ_FALSE;
+
+    pState->m_cur_archive_file_ofs += len;
+    pState->m_comp_size += len;
+    return MZ_TRUE;
+}
+
+#define MZ_ZIP64_MAX_LOCAL_EXTRA_FIELD_SIZE (sizeof(mz_uint16) * 2 + sizeof(mz_uint64) * 2)
+#define MZ_ZIP64_MAX_CENTRAL_EXTRA_FIELD_SIZE (sizeof(mz_uint16) * 2 + sizeof(mz_uint64) * 3)
+static mz_uint32 mz_zip_writer_create_zip64_extra_data(mz_uint8 *pBuf, mz_uint64 *pUncomp_size, mz_uint64 *pComp_size, mz_uint64 *pLocal_header_ofs)
+{
+    mz_uint8 *pDst = pBuf;
+    mz_uint32 field_size = 0;
+
+    MZ_WRITE_LE16(pDst + 0, MZ_ZIP64_EXTENDED_INFORMATION_FIELD_HEADER_ID);
+    MZ_WRITE_LE16(pDst + 2, 0);
+    pDst += sizeof(mz_uint16) * 2;
+
+    if (pUncomp_size)
+    {
+        MZ_WRITE_LE64(pDst, *pUncomp_size);
+        pDst += sizeof(mz_uint64);
+        field_size += sizeof(mz_uint64);
+    }
+
+    if (pComp_size)
+    {
+        MZ_WRITE_LE64(pDst, *pComp_size);
+        pDst += sizeof(mz_uint64);
+        field_size += sizeof(mz_uint64);
+    }
+
+    if (pLocal_header_ofs)
+    {
+        MZ_WRITE_LE64(pDst, *pLocal_header_ofs);
+        pDst += sizeof(mz_uint64);
+        field_size += sizeof(mz_uint64);
+    }
+
+    MZ_WRITE_LE16(pBuf + 2, field_size);
+
+    return (mz_uint32)(pDst - pBuf);
+}
+
+static mz_bool mz_zip_writer_create_local_dir_header(mz_zip_archive *pZip, mz_uint8 *pDst, mz_uint16 filename_size, mz_uint16 extra_size, mz_uint64 uncomp_size, mz_uint64 comp_size, mz_uint32 uncomp_crc32, mz_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date)
+{
+    (void)pZip;
+    memset(pDst, 0, MZ_ZIP_LOCAL_DIR_HEADER_SIZE);
+    MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_SIG_OFS, MZ_ZIP_LOCAL_DIR_HEADER_SIG);
+    MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_VERSION_NEEDED_OFS, method ? 20 : 0);
+    MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_BIT_FLAG_OFS, bit_flags);
+    MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_METHOD_OFS, method);
+    MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILE_TIME_OFS, dos_time);
+    MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILE_DATE_OFS, dos_date);
+    MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_CRC32_OFS, uncomp_crc32);
+    MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_COMPRESSED_SIZE_OFS, MZ_MIN(comp_size, MZ_UINT32_MAX));
+    MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS, MZ_MIN(uncomp_size, MZ_UINT32_MAX));
+    MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILENAME_LEN_OFS, filename_size);
+    MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_EXTRA_LEN_OFS, extra_size);
+    return MZ_TRUE;
+}
+
+static mz_bool mz_zip_writer_create_central_dir_header(mz_zip_archive *pZip, mz_uint8 *pDst,
+                                                       mz_uint16 filename_size, mz_uint16 extra_size, mz_uint16 comment_size,
+                                                       mz_uint64 uncomp_size, mz_uint64 comp_size, mz_uint32 uncomp_crc32,
+                                                       mz_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date,
+                                                       mz_uint64 local_header_ofs, mz_uint32 ext_attributes)
+{
+    (void)pZip;
+    memset(pDst, 0, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE);
+    MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_SIG_OFS, MZ_ZIP_CENTRAL_DIR_HEADER_SIG);
+    MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_VERSION_NEEDED_OFS, method ? 20 : 0);
+    MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_BIT_FLAG_OFS, bit_flags);
+    MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_METHOD_OFS, method);
+    MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILE_TIME_OFS, dos_time);
+    MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILE_DATE_OFS, dos_date);
+    MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_CRC32_OFS, uncomp_crc32);
+    MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS, MZ_MIN(comp_size, MZ_UINT32_MAX));
+    MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS, MZ_MIN(uncomp_size, MZ_UINT32_MAX));
+    MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILENAME_LEN_OFS, filename_size);
+    MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_EXTRA_LEN_OFS, extra_size);
+    MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_COMMENT_LEN_OFS, comment_size);
+    MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS, ext_attributes);
+    MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_LOCAL_HEADER_OFS, MZ_MIN(local_header_ofs, MZ_UINT32_MAX));
+    return MZ_TRUE;
+}
+
+static mz_bool mz_zip_writer_add_to_central_dir(mz_zip_archive *pZip, const char *pFilename, mz_uint16 filename_size,
+                                                const void *pExtra, mz_uint16 extra_size, const void *pComment, mz_uint16 comment_size,
+                                                mz_uint64 uncomp_size, mz_uint64 comp_size, mz_uint32 uncomp_crc32,
+                                                mz_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date,
+                                                mz_uint64 local_header_ofs, mz_uint32 ext_attributes,
+                                                const char *user_extra_data, mz_uint user_extra_data_len)
+{
+    mz_zip_internal_state *pState = pZip->m_pState;
+    mz_uint32 central_dir_ofs = (mz_uint32)pState->m_central_dir.m_size;
+    size_t orig_central_dir_size = pState->m_central_dir.m_size;
+    mz_uint8 central_dir_header[MZ_ZIP_CENTRAL_DIR_HEADER_SIZE];
+
+    if (!pZip->m_pState->m_zip64)
+    {
+        if (local_header_ofs > 0xFFFFFFFF)
+            return mz_zip_set_error(pZip, MZ_ZIP_FILE_TOO_LARGE);
+    }
+
+    /* miniz doesn't support central dirs >= MZ_UINT32_MAX bytes yet */
+    if (((mz_uint64)pState->m_central_dir.m_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_size + extra_size + user_extra_data_len + comment_size) >= MZ_UINT32_MAX)
+        return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_CDIR_SIZE);
+
+    if (!mz_zip_writer_create_central_dir_header(pZip, central_dir_header, filename_size, extra_size + user_extra_data_len, comment_size, uncomp_size, comp_size, uncomp_crc32, method, bit_flags, dos_time, dos_date, local_header_ofs, ext_attributes))
+        return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR);
+
+    if ((!mz_zip_array_push_back(pZip, &pState->m_central_dir, central_dir_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE)) ||
+        (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pFilename, filename_size)) ||
+        (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pExtra, extra_size)) ||
+        (!mz_zip_array_push_back(pZip, &pState->m_central_dir, user_extra_data, user_extra_data_len)) ||
+        (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pComment, comment_size)) ||
+        (!mz_zip_array_push_back(pZip, &pState->m_central_dir_offsets, &central_dir_ofs, 1)))
+    {
+        /* Try to resize the central directory array back into its original state. */
+        mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE);
+        return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+    }
+
+    return MZ_TRUE;
+}
+
+static mz_bool mz_zip_writer_validate_archive_name(const char *pArchive_name)
+{
+    /* Basic ZIP archive filename validity checks: Valid filenames cannot start with a forward slash, cannot contain a drive letter, and cannot use DOS-style backward slashes. */
+    if (*pArchive_name == '/')
+        return MZ_FALSE;
+
+    while (*pArchive_name)
+    {
+        if ((*pArchive_name == '\\') || (*pArchive_name == ':'))
+            return MZ_FALSE;
+
+        pArchive_name++;
+    }
+
+    return MZ_TRUE;
+}
+
+static mz_uint mz_zip_writer_compute_padding_needed_for_file_alignment(mz_zip_archive *pZip)
+{
+    mz_uint32 n;
+    if (!pZip->m_file_offset_alignment)
+        return 0;
+    n = (mz_uint32)(pZip->m_archive_size & (pZip->m_file_offset_alignment - 1));
+    return (mz_uint)((pZip->m_file_offset_alignment - n) & (pZip->m_file_offset_alignment - 1));
+}
+
+static mz_bool mz_zip_writer_write_zeros(mz_zip_archive *pZip, mz_uint64 cur_file_ofs, mz_uint32 n)
+{
+    char buf[4096];
+    memset(buf, 0, MZ_MIN(sizeof(buf), n));
+    while (n)
+    {
+        mz_uint32 s = MZ_MIN(sizeof(buf), n);
+        if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_file_ofs, buf, s) != s)
+            return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
+
+        cur_file_ofs += s;
+        n -= s;
+    }
+    return MZ_TRUE;
+}
+
+mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags,
+                                 mz_uint64 uncomp_size, mz_uint32 uncomp_crc32)
+{
+    return mz_zip_writer_add_mem_ex_v2(pZip, pArchive_name, pBuf, buf_size, pComment, comment_size, level_and_flags, uncomp_size, uncomp_crc32, NULL, NULL, 0, NULL, 0);
+}
+
+mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size,
+                                    mz_uint level_and_flags, mz_uint64 uncomp_size, mz_uint32 uncomp_crc32, MZ_TIME_T *last_modified,
+                                    const char *user_extra_data, mz_uint user_extra_data_len, const char *user_extra_data_central, mz_uint user_extra_data_central_len)
+{
+    mz_uint16 method = 0, dos_time = 0, dos_date = 0;
+    mz_uint level, ext_attributes = 0, num_alignment_padding_bytes;
+    mz_uint64 local_dir_header_ofs = pZip->m_archive_size, cur_archive_file_ofs = pZip->m_archive_size, comp_size = 0;
+    size_t archive_name_size;
+    mz_uint8 local_dir_header[MZ_ZIP_LOCAL_DIR_HEADER_SIZE];
+    tdefl_compressor *pComp = NULL;
+    mz_bool store_data_uncompressed;
+    mz_zip_internal_state *pState;
+    mz_uint8 *pExtra_data = NULL;
+    mz_uint32 extra_size = 0;
+    mz_uint8 extra_data[MZ_ZIP64_MAX_CENTRAL_EXTRA_FIELD_SIZE];
+    mz_uint16 bit_flags = 0;
+
+    if ((int)level_and_flags < 0)
+        level_and_flags = MZ_DEFAULT_LEVEL;
+
+    if (uncomp_size || (buf_size && !(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)))
+        bit_flags |= MZ_ZIP_LDH_BIT_FLAG_HAS_LOCATOR;
+
+    if (!(level_and_flags & MZ_ZIP_FLAG_ASCII_FILENAME))
+        bit_flags |= MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_UTF8;
+
+    level = level_and_flags & 0xF;
+    store_data_uncompressed = ((!level) || (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA));
+
+    if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || ((buf_size) && (!pBuf)) || (!pArchive_name) || ((comment_size) && (!pComment)) || (level > MZ_UBER_COMPRESSION))
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    pState = pZip->m_pState;
+
+    if (pState->m_zip64)
+    {
+        if (pZip->m_total_files == MZ_UINT32_MAX)
+            return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES);
+    }
+    else
+    {
+        if (pZip->m_total_files == MZ_UINT16_MAX)
+        {
+            pState->m_zip64 = MZ_TRUE;
+            /*return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES); */
+        }
+        if ((buf_size > 0xFFFFFFFF) || (uncomp_size > 0xFFFFFFFF))
+        {
+            pState->m_zip64 = MZ_TRUE;
+            /*return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); */
+        }
+    }
+
+    if ((!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (uncomp_size))
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    if (!mz_zip_writer_validate_archive_name(pArchive_name))
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_FILENAME);
+
+#ifndef MINIZ_NO_TIME
+    if (last_modified != NULL)
+    {
+        mz_zip_time_t_to_dos_time(*last_modified, &dos_time, &dos_date);
+    }
+    else
+    {
+        MZ_TIME_T cur_time;
+        time(&cur_time);
+        mz_zip_time_t_to_dos_time(cur_time, &dos_time, &dos_date);
+    }
+#endif /* #ifndef MINIZ_NO_TIME */
+
+    archive_name_size = strlen(pArchive_name);
+    if (archive_name_size > MZ_UINT16_MAX)
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_FILENAME);
+
+    num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip);
+
+    /* miniz doesn't support central dirs >= MZ_UINT32_MAX bytes yet */
+    if (((mz_uint64)pState->m_central_dir.m_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + archive_name_size + MZ_ZIP64_MAX_CENTRAL_EXTRA_FIELD_SIZE + comment_size) >= MZ_UINT32_MAX)
+        return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_CDIR_SIZE);
+
+    if (!pState->m_zip64)
+    {
+        /* Bail early if the archive would obviously become too large */
+        if ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + archive_name_size 
+			+ MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + archive_name_size + comment_size + user_extra_data_len + 
+			pState->m_central_dir.m_size + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE + user_extra_data_central_len
+			+ MZ_ZIP_DATA_DESCRIPTER_SIZE32) > 0xFFFFFFFF)
+        {
+            pState->m_zip64 = MZ_TRUE;
+            /*return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); */
+        }
+    }
+
+    if ((archive_name_size) && (pArchive_name[archive_name_size - 1] == '/'))
+    {
+        /* Set DOS Subdirectory attribute bit. */
+        ext_attributes |= MZ_ZIP_DOS_DIR_ATTRIBUTE_BITFLAG;
+
+        /* Subdirectories cannot contain data. */
+        if ((buf_size) || (uncomp_size))
+            return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+    }
+
+    /* Try to do any allocations before writing to the archive, so if an allocation fails the file remains unmodified. (A good idea if we're doing an in-place modification.) */
+    if ((!mz_zip_array_ensure_room(pZip, &pState->m_central_dir, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + archive_name_size + comment_size + (pState->m_zip64 ? MZ_ZIP64_MAX_CENTRAL_EXTRA_FIELD_SIZE : 0))) || (!mz_zip_array_ensure_room(pZip, &pState->m_central_dir_offsets, 1)))
+        return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+
+    if ((!store_data_uncompressed) && (buf_size))
+    {
+        if (NULL == (pComp = (tdefl_compressor *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(tdefl_compressor))))
+            return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+    }
+
+    if (!mz_zip_writer_write_zeros(pZip, cur_archive_file_ofs, num_alignment_padding_bytes))
+    {
+        pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);
+        return MZ_FALSE;
+    }
+
+    local_dir_header_ofs += num_alignment_padding_bytes;
+    if (pZip->m_file_offset_alignment)
+    {
+        MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == 0);
+    }
+    cur_archive_file_ofs += num_alignment_padding_bytes;
+
+    MZ_CLEAR_OBJ(local_dir_header);
+
+    if (!store_data_uncompressed || (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA))
+    {
+        method = MZ_DEFLATED;
+    }
+
+    if (pState->m_zip64)
+    {
+        if (uncomp_size >= MZ_UINT32_MAX || local_dir_header_ofs >= MZ_UINT32_MAX)
+        {
+            pExtra_data = extra_data;
+            extra_size = mz_zip_writer_create_zip64_extra_data(extra_data, (uncomp_size >= MZ_UINT32_MAX) ? &uncomp_size : NULL,
+                                                               (uncomp_size >= MZ_UINT32_MAX) ? &comp_size : NULL, (local_dir_header_ofs >= MZ_UINT32_MAX) ? &local_dir_header_ofs : NULL);
+        }
+
+        if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, extra_size + user_extra_data_len, 0, 0, 0, method, bit_flags, dos_time, dos_date))
+            return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR);
+
+        if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header))
+            return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
+
+        cur_archive_file_ofs += sizeof(local_dir_header);
+
+        if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size)
+        {
+            pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);
+            return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
+        }
+        cur_archive_file_ofs += archive_name_size;
+
+        if (pExtra_data != NULL)
+        {
+            if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, extra_data, extra_size) != extra_size)
+                return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
+
+            cur_archive_file_ofs += extra_size;
+        }
+    }
+    else
+    {
+        if ((comp_size > MZ_UINT32_MAX) || (cur_archive_file_ofs > MZ_UINT32_MAX))
+            return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);
+        if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, user_extra_data_len, 0, 0, 0, method, bit_flags, dos_time, dos_date))
+            return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR);
+
+        if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header))
+            return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
+
+        cur_archive_file_ofs += sizeof(local_dir_header);
+
+        if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size)
+        {
+            pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);
+            return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
+        }
+        cur_archive_file_ofs += archive_name_size;
+    }
+
+    if (user_extra_data_len > 0)
+    {
+        if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, user_extra_data, user_extra_data_len) != user_extra_data_len)
+            return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
+
+        cur_archive_file_ofs += user_extra_data_len;
+    }
+
+    if (!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA))
+    {
+        uncomp_crc32 = (mz_uint32)mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf, buf_size);
+        uncomp_size = buf_size;
+        if (uncomp_size <= 3)
+        {
+            level = 0;
+            store_data_uncompressed = MZ_TRUE;
+        }
+    }
+
+    if (store_data_uncompressed)
+    {
+        if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pBuf, buf_size) != buf_size)
+        {
+            pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);
+            return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
+        }
+
+        cur_archive_file_ofs += buf_size;
+        comp_size = buf_size;
+    }
+    else if (buf_size)
+    {
+        mz_zip_writer_add_state state;
+
+        state.m_pZip = pZip;
+        state.m_cur_archive_file_ofs = cur_archive_file_ofs;
+        state.m_comp_size = 0;
+
+        if ((tdefl_init(pComp, mz_zip_writer_add_put_buf_callback, &state, tdefl_create_comp_flags_from_zip_params(level, -15, MZ_DEFAULT_STRATEGY)) != TDEFL_STATUS_OKAY) ||
+            (tdefl_compress_buffer(pComp, pBuf, buf_size, TDEFL_FINISH) != TDEFL_STATUS_DONE))
+        {
+            pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);
+            return mz_zip_set_error(pZip, MZ_ZIP_COMPRESSION_FAILED);
+        }
+
+        comp_size = state.m_comp_size;
+        cur_archive_file_ofs = state.m_cur_archive_file_ofs;
+    }
+
+    pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);
+    pComp = NULL;
+
+    if (uncomp_size)
+    {
+        mz_uint8 local_dir_footer[MZ_ZIP_DATA_DESCRIPTER_SIZE64];
+        mz_uint32 local_dir_footer_size = MZ_ZIP_DATA_DESCRIPTER_SIZE32;
+
+        MZ_ASSERT(bit_flags & MZ_ZIP_LDH_BIT_FLAG_HAS_LOCATOR);
+
+        MZ_WRITE_LE32(local_dir_footer + 0, MZ_ZIP_DATA_DESCRIPTOR_ID);
+        MZ_WRITE_LE32(local_dir_footer + 4, uncomp_crc32);
+        if (pExtra_data == NULL)
+        {
+            if (comp_size > MZ_UINT32_MAX)
+                return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);
+
+            MZ_WRITE_LE32(local_dir_footer + 8, comp_size);
+            MZ_WRITE_LE32(local_dir_footer + 12, uncomp_size);
+        }
+        else
+        {
+            MZ_WRITE_LE64(local_dir_footer + 8, comp_size);
+            MZ_WRITE_LE64(local_dir_footer + 16, uncomp_size);
+            local_dir_footer_size = MZ_ZIP_DATA_DESCRIPTER_SIZE64;
+        }
+
+        if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, local_dir_footer, local_dir_footer_size) != local_dir_footer_size)
+            return MZ_FALSE;
+
+        cur_archive_file_ofs += local_dir_footer_size;
+    }
+
+    if (pExtra_data != NULL)
+    {
+        extra_size = mz_zip_writer_create_zip64_extra_data(extra_data, (uncomp_size >= MZ_UINT32_MAX) ? &uncomp_size : NULL,
+                                                           (uncomp_size >= MZ_UINT32_MAX) ? &comp_size : NULL, (local_dir_header_ofs >= MZ_UINT32_MAX) ? &local_dir_header_ofs : NULL);
+    }
+
+    if (!mz_zip_writer_add_to_central_dir(pZip, pArchive_name, (mz_uint16)archive_name_size, pExtra_data, extra_size, pComment,
+                                          comment_size, uncomp_size, comp_size, uncomp_crc32, method, bit_flags, dos_time, dos_date, local_dir_header_ofs, ext_attributes,
+                                          user_extra_data_central, user_extra_data_central_len))
+        return MZ_FALSE;
+
+    pZip->m_total_files++;
+    pZip->m_archive_size = cur_archive_file_ofs;
+
+    return MZ_TRUE;
+}
+
+#ifndef MINIZ_NO_STDIO
+mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name, MZ_FILE *pSrc_file, mz_uint64 size_to_add, const MZ_TIME_T *pFile_time, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags,
+                                const char *user_extra_data, mz_uint user_extra_data_len, const char *user_extra_data_central, mz_uint user_extra_data_central_len)
+{
+    mz_uint16 gen_flags = MZ_ZIP_LDH_BIT_FLAG_HAS_LOCATOR;
+    mz_uint uncomp_crc32 = MZ_CRC32_INIT, level, num_alignment_padding_bytes;
+    mz_uint16 method = 0, dos_time = 0, dos_date = 0, ext_attributes = 0;
+    mz_uint64 local_dir_header_ofs, cur_archive_file_ofs = pZip->m_archive_size, uncomp_size = size_to_add, comp_size = 0;
+    size_t archive_name_size;
+    mz_uint8 local_dir_header[MZ_ZIP_LOCAL_DIR_HEADER_SIZE];
+    mz_uint8 *pExtra_data = NULL;
+    mz_uint32 extra_size = 0;
+    mz_uint8 extra_data[MZ_ZIP64_MAX_CENTRAL_EXTRA_FIELD_SIZE];
+    mz_zip_internal_state *pState;
+
+    if (!(level_and_flags & MZ_ZIP_FLAG_ASCII_FILENAME))
+        gen_flags |= MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_UTF8;
+
+    if ((int)level_and_flags < 0)
+        level_and_flags = MZ_DEFAULT_LEVEL;
+    level = level_and_flags & 0xF;
+
+    /* Sanity checks */
+    if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || (!pArchive_name) || ((comment_size) && (!pComment)) || (level > MZ_UBER_COMPRESSION))
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    pState = pZip->m_pState;
+
+    if ((!pState->m_zip64) && (uncomp_size > MZ_UINT32_MAX))
+    {
+        /* Source file is too large for non-zip64 */
+        /*return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); */
+        pState->m_zip64 = MZ_TRUE;
+    }
+
+    /* We could support this, but why? */
+    if (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    if (!mz_zip_writer_validate_archive_name(pArchive_name))
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_FILENAME);
+
+    if (pState->m_zip64)
+    {
+        if (pZip->m_total_files == MZ_UINT32_MAX)
+            return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES);
+    }
+    else
+    {
+        if (pZip->m_total_files == MZ_UINT16_MAX)
+        {
+            pState->m_zip64 = MZ_TRUE;
+            /*return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES); */
+        }
+    }
+
+    archive_name_size = strlen(pArchive_name);
+    if (archive_name_size > MZ_UINT16_MAX)
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_FILENAME);
+
+    num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip);
+
+    /* miniz doesn't support central dirs >= MZ_UINT32_MAX bytes yet */
+    if (((mz_uint64)pState->m_central_dir.m_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + archive_name_size + MZ_ZIP64_MAX_CENTRAL_EXTRA_FIELD_SIZE + comment_size) >= MZ_UINT32_MAX)
+        return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_CDIR_SIZE);
+
+    if (!pState->m_zip64)
+    {
+        /* Bail early if the archive would obviously become too large */
+        if ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + archive_name_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE 
+			+ archive_name_size + comment_size + user_extra_data_len + pState->m_central_dir.m_size + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE + 1024
+			+ MZ_ZIP_DATA_DESCRIPTER_SIZE32 + user_extra_data_central_len) > 0xFFFFFFFF)
+        {
+            pState->m_zip64 = MZ_TRUE;
+            /*return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); */
+        }
+    }
+
+#ifndef MINIZ_NO_TIME
+    if (pFile_time)
+    {
+        mz_zip_time_t_to_dos_time(*pFile_time, &dos_time, &dos_date);
+    }
+#endif
+
+    if (uncomp_size <= 3)
+        level = 0;
+
+    if (!mz_zip_writer_write_zeros(pZip, cur_archive_file_ofs, num_alignment_padding_bytes))
+    {
+        return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
+    }
+
+    cur_archive_file_ofs += num_alignment_padding_bytes;
+    local_dir_header_ofs = cur_archive_file_ofs;
+
+    if (pZip->m_file_offset_alignment)
+    {
+        MZ_ASSERT((cur_archive_file_ofs & (pZip->m_file_offset_alignment - 1)) == 0);
+    }
+
+    if (uncomp_size && level)
+    {
+        method = MZ_DEFLATED;
+    }
+
+    MZ_CLEAR_OBJ(local_dir_header);
+    if (pState->m_zip64)
+    {
+        if (uncomp_size >= MZ_UINT32_MAX || local_dir_header_ofs >= MZ_UINT32_MAX)
+        {
+            pExtra_data = extra_data;
+            extra_size = mz_zip_writer_create_zip64_extra_data(extra_data, (uncomp_size >= MZ_UINT32_MAX) ? &uncomp_size : NULL,
+                                                               (uncomp_size >= MZ_UINT32_MAX) ? &comp_size : NULL, (local_dir_header_ofs >= MZ_UINT32_MAX) ? &local_dir_header_ofs : NULL);
+        }
+
+        if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, extra_size + user_extra_data_len, 0, 0, 0, method, gen_flags, dos_time, dos_date))
+            return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR);
+
+        if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header))
+            return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
+
+        cur_archive_file_ofs += sizeof(local_dir_header);
+
+        if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size)
+        {
+            return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
+        }
+
+        cur_archive_file_ofs += archive_name_size;
+
+        if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, extra_data, extra_size) != extra_size)
+            return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
+
+        cur_archive_file_ofs += extra_size;
+    }
+    else
+    {
+        if ((comp_size > MZ_UINT32_MAX) || (cur_archive_file_ofs > MZ_UINT32_MAX))
+            return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);
+        if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, user_extra_data_len, 0, 0, 0, method, gen_flags, dos_time, dos_date))
+            return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR);
+
+        if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header))
+            return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
+
+        cur_archive_file_ofs += sizeof(local_dir_header);
+
+        if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size)
+        {
+            return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
+        }
+
+        cur_archive_file_ofs += archive_name_size;
+    }
+
+    if (user_extra_data_len > 0)
+    {
+        if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, user_extra_data, user_extra_data_len) != user_extra_data_len)
+            return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
+
+        cur_archive_file_ofs += user_extra_data_len;
+    }
+
+    if (uncomp_size)
+    {
+        mz_uint64 uncomp_remaining = uncomp_size;
+        void *pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, MZ_ZIP_MAX_IO_BUF_SIZE);
+        if (!pRead_buf)
+        {
+            return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+        }
+
+        if (!level)
+        {
+            while (uncomp_remaining)
+            {
+                mz_uint n = (mz_uint)MZ_MIN((mz_uint64)MZ_ZIP_MAX_IO_BUF_SIZE, uncomp_remaining);
+                if ((MZ_FREAD(pRead_buf, 1, n, pSrc_file) != n) || (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pRead_buf, n) != n))
+                {
+                    pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);
+                    return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
+                }
+                uncomp_crc32 = (mz_uint32)mz_crc32(uncomp_crc32, (const mz_uint8 *)pRead_buf, n);
+                uncomp_remaining -= n;
+                cur_archive_file_ofs += n;
+            }
+            comp_size = uncomp_size;
+        }
+        else
+        {
+            mz_bool result = MZ_FALSE;
+            mz_zip_writer_add_state state;
+            tdefl_compressor *pComp = (tdefl_compressor *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(tdefl_compressor));
+            if (!pComp)
+            {
+                pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);
+                return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+            }
+
+            state.m_pZip = pZip;
+            state.m_cur_archive_file_ofs = cur_archive_file_ofs;
+            state.m_comp_size = 0;
+
+            if (tdefl_init(pComp, mz_zip_writer_add_put_buf_callback, &state, tdefl_create_comp_flags_from_zip_params(level, -15, MZ_DEFAULT_STRATEGY)) != TDEFL_STATUS_OKAY)
+            {
+                pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);
+                pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);
+                return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR);
+            }
+
+            for (;;)
+            {
+                size_t in_buf_size = (mz_uint32)MZ_MIN(uncomp_remaining, (mz_uint64)MZ_ZIP_MAX_IO_BUF_SIZE);
+                tdefl_status status;
+                tdefl_flush flush = TDEFL_NO_FLUSH;
+
+                if (MZ_FREAD(pRead_buf, 1, in_buf_size, pSrc_file) != in_buf_size)
+                {
+                    mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
+                    break;
+                }
+
+                uncomp_crc32 = (mz_uint32)mz_crc32(uncomp_crc32, (const mz_uint8 *)pRead_buf, in_buf_size);
+                uncomp_remaining -= in_buf_size;
+
+                if (pZip->m_pNeeds_keepalive != NULL && pZip->m_pNeeds_keepalive(pZip->m_pIO_opaque))
+                    flush = TDEFL_FULL_FLUSH;
+
+                status = tdefl_compress_buffer(pComp, pRead_buf, in_buf_size, uncomp_remaining ? flush : TDEFL_FINISH);
+                if (status == TDEFL_STATUS_DONE)
+                {
+                    result = MZ_TRUE;
+                    break;
+                }
+                else if (status != TDEFL_STATUS_OKAY)
+                {
+                    mz_zip_set_error(pZip, MZ_ZIP_COMPRESSION_FAILED);
+                    break;
+                }
+            }
+
+            pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);
+
+            if (!result)
+            {
+                pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);
+                return MZ_FALSE;
+            }
+
+            comp_size = state.m_comp_size;
+            cur_archive_file_ofs = state.m_cur_archive_file_ofs;
+        }
+
+        pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);
+    }
+
+    {
+        mz_uint8 local_dir_footer[MZ_ZIP_DATA_DESCRIPTER_SIZE64];
+        mz_uint32 local_dir_footer_size = MZ_ZIP_DATA_DESCRIPTER_SIZE32;
+
+        MZ_WRITE_LE32(local_dir_footer + 0, MZ_ZIP_DATA_DESCRIPTOR_ID);
+        MZ_WRITE_LE32(local_dir_footer + 4, uncomp_crc32);
+        if (pExtra_data == NULL)
+        {
+            if (comp_size > MZ_UINT32_MAX)
+                return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);
+
+            MZ_WRITE_LE32(local_dir_footer + 8, comp_size);
+            MZ_WRITE_LE32(local_dir_footer + 12, uncomp_size);
+        }
+        else
+        {
+            MZ_WRITE_LE64(local_dir_footer + 8, comp_size);
+            MZ_WRITE_LE64(local_dir_footer + 16, uncomp_size);
+            local_dir_footer_size = MZ_ZIP_DATA_DESCRIPTER_SIZE64;
+        }
+
+        if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, local_dir_footer, local_dir_footer_size) != local_dir_footer_size)
+            return MZ_FALSE;
+
+        cur_archive_file_ofs += local_dir_footer_size;
+    }
+
+    if (pExtra_data != NULL)
+    {
+        extra_size = mz_zip_writer_create_zip64_extra_data(extra_data, (uncomp_size >= MZ_UINT32_MAX) ? &uncomp_size : NULL,
+                                                           (uncomp_size >= MZ_UINT32_MAX) ? &comp_size : NULL, (local_dir_header_ofs >= MZ_UINT32_MAX) ? &local_dir_header_ofs : NULL);
+    }
+
+    if (!mz_zip_writer_add_to_central_dir(pZip, pArchive_name, (mz_uint16)archive_name_size, pExtra_data, extra_size, pComment, comment_size,
+                                          uncomp_size, comp_size, uncomp_crc32, method, gen_flags, dos_time, dos_date, local_dir_header_ofs, ext_attributes,
+                                          user_extra_data_central, user_extra_data_central_len))
+        return MZ_FALSE;
+
+    pZip->m_total_files++;
+    pZip->m_archive_size = cur_archive_file_ofs;
+
+    return MZ_TRUE;
+}
+
+mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, const char *pSrc_filename, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags)
+{
+    MZ_FILE *pSrc_file = NULL;
+    mz_uint64 uncomp_size = 0;
+    MZ_TIME_T file_modified_time;
+    MZ_TIME_T *pFile_time = NULL;
+    mz_bool status;
+
+    memset(&file_modified_time, 0, sizeof(file_modified_time));
+
+#if !defined(MINIZ_NO_TIME) && !defined(MINIZ_NO_STDIO)
+    pFile_time = &file_modified_time;
+    if (!mz_zip_get_file_modified_time(pSrc_filename, &file_modified_time))
+        return mz_zip_set_error(pZip, MZ_ZIP_FILE_STAT_FAILED);
+#endif
+
+    pSrc_file = MZ_FOPEN(pSrc_filename, "rb");
+    if (!pSrc_file)
+        return mz_zip_set_error(pZip, MZ_ZIP_FILE_OPEN_FAILED);
+
+    MZ_FSEEK64(pSrc_file, 0, SEEK_END);
+    uncomp_size = MZ_FTELL64(pSrc_file);
+    MZ_FSEEK64(pSrc_file, 0, SEEK_SET);
+
+    status = mz_zip_writer_add_cfile(pZip, pArchive_name, pSrc_file, uncomp_size, pFile_time, pComment, comment_size, level_and_flags, NULL, 0, NULL, 0);
+
+    MZ_FCLOSE(pSrc_file);
+
+    return status;
+}
+#endif /* #ifndef MINIZ_NO_STDIO */
+
+static mz_bool mz_zip_writer_update_zip64_extension_block(mz_zip_array *pNew_ext, mz_zip_archive *pZip, const mz_uint8 *pExt, uint32_t ext_len, mz_uint64 *pComp_size, mz_uint64 *pUncomp_size, mz_uint64 *pLocal_header_ofs, mz_uint32 *pDisk_start)
+{
+    /* + 64 should be enough for any new zip64 data */
+    if (!mz_zip_array_reserve(pZip, pNew_ext, ext_len + 64, MZ_FALSE))
+        return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+
+    mz_zip_array_resize(pZip, pNew_ext, 0, MZ_FALSE);
+
+    if ((pUncomp_size) || (pComp_size) || (pLocal_header_ofs) || (pDisk_start))
+    {
+        mz_uint8 new_ext_block[64];
+        mz_uint8 *pDst = new_ext_block;
+        mz_write_le16(pDst, MZ_ZIP64_EXTENDED_INFORMATION_FIELD_HEADER_ID);
+        mz_write_le16(pDst + sizeof(mz_uint16), 0);
+        pDst += sizeof(mz_uint16) * 2;
+
+        if (pUncomp_size)
+        {
+            mz_write_le64(pDst, *pUncomp_size);
+            pDst += sizeof(mz_uint64);
+        }
+
+        if (pComp_size)
+        {
+            mz_write_le64(pDst, *pComp_size);
+            pDst += sizeof(mz_uint64);
+        }
+
+        if (pLocal_header_ofs)
+        {
+            mz_write_le64(pDst, *pLocal_header_ofs);
+            pDst += sizeof(mz_uint64);
+        }
+
+        if (pDisk_start)
+        {
+            mz_write_le32(pDst, *pDisk_start);
+            pDst += sizeof(mz_uint32);
+        }
+
+        mz_write_le16(new_ext_block + sizeof(mz_uint16), (mz_uint16)((pDst - new_ext_block) - sizeof(mz_uint16) * 2));
+
+        if (!mz_zip_array_push_back(pZip, pNew_ext, new_ext_block, pDst - new_ext_block))
+            return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+    }
+
+    if ((pExt) && (ext_len))
+    {
+        mz_uint32 extra_size_remaining = ext_len;
+        const mz_uint8 *pExtra_data = pExt;
+
+        do
+        {
+            mz_uint32 field_id, field_data_size, field_total_size;
+
+            if (extra_size_remaining < (sizeof(mz_uint16) * 2))
+                return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+
+            field_id = MZ_READ_LE16(pExtra_data);
+            field_data_size = MZ_READ_LE16(pExtra_data + sizeof(mz_uint16));
+            field_total_size = field_data_size + sizeof(mz_uint16) * 2;
+
+            if (field_total_size > extra_size_remaining)
+                return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+
+            if (field_id != MZ_ZIP64_EXTENDED_INFORMATION_FIELD_HEADER_ID)
+            {
+                if (!mz_zip_array_push_back(pZip, pNew_ext, pExtra_data, field_total_size))
+                    return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+            }
+
+            pExtra_data += field_total_size;
+            extra_size_remaining -= field_total_size;
+        } while (extra_size_remaining);
+    }
+
+    return MZ_TRUE;
+}
+
+/* TODO: This func is now pretty freakin complex due to zip64, split it up? */
+mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint src_file_index)
+{
+    mz_uint n, bit_flags, num_alignment_padding_bytes, src_central_dir_following_data_size;
+    mz_uint64 src_archive_bytes_remaining, local_dir_header_ofs;
+    mz_uint64 cur_src_file_ofs, cur_dst_file_ofs;
+    mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)];
+    mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32;
+    mz_uint8 new_central_header[MZ_ZIP_CENTRAL_DIR_HEADER_SIZE];
+    size_t orig_central_dir_size;
+    mz_zip_internal_state *pState;
+    void *pBuf;
+    const mz_uint8 *pSrc_central_header;
+    mz_zip_archive_file_stat src_file_stat;
+    mz_uint32 src_filename_len, src_comment_len, src_ext_len;
+    mz_uint32 local_header_filename_size, local_header_extra_len;
+    mz_uint64 local_header_comp_size, local_header_uncomp_size;
+    mz_bool found_zip64_ext_data_in_ldir = MZ_FALSE;
+
+    /* Sanity checks */
+    if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || (!pSource_zip->m_pRead))
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    pState = pZip->m_pState;
+
+    /* Don't support copying files from zip64 archives to non-zip64, even though in some cases this is possible */
+    if ((pSource_zip->m_pState->m_zip64) && (!pZip->m_pState->m_zip64))
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    /* Get pointer to the source central dir header and crack it */
+    if (NULL == (pSrc_central_header = mz_zip_get_cdh(pSource_zip, src_file_index)))
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    if (MZ_READ_LE32(pSrc_central_header + MZ_ZIP_CDH_SIG_OFS) != MZ_ZIP_CENTRAL_DIR_HEADER_SIG)
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+
+    src_filename_len = MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_FILENAME_LEN_OFS);
+    src_comment_len = MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_COMMENT_LEN_OFS);
+    src_ext_len = MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_EXTRA_LEN_OFS);
+    src_central_dir_following_data_size = src_filename_len + src_ext_len + src_comment_len;
+
+    /* TODO: We don't support central dir's >= MZ_UINT32_MAX bytes right now (+32 fudge factor in case we need to add more extra data) */
+    if ((pState->m_central_dir.m_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + src_central_dir_following_data_size + 32) >= MZ_UINT32_MAX)
+        return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_CDIR_SIZE);
+
+    num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip);
+
+    if (!pState->m_zip64)
+    {
+        if (pZip->m_total_files == MZ_UINT16_MAX)
+            return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES);
+    }
+    else
+    {
+        /* TODO: Our zip64 support still has some 32-bit limits that may not be worth fixing. */
+        if (pZip->m_total_files == MZ_UINT32_MAX)
+            return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES);
+    }
+
+    if (!mz_zip_file_stat_internal(pSource_zip, src_file_index, pSrc_central_header, &src_file_stat, NULL))
+        return MZ_FALSE;
+
+    cur_src_file_ofs = src_file_stat.m_local_header_ofs;
+    cur_dst_file_ofs = pZip->m_archive_size;
+
+    /* Read the source archive's local dir header */
+    if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE)
+        return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
+
+    if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG)
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+
+    cur_src_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE;
+
+    /* Compute the total size we need to copy (filename+extra data+compressed data) */
+    local_header_filename_size = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS);
+    local_header_extra_len = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS);
+    local_header_comp_size = MZ_READ_LE32(pLocal_header + MZ_ZIP_LDH_COMPRESSED_SIZE_OFS);
+    local_header_uncomp_size = MZ_READ_LE32(pLocal_header + MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS);
+    src_archive_bytes_remaining = local_header_filename_size + local_header_extra_len + src_file_stat.m_comp_size;
+
+    /* Try to find a zip64 extended information field */
+    if ((local_header_extra_len) && ((local_header_comp_size == MZ_UINT32_MAX) || (local_header_uncomp_size == MZ_UINT32_MAX)))
+    {
+        mz_zip_array file_data_array;
+        const mz_uint8 *pExtra_data;
+        mz_uint32 extra_size_remaining = local_header_extra_len;
+
+        mz_zip_array_init(&file_data_array, 1);
+        if (!mz_zip_array_resize(pZip, &file_data_array, local_header_extra_len, MZ_FALSE))
+        {
+            return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+        }
+
+        if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, src_file_stat.m_local_header_ofs + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + local_header_filename_size, file_data_array.m_p, local_header_extra_len) != local_header_extra_len)
+        {
+            mz_zip_array_clear(pZip, &file_data_array);
+            return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
+        }
+
+        pExtra_data = (const mz_uint8 *)file_data_array.m_p;
+
+        do
+        {
+            mz_uint32 field_id, field_data_size, field_total_size;
+
+            if (extra_size_remaining < (sizeof(mz_uint16) * 2))
+            {
+                mz_zip_array_clear(pZip, &file_data_array);
+                return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+            }
+
+            field_id = MZ_READ_LE16(pExtra_data);
+            field_data_size = MZ_READ_LE16(pExtra_data + sizeof(mz_uint16));
+            field_total_size = field_data_size + sizeof(mz_uint16) * 2;
+
+            if (field_total_size > extra_size_remaining)
+            {
+                mz_zip_array_clear(pZip, &file_data_array);
+                return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+            }
+
+            if (field_id == MZ_ZIP64_EXTENDED_INFORMATION_FIELD_HEADER_ID)
+            {
+                const mz_uint8 *pSrc_field_data = pExtra_data + sizeof(mz_uint32);
+
+                if (field_data_size < sizeof(mz_uint64) * 2)
+                {
+                    mz_zip_array_clear(pZip, &file_data_array);
+                    return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
+                }
+
+                local_header_uncomp_size = MZ_READ_LE64(pSrc_field_data);
+                local_header_comp_size = MZ_READ_LE64(pSrc_field_data + sizeof(mz_uint64)); /* may be 0 if there's a descriptor */
+
+                found_zip64_ext_data_in_ldir = MZ_TRUE;
+                break;
+            }
+
+            pExtra_data += field_total_size;
+            extra_size_remaining -= field_total_size;
+        } while (extra_size_remaining);
+
+        mz_zip_array_clear(pZip, &file_data_array);
+    }
+
+    if (!pState->m_zip64)
+    {
+        /* Try to detect if the new archive will most likely wind up too big and bail early (+(sizeof(mz_uint32) * 4) is for the optional descriptor which could be present, +64 is a fudge factor). */
+        /* We also check when the archive is finalized so this doesn't need to be perfect. */
+        mz_uint64 approx_new_archive_size = cur_dst_file_ofs + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + src_archive_bytes_remaining + (sizeof(mz_uint32) * 4) +
+                                            pState->m_central_dir.m_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + src_central_dir_following_data_size + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE + 64;
+
+        if (approx_new_archive_size >= MZ_UINT32_MAX)
+            return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);
+    }
+
+    /* Write dest archive padding */
+    if (!mz_zip_writer_write_zeros(pZip, cur_dst_file_ofs, num_alignment_padding_bytes))
+        return MZ_FALSE;
+
+    cur_dst_file_ofs += num_alignment_padding_bytes;
+
+    local_dir_header_ofs = cur_dst_file_ofs;
+    if (pZip->m_file_offset_alignment)
+    {
+        MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == 0);
+    }
+
+    /* The original zip's local header+ext block doesn't change, even with zip64, so we can just copy it over to the dest zip */
+    if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE)
+        return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
+
+    cur_dst_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE;
+
+    /* Copy over the source archive bytes to the dest archive, also ensure we have enough buf space to handle optional data descriptor */
+    if (NULL == (pBuf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)MZ_MAX(32U, MZ_MIN((mz_uint64)MZ_ZIP_MAX_IO_BUF_SIZE, src_archive_bytes_remaining)))))
+        return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+
+    while (src_archive_bytes_remaining)
+    {
+        n = (mz_uint)MZ_MIN((mz_uint64)MZ_ZIP_MAX_IO_BUF_SIZE, src_archive_bytes_remaining);
+        if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf, n) != n)
+        {
+            pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);
+            return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
+        }
+        cur_src_file_ofs += n;
+
+        if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pBuf, n) != n)
+        {
+            pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);
+            return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
+        }
+        cur_dst_file_ofs += n;
+
+        src_archive_bytes_remaining -= n;
+    }
+
+    /* Now deal with the optional data descriptor */
+    bit_flags = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_BIT_FLAG_OFS);
+    if (bit_flags & 8)
+    {
+        /* Copy data descriptor */
+        if ((pSource_zip->m_pState->m_zip64) || (found_zip64_ext_data_in_ldir))
+        {
+            /* src is zip64, dest must be zip64 */
+
+            /* name			uint32_t's */
+            /* id				1 (optional in zip64?) */
+            /* crc			1 */
+            /* comp_size	2 */
+            /* uncomp_size 2 */
+            if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf, (sizeof(mz_uint32) * 6)) != (sizeof(mz_uint32) * 6))
+            {
+                pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);
+                return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
+            }
+
+            n = sizeof(mz_uint32) * ((MZ_READ_LE32(pBuf) == MZ_ZIP_DATA_DESCRIPTOR_ID) ? 6 : 5);
+        }
+        else
+        {
+            /* src is NOT zip64 */
+            mz_bool has_id;
+
+            if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf, sizeof(mz_uint32) * 4) != sizeof(mz_uint32) * 4)
+            {
+                pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);
+                return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
+            }
+
+            has_id = (MZ_READ_LE32(pBuf) == MZ_ZIP_DATA_DESCRIPTOR_ID);
+
+            if (pZip->m_pState->m_zip64)
+            {
+                /* dest is zip64, so upgrade the data descriptor */
+                const mz_uint32 *pSrc_descriptor = (const mz_uint32 *)((const mz_uint8 *)pBuf + (has_id ? sizeof(mz_uint32) : 0));
+                const mz_uint32 src_crc32 = pSrc_descriptor[0];
+                const mz_uint64 src_comp_size = pSrc_descriptor[1];
+                const mz_uint64 src_uncomp_size = pSrc_descriptor[2];
+
+                mz_write_le32((mz_uint8 *)pBuf, MZ_ZIP_DATA_DESCRIPTOR_ID);
+                mz_write_le32((mz_uint8 *)pBuf + sizeof(mz_uint32) * 1, src_crc32);
+                mz_write_le64((mz_uint8 *)pBuf + sizeof(mz_uint32) * 2, src_comp_size);
+                mz_write_le64((mz_uint8 *)pBuf + sizeof(mz_uint32) * 4, src_uncomp_size);
+
+                n = sizeof(mz_uint32) * 6;
+            }
+            else
+            {
+                /* dest is NOT zip64, just copy it as-is */
+                n = sizeof(mz_uint32) * (has_id ? 4 : 3);
+            }
+        }
+
+        if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pBuf, n) != n)
+        {
+            pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);
+            return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
+        }
+
+        cur_src_file_ofs += n;
+        cur_dst_file_ofs += n;
+    }
+    pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);
+
+    /* Finally, add the new central dir header */
+    orig_central_dir_size = pState->m_central_dir.m_size;
+
+    memcpy(new_central_header, pSrc_central_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE);
+
+    if (pState->m_zip64)
+    {
+        /* This is the painful part: We need to write a new central dir header + ext block with updated zip64 fields, and ensure the old fields (if any) are not included. */
+        const mz_uint8 *pSrc_ext = pSrc_central_header + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + src_filename_len;
+        mz_zip_array new_ext_block;
+
+        mz_zip_array_init(&new_ext_block, sizeof(mz_uint8));
+
+        MZ_WRITE_LE32(new_central_header + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS, MZ_UINT32_MAX);
+        MZ_WRITE_LE32(new_central_header + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS, MZ_UINT32_MAX);
+        MZ_WRITE_LE32(new_central_header + MZ_ZIP_CDH_LOCAL_HEADER_OFS, MZ_UINT32_MAX);
+
+        if (!mz_zip_writer_update_zip64_extension_block(&new_ext_block, pZip, pSrc_ext, src_ext_len, &src_file_stat.m_comp_size, &src_file_stat.m_uncomp_size, &local_dir_header_ofs, NULL))
+        {
+            mz_zip_array_clear(pZip, &new_ext_block);
+            return MZ_FALSE;
+        }
+
+        MZ_WRITE_LE16(new_central_header + MZ_ZIP_CDH_EXTRA_LEN_OFS, new_ext_block.m_size);
+
+        if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, new_central_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE))
+        {
+            mz_zip_array_clear(pZip, &new_ext_block);
+            return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+        }
+
+        if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pSrc_central_header + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, src_filename_len))
+        {
+            mz_zip_array_clear(pZip, &new_ext_block);
+            mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE);
+            return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+        }
+
+        if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, new_ext_block.m_p, new_ext_block.m_size))
+        {
+            mz_zip_array_clear(pZip, &new_ext_block);
+            mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE);
+            return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+        }
+
+        if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pSrc_central_header + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + src_filename_len + src_ext_len, src_comment_len))
+        {
+            mz_zip_array_clear(pZip, &new_ext_block);
+            mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE);
+            return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+        }
+
+        mz_zip_array_clear(pZip, &new_ext_block);
+    }
+    else
+    {
+        /* sanity checks */
+        if (cur_dst_file_ofs > MZ_UINT32_MAX)
+            return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);
+
+        if (local_dir_header_ofs >= MZ_UINT32_MAX)
+            return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);
+
+        MZ_WRITE_LE32(new_central_header + MZ_ZIP_CDH_LOCAL_HEADER_OFS, local_dir_header_ofs);
+
+        if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, new_central_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE))
+            return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+
+        if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pSrc_central_header + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, src_central_dir_following_data_size))
+        {
+            mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE);
+            return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+        }
+    }
+
+    /* This shouldn't trigger unless we screwed up during the initial sanity checks */
+    if (pState->m_central_dir.m_size >= MZ_UINT32_MAX)
+    {
+        /* TODO: Support central dirs >= 32-bits in size */
+        mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE);
+        return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_CDIR_SIZE);
+    }
+
+    n = (mz_uint32)orig_central_dir_size;
+    if (!mz_zip_array_push_back(pZip, &pState->m_central_dir_offsets, &n, 1))
+    {
+        mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE);
+        return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
+    }
+
+    pZip->m_total_files++;
+    pZip->m_archive_size = cur_dst_file_ofs;
+
+    return MZ_TRUE;
+}
+
+mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip)
+{
+    mz_zip_internal_state *pState;
+    mz_uint64 central_dir_ofs, central_dir_size;
+    mz_uint8 hdr[256];
+
+    if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING))
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    pState = pZip->m_pState;
+
+    if (pState->m_zip64)
+    {
+        if ((pZip->m_total_files > MZ_UINT32_MAX) || (pState->m_central_dir.m_size >= MZ_UINT32_MAX))
+            return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES);
+    }
+    else
+    {
+        if ((pZip->m_total_files > MZ_UINT16_MAX) || ((pZip->m_archive_size + pState->m_central_dir.m_size + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) > MZ_UINT32_MAX))
+            return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES);
+    }
+
+    central_dir_ofs = 0;
+    central_dir_size = 0;
+    if (pZip->m_total_files)
+    {
+        /* Write central directory */
+        central_dir_ofs = pZip->m_archive_size;
+        central_dir_size = pState->m_central_dir.m_size;
+        pZip->m_central_directory_file_ofs = central_dir_ofs;
+        if (pZip->m_pWrite(pZip->m_pIO_opaque, central_dir_ofs, pState->m_central_dir.m_p, (size_t)central_dir_size) != central_dir_size)
+            return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
+
+        pZip->m_archive_size += central_dir_size;
+    }
+
+    if (pState->m_zip64)
+    {
+        /* Write zip64 end of central directory header */
+        mz_uint64 rel_ofs_to_zip64_ecdr = pZip->m_archive_size;
+
+        MZ_CLEAR_OBJ(hdr);
+        MZ_WRITE_LE32(hdr + MZ_ZIP64_ECDH_SIG_OFS, MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIG);
+        MZ_WRITE_LE64(hdr + MZ_ZIP64_ECDH_SIZE_OF_RECORD_OFS, MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIZE - sizeof(mz_uint32) - sizeof(mz_uint64));
+        MZ_WRITE_LE16(hdr + MZ_ZIP64_ECDH_VERSION_MADE_BY_OFS, 0x031E); /* TODO: always Unix */
+        MZ_WRITE_LE16(hdr + MZ_ZIP64_ECDH_VERSION_NEEDED_OFS, 0x002D);
+        MZ_WRITE_LE64(hdr + MZ_ZIP64_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS, pZip->m_total_files);
+        MZ_WRITE_LE64(hdr + MZ_ZIP64_ECDH_CDIR_TOTAL_ENTRIES_OFS, pZip->m_total_files);
+        MZ_WRITE_LE64(hdr + MZ_ZIP64_ECDH_CDIR_SIZE_OFS, central_dir_size);
+        MZ_WRITE_LE64(hdr + MZ_ZIP64_ECDH_CDIR_OFS_OFS, central_dir_ofs);
+        if (pZip->m_pWrite(pZip->m_pIO_opaque, pZip->m_archive_size, hdr, MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIZE) != MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIZE)
+            return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
+
+        pZip->m_archive_size += MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIZE;
+
+        /* Write zip64 end of central directory locator */
+        MZ_CLEAR_OBJ(hdr);
+        MZ_WRITE_LE32(hdr + MZ_ZIP64_ECDL_SIG_OFS, MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIG);
+        MZ_WRITE_LE64(hdr + MZ_ZIP64_ECDL_REL_OFS_TO_ZIP64_ECDR_OFS, rel_ofs_to_zip64_ecdr);
+        MZ_WRITE_LE32(hdr + MZ_ZIP64_ECDL_TOTAL_NUMBER_OF_DISKS_OFS, 1);
+        if (pZip->m_pWrite(pZip->m_pIO_opaque, pZip->m_archive_size, hdr, MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIZE) != MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIZE)
+            return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
+
+        pZip->m_archive_size += MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIZE;
+    }
+
+    /* Write end of central directory record */
+    MZ_CLEAR_OBJ(hdr);
+    MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_SIG_OFS, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG);
+    MZ_WRITE_LE16(hdr + MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS, MZ_MIN(MZ_UINT16_MAX, pZip->m_total_files));
+    MZ_WRITE_LE16(hdr + MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS, MZ_MIN(MZ_UINT16_MAX, pZip->m_total_files));
+    MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_CDIR_SIZE_OFS, MZ_MIN(MZ_UINT32_MAX, central_dir_size));
+    MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_CDIR_OFS_OFS, MZ_MIN(MZ_UINT32_MAX, central_dir_ofs));
+
+    if (pZip->m_pWrite(pZip->m_pIO_opaque, pZip->m_archive_size, hdr, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) != MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE)
+        return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
+
+#ifndef MINIZ_NO_STDIO
+    if ((pState->m_pFile) && (MZ_FFLUSH(pState->m_pFile) == EOF))
+        return mz_zip_set_error(pZip, MZ_ZIP_FILE_CLOSE_FAILED);
+#endif /* #ifndef MINIZ_NO_STDIO */
+
+    pZip->m_archive_size += MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE;
+
+    pZip->m_zip_mode = MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED;
+    return MZ_TRUE;
+}
+
+mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **ppBuf, size_t *pSize)
+{
+    if ((!ppBuf) || (!pSize))
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    *ppBuf = NULL;
+    *pSize = 0;
+
+    if ((!pZip) || (!pZip->m_pState))
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    if (pZip->m_pWrite != mz_zip_heap_write_func)
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    if (!mz_zip_writer_finalize_archive(pZip))
+        return MZ_FALSE;
+
+    *ppBuf = pZip->m_pState->m_pMem;
+    *pSize = pZip->m_pState->m_mem_size;
+    pZip->m_pState->m_pMem = NULL;
+    pZip->m_pState->m_mem_size = pZip->m_pState->m_mem_capacity = 0;
+
+    return MZ_TRUE;
+}
+
+mz_bool mz_zip_writer_end(mz_zip_archive *pZip)
+{
+    return mz_zip_writer_end_internal(pZip, MZ_TRUE);
+}
+
+#ifndef MINIZ_NO_STDIO
+mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags)
+{
+    return mz_zip_add_mem_to_archive_file_in_place_v2(pZip_filename, pArchive_name, pBuf, buf_size, pComment, comment_size, level_and_flags, NULL);
+}
+
+mz_bool mz_zip_add_mem_to_archive_file_in_place_v2(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, mz_zip_error *pErr)
+{
+    mz_bool status, created_new_archive = MZ_FALSE;
+    mz_zip_archive zip_archive;
+    struct MZ_FILE_STAT_STRUCT file_stat;
+    mz_zip_error actual_err = MZ_ZIP_NO_ERROR;
+
+    mz_zip_zero_struct(&zip_archive);
+    if ((int)level_and_flags < 0)
+        level_and_flags = MZ_DEFAULT_LEVEL;
+
+    if ((!pZip_filename) || (!pArchive_name) || ((buf_size) && (!pBuf)) || ((comment_size) && (!pComment)) || ((level_and_flags & 0xF) > MZ_UBER_COMPRESSION))
+    {
+        if (pErr)
+            *pErr = MZ_ZIP_INVALID_PARAMETER;
+        return MZ_FALSE;
+    }
+
+    if (!mz_zip_writer_validate_archive_name(pArchive_name))
+    {
+        if (pErr)
+            *pErr = MZ_ZIP_INVALID_FILENAME;
+        return MZ_FALSE;
+    }
+
+    /* Important: The regular non-64 bit version of stat() can fail here if the file is very large, which could cause the archive to be overwritten. */
+    /* So be sure to compile with _LARGEFILE64_SOURCE 1 */
+    if (MZ_FILE_STAT(pZip_filename, &file_stat) != 0)
+    {
+        /* Create a new archive. */
+        if (!mz_zip_writer_init_file_v2(&zip_archive, pZip_filename, 0, level_and_flags))
+        {
+            if (pErr)
+                *pErr = zip_archive.m_last_error;
+            return MZ_FALSE;
+        }
+
+        created_new_archive = MZ_TRUE;
+    }
+    else
+    {
+        /* Append to an existing archive. */
+        if (!mz_zip_reader_init_file_v2(&zip_archive, pZip_filename, level_and_flags | MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY, 0, 0))
+        {
+            if (pErr)
+                *pErr = zip_archive.m_last_error;
+            return MZ_FALSE;
+        }
+
+        if (!mz_zip_writer_init_from_reader_v2(&zip_archive, pZip_filename, level_and_flags))
+        {
+            if (pErr)
+                *pErr = zip_archive.m_last_error;
+
+            mz_zip_reader_end_internal(&zip_archive, MZ_FALSE);
+
+            return MZ_FALSE;
+        }
+    }
+
+    status = mz_zip_writer_add_mem_ex(&zip_archive, pArchive_name, pBuf, buf_size, pComment, comment_size, level_and_flags, 0, 0);
+    actual_err = zip_archive.m_last_error;
+
+    /* Always finalize, even if adding failed for some reason, so we have a valid central directory. (This may not always succeed, but we can try.) */
+    if (!mz_zip_writer_finalize_archive(&zip_archive))
+    {
+        if (!actual_err)
+            actual_err = zip_archive.m_last_error;
+
+        status = MZ_FALSE;
+    }
+
+    if (!mz_zip_writer_end_internal(&zip_archive, status))
+    {
+        if (!actual_err)
+            actual_err = zip_archive.m_last_error;
+
+        status = MZ_FALSE;
+    }
+
+    if ((!status) && (created_new_archive))
+    {
+        /* It's a new archive and something went wrong, so just delete it. */
+        int ignoredStatus = MZ_DELETE_FILE(pZip_filename);
+        (void)ignoredStatus;
+    }
+
+    if (pErr)
+        *pErr = actual_err;
+
+    return status;
+}
+
+void *mz_zip_extract_archive_file_to_heap_v2(const char *pZip_filename, const char *pArchive_name, const char *pComment, size_t *pSize, mz_uint flags, mz_zip_error *pErr)
+{
+    mz_uint32 file_index;
+    mz_zip_archive zip_archive;
+    void *p = NULL;
+
+    if (pSize)
+        *pSize = 0;
+
+    if ((!pZip_filename) || (!pArchive_name))
+    {
+        if (pErr)
+            *pErr = MZ_ZIP_INVALID_PARAMETER;
+
+        return NULL;
+    }
+
+    mz_zip_zero_struct(&zip_archive);
+    if (!mz_zip_reader_init_file_v2(&zip_archive, pZip_filename, flags | MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY, 0, 0))
+    {
+        if (pErr)
+            *pErr = zip_archive.m_last_error;
+
+        return NULL;
+    }
+
+    if (mz_zip_reader_locate_file_v2(&zip_archive, pArchive_name, pComment, flags, &file_index))
+    {
+        p = mz_zip_reader_extract_to_heap(&zip_archive, file_index, pSize, flags);
+    }
+
+    mz_zip_reader_end_internal(&zip_archive, p != NULL);
+
+    if (pErr)
+        *pErr = zip_archive.m_last_error;
+
+    return p;
+}
+
+void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint flags)
+{
+    return mz_zip_extract_archive_file_to_heap_v2(pZip_filename, pArchive_name, NULL, pSize, flags, NULL);
+}
+
+#endif /* #ifndef MINIZ_NO_STDIO */
+
+#endif /* #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS */
+
+/* ------------------- Misc utils */
+
+mz_zip_mode mz_zip_get_mode(mz_zip_archive *pZip)
+{
+    return pZip ? pZip->m_zip_mode : MZ_ZIP_MODE_INVALID;
+}
+
+mz_zip_type mz_zip_get_type(mz_zip_archive *pZip)
+{
+    return pZip ? pZip->m_zip_type : MZ_ZIP_TYPE_INVALID;
+}
+
+mz_zip_error mz_zip_set_last_error(mz_zip_archive *pZip, mz_zip_error err_num)
+{
+    mz_zip_error prev_err;
+
+    if (!pZip)
+        return MZ_ZIP_INVALID_PARAMETER;
+
+    prev_err = pZip->m_last_error;
+
+    pZip->m_last_error = err_num;
+    return prev_err;
+}
+
+mz_zip_error mz_zip_peek_last_error(mz_zip_archive *pZip)
+{
+    if (!pZip)
+        return MZ_ZIP_INVALID_PARAMETER;
+
+    return pZip->m_last_error;
+}
+
+mz_zip_error mz_zip_clear_last_error(mz_zip_archive *pZip)
+{
+    return mz_zip_set_last_error(pZip, MZ_ZIP_NO_ERROR);
+}
+
+mz_zip_error mz_zip_get_last_error(mz_zip_archive *pZip)
+{
+    mz_zip_error prev_err;
+
+    if (!pZip)
+        return MZ_ZIP_INVALID_PARAMETER;
+
+    prev_err = pZip->m_last_error;
+
+    pZip->m_last_error = MZ_ZIP_NO_ERROR;
+    return prev_err;
+}
+
+const char *mz_zip_get_error_string(mz_zip_error mz_err)
+{
+    switch (mz_err)
+    {
+        case MZ_ZIP_NO_ERROR:
+            return "no error";
+        case MZ_ZIP_UNDEFINED_ERROR:
+            return "undefined error";
+        case MZ_ZIP_TOO_MANY_FILES:
+            return "too many files";
+        case MZ_ZIP_FILE_TOO_LARGE:
+            return "file too large";
+        case MZ_ZIP_UNSUPPORTED_METHOD:
+            return "unsupported method";
+        case MZ_ZIP_UNSUPPORTED_ENCRYPTION:
+            return "unsupported encryption";
+        case MZ_ZIP_UNSUPPORTED_FEATURE:
+            return "unsupported feature";
+        case MZ_ZIP_FAILED_FINDING_CENTRAL_DIR:
+            return "failed finding central directory";
+        case MZ_ZIP_NOT_AN_ARCHIVE:
+            return "not a ZIP archive";
+        case MZ_ZIP_INVALID_HEADER_OR_CORRUPTED:
+            return "invalid header or archive is corrupted";
+        case MZ_ZIP_UNSUPPORTED_MULTIDISK:
+            return "unsupported multidisk archive";
+        case MZ_ZIP_DECOMPRESSION_FAILED:
+            return "decompression failed or archive is corrupted";
+        case MZ_ZIP_COMPRESSION_FAILED:
+            return "compression failed";
+        case MZ_ZIP_UNEXPECTED_DECOMPRESSED_SIZE:
+            return "unexpected decompressed size";
+        case MZ_ZIP_CRC_CHECK_FAILED:
+            return "CRC-32 check failed";
+        case MZ_ZIP_UNSUPPORTED_CDIR_SIZE:
+            return "unsupported central directory size";
+        case MZ_ZIP_ALLOC_FAILED:
+            return "allocation failed";
+        case MZ_ZIP_FILE_OPEN_FAILED:
+            return "file open failed";
+        case MZ_ZIP_FILE_CREATE_FAILED:
+            return "file create failed";
+        case MZ_ZIP_FILE_WRITE_FAILED:
+            return "file write failed";
+        case MZ_ZIP_FILE_READ_FAILED:
+            return "file read failed";
+        case MZ_ZIP_FILE_CLOSE_FAILED:
+            return "file close failed";
+        case MZ_ZIP_FILE_SEEK_FAILED:
+            return "file seek failed";
+        case MZ_ZIP_FILE_STAT_FAILED:
+            return "file stat failed";
+        case MZ_ZIP_INVALID_PARAMETER:
+            return "invalid parameter";
+        case MZ_ZIP_INVALID_FILENAME:
+            return "invalid filename";
+        case MZ_ZIP_BUF_TOO_SMALL:
+            return "buffer too small";
+        case MZ_ZIP_INTERNAL_ERROR:
+            return "internal error";
+        case MZ_ZIP_FILE_NOT_FOUND:
+            return "file not found";
+        case MZ_ZIP_ARCHIVE_TOO_LARGE:
+            return "archive is too large";
+        case MZ_ZIP_VALIDATION_FAILED:
+            return "validation failed";
+        case MZ_ZIP_WRITE_CALLBACK_FAILED:
+            return "write calledback failed";
+        default:
+            break;
+    }
+
+    return "unknown error";
+}
+
+/* Note: Just because the archive is not zip64 doesn't necessarily mean it doesn't have Zip64 extended information extra field, argh. */
+mz_bool mz_zip_is_zip64(mz_zip_archive *pZip)
+{
+    if ((!pZip) || (!pZip->m_pState))
+        return MZ_FALSE;
+
+    return pZip->m_pState->m_zip64;
+}
+
+size_t mz_zip_get_central_dir_size(mz_zip_archive *pZip)
+{
+    if ((!pZip) || (!pZip->m_pState))
+        return 0;
+
+    return pZip->m_pState->m_central_dir.m_size;
+}
+
+mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip)
+{
+    return pZip ? pZip->m_total_files : 0;
+}
+
+mz_uint64 mz_zip_get_archive_size(mz_zip_archive *pZip)
+{
+    if (!pZip)
+        return 0;
+    return pZip->m_archive_size;
+}
+
+mz_uint64 mz_zip_get_archive_file_start_offset(mz_zip_archive *pZip)
+{
+    if ((!pZip) || (!pZip->m_pState))
+        return 0;
+    return pZip->m_pState->m_file_archive_start_ofs;
+}
+
+MZ_FILE *mz_zip_get_cfile(mz_zip_archive *pZip)
+{
+    if ((!pZip) || (!pZip->m_pState))
+        return 0;
+    return pZip->m_pState->m_pFile;
+}
+
+size_t mz_zip_read_archive_data(mz_zip_archive *pZip, mz_uint64 file_ofs, void *pBuf, size_t n)
+{
+    if ((!pZip) || (!pZip->m_pState) || (!pBuf) || (!pZip->m_pRead))
+        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+
+    return pZip->m_pRead(pZip->m_pIO_opaque, file_ofs, pBuf, n);
+}
+
+mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size)
+{
+    mz_uint n;
+    const mz_uint8 *p = mz_zip_get_cdh(pZip, file_index);
+    if (!p)
+    {
+        if (filename_buf_size)
+            pFilename[0] = '\0';
+        mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
+        return 0;
+    }
+    n = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS);
+    if (filename_buf_size)
+    {
+        n = MZ_MIN(n, filename_buf_size - 1);
+        memcpy(pFilename, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n);
+        pFilename[n] = '\0';
+    }
+    return n + 1;
+}
+
+mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat)
+{
+    return mz_zip_file_stat_internal(pZip, file_index, mz_zip_get_cdh(pZip, file_index), pStat, NULL);
+}
+
+mz_bool mz_zip_end(mz_zip_archive *pZip)
+{
+    if (!pZip)
+        return MZ_FALSE;
+
+    if (pZip->m_zip_mode == MZ_ZIP_MODE_READING)
+        return mz_zip_reader_end(pZip);
+#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS
+    else if ((pZip->m_zip_mode == MZ_ZIP_MODE_WRITING) || (pZip->m_zip_mode == MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED))
+        return mz_zip_writer_end(pZip);
+#endif
+
+    return MZ_FALSE;
+}
+
+#endif /*#ifndef MINIZ_NO_ARCHIVE_APIS*/
diff --git a/xs/src/miniz/miniz_zip.h b/xs/src/miniz/miniz_zip.h
new file mode 100644
index 000000000..71ecb4ae2
--- /dev/null
+++ b/xs/src/miniz/miniz_zip.h
@@ -0,0 +1,429 @@
+
+#pragma once
+#include "miniz.h"
+
+/* ------------------- ZIP archive reading/writing */
+
+#ifndef MINIZ_NO_ARCHIVE_APIS
+
+enum
+{
+    /* Note: These enums can be reduced as needed to save memory or stack space - they are pretty conservative. */
+    MZ_ZIP_MAX_IO_BUF_SIZE = 64 * 1024,
+    MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE = 512,
+    MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE = 512
+};
+
+typedef struct
+{
+    /* Central directory file index. */
+    mz_uint32 m_file_index;
+
+    /* Byte offset of this entry in the archive's central directory. Note we currently only support up to UINT_MAX or less bytes in the central dir. */
+    mz_uint64 m_central_dir_ofs;
+
+    /* These fields are copied directly from the zip's central dir. */
+    mz_uint16 m_version_made_by;
+    mz_uint16 m_version_needed;
+    mz_uint16 m_bit_flag;
+    mz_uint16 m_method;
+
+#ifndef MINIZ_NO_TIME
+    MZ_TIME_T m_time;
+#endif
+
+    /* CRC-32 of uncompressed data. */
+    mz_uint32 m_crc32;
+
+    /* File's compressed size. */
+    mz_uint64 m_comp_size;
+
+    /* File's uncompressed size. Note, I've seen some old archives where directory entries had 512 bytes for their uncompressed sizes, but when you try to unpack them you actually get 0 bytes. */
+    mz_uint64 m_uncomp_size;
+
+    /* Zip internal and external file attributes. */
+    mz_uint16 m_internal_attr;
+    mz_uint32 m_external_attr;
+
+    /* Entry's local header file offset in bytes. */
+    mz_uint64 m_local_header_ofs;
+
+    /* Size of comment in bytes. */
+    mz_uint32 m_comment_size;
+
+    /* MZ_TRUE if the entry appears to be a directory. */
+    mz_bool m_is_directory;
+
+    /* MZ_TRUE if the entry uses encryption/strong encryption (which miniz_zip doesn't support) */
+    mz_bool m_is_encrypted;
+
+    /* MZ_TRUE if the file is not encrypted, a patch file, and if it uses a compression method we support. */
+    mz_bool m_is_supported;
+
+    /* Filename. If string ends in '/' it's a subdirectory entry. */
+    /* Guaranteed to be zero terminated, may be truncated to fit. */
+    char m_filename[MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE];
+
+    /* Comment field. */
+    /* Guaranteed to be zero terminated, may be truncated to fit. */
+    char m_comment[MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE];
+
+} mz_zip_archive_file_stat;
+
+typedef size_t (*mz_file_read_func)(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n);
+typedef size_t (*mz_file_write_func)(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n);
+typedef mz_bool (*mz_file_needs_keepalive)(void *pOpaque);
+
+struct mz_zip_internal_state_tag;
+typedef struct mz_zip_internal_state_tag mz_zip_internal_state;
+
+typedef enum {
+    MZ_ZIP_MODE_INVALID = 0,
+    MZ_ZIP_MODE_READING = 1,
+    MZ_ZIP_MODE_WRITING = 2,
+    MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED = 3
+} mz_zip_mode;
+
+typedef enum {
+    MZ_ZIP_FLAG_CASE_SENSITIVE = 0x0100,
+    MZ_ZIP_FLAG_IGNORE_PATH = 0x0200,
+    MZ_ZIP_FLAG_COMPRESSED_DATA = 0x0400,
+    MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY = 0x0800,
+    MZ_ZIP_FLAG_VALIDATE_LOCATE_FILE_FLAG = 0x1000, /* if enabled, mz_zip_reader_locate_file() will be called on each file as its validated to ensure the func finds the file in the central dir (intended for testing) */
+    MZ_ZIP_FLAG_VALIDATE_HEADERS_ONLY = 0x2000,     /* validate the local headers, but don't decompress the entire file and check the crc32 */
+    MZ_ZIP_FLAG_WRITE_ZIP64 = 0x4000,               /* always use the zip64 file format, instead of the original zip file format with automatic switch to zip64. Use as flags parameter with mz_zip_writer_init*_v2 */
+    MZ_ZIP_FLAG_WRITE_ALLOW_READING = 0x8000,
+    MZ_ZIP_FLAG_ASCII_FILENAME = 0x10000
+} mz_zip_flags;
+
+typedef enum {
+    MZ_ZIP_TYPE_INVALID = 0,
+    MZ_ZIP_TYPE_USER,
+    MZ_ZIP_TYPE_MEMORY,
+    MZ_ZIP_TYPE_HEAP,
+    MZ_ZIP_TYPE_FILE,
+    MZ_ZIP_TYPE_CFILE,
+    MZ_ZIP_TOTAL_TYPES
+} mz_zip_type;
+
+/* miniz error codes. Be sure to update mz_zip_get_error_string() if you add or modify this enum. */
+typedef enum {
+    MZ_ZIP_NO_ERROR = 0,
+    MZ_ZIP_UNDEFINED_ERROR,
+    MZ_ZIP_TOO_MANY_FILES,
+    MZ_ZIP_FILE_TOO_LARGE,
+    MZ_ZIP_UNSUPPORTED_METHOD,
+    MZ_ZIP_UNSUPPORTED_ENCRYPTION,
+    MZ_ZIP_UNSUPPORTED_FEATURE,
+    MZ_ZIP_FAILED_FINDING_CENTRAL_DIR,
+    MZ_ZIP_NOT_AN_ARCHIVE,
+    MZ_ZIP_INVALID_HEADER_OR_CORRUPTED,
+    MZ_ZIP_UNSUPPORTED_MULTIDISK,
+    MZ_ZIP_DECOMPRESSION_FAILED,
+    MZ_ZIP_COMPRESSION_FAILED,
+    MZ_ZIP_UNEXPECTED_DECOMPRESSED_SIZE,
+    MZ_ZIP_CRC_CHECK_FAILED,
+    MZ_ZIP_UNSUPPORTED_CDIR_SIZE,
+    MZ_ZIP_ALLOC_FAILED,
+    MZ_ZIP_FILE_OPEN_FAILED,
+    MZ_ZIP_FILE_CREATE_FAILED,
+    MZ_ZIP_FILE_WRITE_FAILED,
+    MZ_ZIP_FILE_READ_FAILED,
+    MZ_ZIP_FILE_CLOSE_FAILED,
+    MZ_ZIP_FILE_SEEK_FAILED,
+    MZ_ZIP_FILE_STAT_FAILED,
+    MZ_ZIP_INVALID_PARAMETER,
+    MZ_ZIP_INVALID_FILENAME,
+    MZ_ZIP_BUF_TOO_SMALL,
+    MZ_ZIP_INTERNAL_ERROR,
+    MZ_ZIP_FILE_NOT_FOUND,
+    MZ_ZIP_ARCHIVE_TOO_LARGE,
+    MZ_ZIP_VALIDATION_FAILED,
+    MZ_ZIP_WRITE_CALLBACK_FAILED,
+    MZ_ZIP_TOTAL_ERRORS
+} mz_zip_error;
+
+typedef struct
+{
+    mz_uint64 m_archive_size;
+    mz_uint64 m_central_directory_file_ofs;
+
+    /* We only support up to UINT32_MAX files in zip64 mode. */
+    mz_uint32 m_total_files;
+    mz_zip_mode m_zip_mode;
+    mz_zip_type m_zip_type;
+    mz_zip_error m_last_error;
+
+    mz_uint64 m_file_offset_alignment;
+
+    mz_alloc_func m_pAlloc;
+    mz_free_func m_pFree;
+    mz_realloc_func m_pRealloc;
+    void *m_pAlloc_opaque;
+
+    mz_file_read_func m_pRead;
+    mz_file_write_func m_pWrite;
+    mz_file_needs_keepalive m_pNeeds_keepalive;
+    void *m_pIO_opaque;
+
+    mz_zip_internal_state *m_pState;
+
+} mz_zip_archive;
+
+typedef struct
+{
+    mz_zip_archive *pZip;
+    mz_uint flags;
+
+    int status;
+#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
+    mz_uint file_crc32;
+#endif
+    mz_uint64 read_buf_size, read_buf_ofs, read_buf_avail, comp_remaining, out_buf_ofs, cur_file_ofs;
+    mz_zip_archive_file_stat file_stat;
+    void *pRead_buf;
+    void *pWrite_buf;
+
+    size_t out_blk_remain;
+
+    tinfl_decompressor inflator;
+
+} mz_zip_reader_extract_iter_state;
+
+/* -------- ZIP reading */
+
+/* Inits a ZIP archive reader. */
+/* These functions read and validate the archive's central directory. */
+mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, mz_uint flags);
+
+mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint flags);
+
+#ifndef MINIZ_NO_STDIO
+/* Read a archive from a disk file. */
+/* file_start_ofs is the file offset where the archive actually begins, or 0. */
+/* actual_archive_size is the true total size of the archive, which may be smaller than the file's actual size on disk. If zero the entire file is treated as the archive. */
+mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags);
+mz_bool mz_zip_reader_init_file_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint flags, mz_uint64 file_start_ofs, mz_uint64 archive_size);
+
+/* Read an archive from an already opened FILE, beginning at the current file position. */
+/* The archive is assumed to be archive_size bytes long. If archive_size is < 0, then the entire rest of the file is assumed to contain the archive. */
+/* The FILE will NOT be closed when mz_zip_reader_end() is called. */
+mz_bool mz_zip_reader_init_cfile(mz_zip_archive *pZip, MZ_FILE *pFile, mz_uint64 archive_size, mz_uint flags);
+#endif
+
+/* Ends archive reading, freeing all allocations, and closing the input archive file if mz_zip_reader_init_file() was used. */
+mz_bool mz_zip_reader_end(mz_zip_archive *pZip);
+
+/* -------- ZIP reading or writing */
+
+/* Clears a mz_zip_archive struct to all zeros. */
+/* Important: This must be done before passing the struct to any mz_zip functions. */
+void mz_zip_zero_struct(mz_zip_archive *pZip);
+
+mz_zip_mode mz_zip_get_mode(mz_zip_archive *pZip);
+mz_zip_type mz_zip_get_type(mz_zip_archive *pZip);
+
+/* Returns the total number of files in the archive. */
+mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip);
+
+mz_uint64 mz_zip_get_archive_size(mz_zip_archive *pZip);
+mz_uint64 mz_zip_get_archive_file_start_offset(mz_zip_archive *pZip);
+MZ_FILE *mz_zip_get_cfile(mz_zip_archive *pZip);
+
+/* Reads n bytes of raw archive data, starting at file offset file_ofs, to pBuf. */
+size_t mz_zip_read_archive_data(mz_zip_archive *pZip, mz_uint64 file_ofs, void *pBuf, size_t n);
+
+/* Attempts to locates a file in the archive's central directory. */
+/* Valid flags: MZ_ZIP_FLAG_CASE_SENSITIVE, MZ_ZIP_FLAG_IGNORE_PATH */
+/* Returns -1 if the file cannot be found. */
+int mz_zip_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags);
+/* Returns MZ_FALSE if the file cannot be found. */
+mz_bool mz_zip_locate_file_v2(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags, mz_uint32 *pIndex);
+
+/* All mz_zip funcs set the m_last_error field in the mz_zip_archive struct. These functions retrieve/manipulate this field. */
+/* Note that the m_last_error functionality is not thread safe. */
+mz_zip_error mz_zip_set_last_error(mz_zip_archive *pZip, mz_zip_error err_num);
+mz_zip_error mz_zip_peek_last_error(mz_zip_archive *pZip);
+mz_zip_error mz_zip_clear_last_error(mz_zip_archive *pZip);
+mz_zip_error mz_zip_get_last_error(mz_zip_archive *pZip);
+const char *mz_zip_get_error_string(mz_zip_error mz_err);
+
+/* MZ_TRUE if the archive file entry is a directory entry. */
+mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index);
+
+/* MZ_TRUE if the file is encrypted/strong encrypted. */
+mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index);
+
+/* MZ_TRUE if the compression method is supported, and the file is not encrypted, and the file is not a compressed patch file. */
+mz_bool mz_zip_reader_is_file_supported(mz_zip_archive *pZip, mz_uint file_index);
+
+/* Retrieves the filename of an archive file entry. */
+/* Returns the number of bytes written to pFilename, or if filename_buf_size is 0 this function returns the number of bytes needed to fully store the filename. */
+mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size);
+
+/* Attempts to locates a file in the archive's central directory. */
+/* Valid flags: MZ_ZIP_FLAG_CASE_SENSITIVE, MZ_ZIP_FLAG_IGNORE_PATH */
+/* Returns -1 if the file cannot be found. */
+int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags);
+int mz_zip_reader_locate_file_v2(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags, mz_uint32 *file_index);
+
+/* Returns detailed information about an archive file entry. */
+mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat);
+
+/* MZ_TRUE if the file is in zip64 format. */
+/* A file is considered zip64 if it contained a zip64 end of central directory marker, or if it contained any zip64 extended file information fields in the central directory. */
+mz_bool mz_zip_is_zip64(mz_zip_archive *pZip);
+
+/* Returns the total central directory size in bytes. */
+/* The current max supported size is <= MZ_UINT32_MAX. */
+size_t mz_zip_get_central_dir_size(mz_zip_archive *pZip);
+
+/* Extracts a archive file to a memory buffer using no memory allocation. */
+/* There must be at least enough room on the stack to store the inflator's state (~34KB or so). */
+mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size);
+mz_bool mz_zip_reader_extract_file_to_mem_no_alloc(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size);
+
+/* Extracts a archive file to a memory buffer. */
+mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags);
+mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags);
+
+/* Extracts a archive file to a dynamically allocated heap buffer. */
+/* The memory will be allocated via the mz_zip_archive's alloc/realloc functions. */
+/* Returns NULL and sets the last error on failure. */
+void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, size_t *pSize, mz_uint flags);
+void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFilename, size_t *pSize, mz_uint flags);
+
+/* Extracts a archive file using a callback function to output the file's data. */
+mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_index, mz_file_write_func pCallback, void *pOpaque, mz_uint flags);
+mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip, const char *pFilename, mz_file_write_func pCallback, void *pOpaque, mz_uint flags);
+
+/* Extract a file iteratively */
+mz_zip_reader_extract_iter_state* mz_zip_reader_extract_iter_new(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags);
+mz_zip_reader_extract_iter_state* mz_zip_reader_extract_file_iter_new(mz_zip_archive *pZip, const char *pFilename, mz_uint flags);
+size_t mz_zip_reader_extract_iter_read(mz_zip_reader_extract_iter_state* pState, void* pvBuf, size_t buf_size);
+mz_bool mz_zip_reader_extract_iter_free(mz_zip_reader_extract_iter_state* pState);
+
+#ifndef MINIZ_NO_STDIO
+/* Extracts a archive file to a disk file and sets its last accessed and modified times. */
+/* This function only extracts files, not archive directory records. */
+mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, mz_uint flags);
+mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, const char *pArchive_filename, const char *pDst_filename, mz_uint flags);
+
+/* Extracts a archive file starting at the current position in the destination FILE stream. */
+mz_bool mz_zip_reader_extract_to_cfile(mz_zip_archive *pZip, mz_uint file_index, MZ_FILE *File, mz_uint flags);
+mz_bool mz_zip_reader_extract_file_to_cfile(mz_zip_archive *pZip, const char *pArchive_filename, MZ_FILE *pFile, mz_uint flags);
+#endif
+
+#if 0
+/* TODO */
+	typedef void *mz_zip_streaming_extract_state_ptr;
+	mz_zip_streaming_extract_state_ptr mz_zip_streaming_extract_begin(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags);
+	uint64_t mz_zip_streaming_extract_get_size(mz_zip_archive *pZip, mz_zip_streaming_extract_state_ptr pState);
+	uint64_t mz_zip_streaming_extract_get_cur_ofs(mz_zip_archive *pZip, mz_zip_streaming_extract_state_ptr pState);
+	mz_bool mz_zip_streaming_extract_seek(mz_zip_archive *pZip, mz_zip_streaming_extract_state_ptr pState, uint64_t new_ofs);
+	size_t mz_zip_streaming_extract_read(mz_zip_archive *pZip, mz_zip_streaming_extract_state_ptr pState, void *pBuf, size_t buf_size);
+	mz_bool mz_zip_streaming_extract_end(mz_zip_archive *pZip, mz_zip_streaming_extract_state_ptr pState);
+#endif
+
+/* This function compares the archive's local headers, the optional local zip64 extended information block, and the optional descriptor following the compressed data vs. the data in the central directory. */
+/* It also validates that each file can be successfully uncompressed unless the MZ_ZIP_FLAG_VALIDATE_HEADERS_ONLY is specified. */
+mz_bool mz_zip_validate_file(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags);
+
+/* Validates an entire archive by calling mz_zip_validate_file() on each file. */
+mz_bool mz_zip_validate_archive(mz_zip_archive *pZip, mz_uint flags);
+
+/* Misc utils/helpers, valid for ZIP reading or writing */
+mz_bool mz_zip_validate_mem_archive(const void *pMem, size_t size, mz_uint flags, mz_zip_error *pErr);
+mz_bool mz_zip_validate_file_archive(const char *pFilename, mz_uint flags, mz_zip_error *pErr);
+
+/* Universal end function - calls either mz_zip_reader_end() or mz_zip_writer_end(). */
+mz_bool mz_zip_end(mz_zip_archive *pZip);
+
+/* -------- ZIP writing */
+
+#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS
+
+/* Inits a ZIP archive writer. */
+/*Set pZip->m_pWrite (and pZip->m_pIO_opaque) before calling mz_zip_writer_init or mz_zip_writer_init_v2*/
+/*The output is streamable, i.e. file_ofs in mz_file_write_func always increases only by n*/
+mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size);
+mz_bool mz_zip_writer_init_v2(mz_zip_archive *pZip, mz_uint64 existing_size, mz_uint flags);
+
+mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size);
+mz_bool mz_zip_writer_init_heap_v2(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size, mz_uint flags);
+
+#ifndef MINIZ_NO_STDIO
+mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning);
+mz_bool mz_zip_writer_init_file_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning, mz_uint flags);
+mz_bool mz_zip_writer_init_cfile(mz_zip_archive *pZip, MZ_FILE *pFile, mz_uint flags);
+#endif
+
+/* Converts a ZIP archive reader object into a writer object, to allow efficient in-place file appends to occur on an existing archive. */
+/* For archives opened using mz_zip_reader_init_file, pFilename must be the archive's filename so it can be reopened for writing. If the file can't be reopened, mz_zip_reader_end() will be called. */
+/* For archives opened using mz_zip_reader_init_mem, the memory block must be growable using the realloc callback (which defaults to realloc unless you've overridden it). */
+/* Finally, for archives opened using mz_zip_reader_init, the mz_zip_archive's user provided m_pWrite function cannot be NULL. */
+/* Note: In-place archive modification is not recommended unless you know what you're doing, because if execution stops or something goes wrong before */
+/* the archive is finalized the file's central directory will be hosed. */
+mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilename);
+mz_bool mz_zip_writer_init_from_reader_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint flags);
+
+/* Adds the contents of a memory buffer to an archive. These functions record the current local time into the archive. */
+/* To add a directory entry, call this method with an archive name ending in a forwardslash with an empty buffer. */
+/* level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. */
+mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, mz_uint level_and_flags);
+
+/* Like mz_zip_writer_add_mem(), except you can specify a file comment field, and optionally supply the function with already compressed data. */
+/* uncomp_size/uncomp_crc32 are only used if the MZ_ZIP_FLAG_COMPRESSED_DATA flag is specified. */
+mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags,
+                                 mz_uint64 uncomp_size, mz_uint32 uncomp_crc32);
+
+mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags,
+                                    mz_uint64 uncomp_size, mz_uint32 uncomp_crc32, MZ_TIME_T *last_modified, const char *user_extra_data_local, mz_uint user_extra_data_local_len,
+                                    const char *user_extra_data_central, mz_uint user_extra_data_central_len);
+
+#ifndef MINIZ_NO_STDIO
+/* Adds the contents of a disk file to an archive. This function also records the disk file's modified time into the archive. */
+/* level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. */
+mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, const char *pSrc_filename, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags);
+
+/* Like mz_zip_writer_add_file(), except the file data is read from the specified FILE stream. */
+mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name, MZ_FILE *pSrc_file, mz_uint64 size_to_add,
+                                const MZ_TIME_T *pFile_time, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, const char *user_extra_data_local, mz_uint user_extra_data_local_len,
+                                const char *user_extra_data_central, mz_uint user_extra_data_central_len);
+#endif
+
+/* Adds a file to an archive by fully cloning the data from another archive. */
+/* This function fully clones the source file's compressed data (no recompression), along with its full filename, extra data (it may add or modify the zip64 local header extra data field), and the optional descriptor following the compressed data. */
+mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint src_file_index);
+
+/* Finalizes the archive by writing the central directory records followed by the end of central directory record. */
+/* After an archive is finalized, the only valid call on the mz_zip_archive struct is mz_zip_writer_end(). */
+/* An archive must be manually finalized by calling this function for it to be valid. */
+mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip);
+
+/* Finalizes a heap archive, returning a poiner to the heap block and its size. */
+/* The heap block will be allocated using the mz_zip_archive's alloc/realloc callbacks. */
+mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **ppBuf, size_t *pSize);
+
+/* Ends archive writing, freeing all allocations, and closing the output file if mz_zip_writer_init_file() was used. */
+/* Note for the archive to be valid, it *must* have been finalized before ending (this function will not do it for you). */
+mz_bool mz_zip_writer_end(mz_zip_archive *pZip);
+
+/* -------- Misc. high-level helper functions: */
+
+/* mz_zip_add_mem_to_archive_file_in_place() efficiently (but not atomically) appends a memory blob to a ZIP archive. */
+/* Note this is NOT a fully safe operation. If it crashes or dies in some way your archive can be left in a screwed up state (without a central directory). */
+/* level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. */
+/* TODO: Perhaps add an option to leave the existing central dir in place in case the add dies? We could then truncate the file (so the old central dir would be at the end) if something goes wrong. */
+mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags);
+mz_bool mz_zip_add_mem_to_archive_file_in_place_v2(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, mz_zip_error *pErr);
+
+/* Reads a single file from an archive into a heap block. */
+/* If pComment is not NULL, only the file with the specified comment will be extracted. */
+/* Returns NULL on failure. */
+void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint flags);
+void *mz_zip_extract_archive_file_to_heap_v2(const char *pZip_filename, const char *pArchive_name, const char *pComment, size_t *pSize, mz_uint flags, mz_zip_error *pErr);
+
+#endif /* #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS */
+
+#endif /* MINIZ_NO_ARCHIVE_APIS */
diff --git a/xs/src/perlglue.cpp b/xs/src/perlglue.cpp
index 948fcfd93..cb2ef7368 100644
--- a/xs/src/perlglue.cpp
+++ b/xs/src/perlglue.cpp
@@ -15,6 +15,7 @@ REGISTER_CLASS(Filler, "Filler");
 REGISTER_CLASS(Flow, "Flow");
 REGISTER_CLASS(CoolingBuffer, "GCode::CoolingBuffer");
 REGISTER_CLASS(GCode, "GCode");
+REGISTER_CLASS(GCodePreviewData, "GCode::PreviewData");
 REGISTER_CLASS(GCodeSender, "GCode::Sender");
 REGISTER_CLASS(Layer, "Layer");
 REGISTER_CLASS(SupportLayer, "Layer::Support");
@@ -62,6 +63,7 @@ REGISTER_CLASS(Preset, "GUI::Preset");
 REGISTER_CLASS(PresetCollection, "GUI::PresetCollection");
 REGISTER_CLASS(PresetBundle, "GUI::PresetBundle");
 REGISTER_CLASS(PresetHints, "GUI::PresetHints");
+REGISTER_CLASS(TabIface, "GUI::Tab");
 
 SV* ConfigBase__as_hash(ConfigBase* THIS)
 {
diff --git a/xs/src/slic3r/GUI/2DBed.cpp b/xs/src/slic3r/GUI/2DBed.cpp
new file mode 100644
index 000000000..c5d68400d
--- /dev/null
+++ b/xs/src/slic3r/GUI/2DBed.cpp
@@ -0,0 +1,189 @@
+#include "2DBed.hpp";
+
+#include <wx/dcbuffer.h>
+#include "BoundingBox.hpp"
+#include "Geometry.hpp"
+#include "ClipperUtils.hpp"
+
+namespace Slic3r {
+namespace GUI {
+
+void Bed_2D::repaint()
+{
+	wxAutoBufferedPaintDC dc(this);
+	auto cw = GetSize().GetWidth();
+	auto ch = GetSize().GetHeight();
+	// when canvas is not rendered yet, size is 0, 0
+	if (cw == 0) return ; 
+
+	if (m_user_drawn_background) {
+		// On all systems the AutoBufferedPaintDC() achieves double buffering.
+		// On MacOS the background is erased, on Windows the background is not erased
+		// and on Linux / GTK the background is erased to gray color.
+		// Fill DC with the background on Windows & Linux / GTK.
+		auto color = wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT); //GetSystemColour
+		dc.SetPen(*new wxPen(color, 1, wxPENSTYLE_SOLID));
+		dc.SetBrush(*new wxBrush(color, wxBRUSHSTYLE_SOLID));
+		auto rect = GetUpdateRegion().GetBox();
+		dc.DrawRectangle(rect.GetLeft(), rect.GetTop(), rect.GetWidth(), rect.GetHeight());
+	}
+
+	// turn cw and ch from sizes to max coordinates
+	cw--;
+	ch--;
+
+	auto cbb = BoundingBoxf(Pointf(0, 0),Pointf(cw, ch));
+	// leave space for origin point
+	cbb.min.translate(4, 0);
+	cbb.max.translate(-4, -4);
+
+	// leave space for origin label
+	cbb.max.translate(0, -13);
+
+	// read new size
+	cw = cbb.size().x;
+	ch = cbb.size().y;
+
+	auto ccenter = cbb.center();
+
+	// get bounding box of bed shape in G - code coordinates
+	auto bed_shape = m_bed_shape;
+	auto bed_polygon = Polygon::new_scale(m_bed_shape);
+	auto bb = BoundingBoxf(m_bed_shape);
+	bb.merge(Pointf(0, 0));  // origin needs to be in the visible area
+	auto bw = bb.size().x;
+	auto bh = bb.size().y;
+	auto bcenter = bb.center();
+
+	// calculate the scaling factor for fitting bed shape in canvas area
+	auto sfactor = std::min(cw/bw, ch/bh);
+	auto shift = Pointf(
+		ccenter.x - bcenter.x * sfactor,
+		ccenter.y - bcenter.y * sfactor
+		);
+	m_scale_factor = sfactor;
+	m_shift = Pointf(shift.x + cbb.min.x,
+					shift.y - (cbb.max.y - GetSize().GetHeight()));
+
+	// draw bed fill
+	dc.SetBrush(*new wxBrush(*new wxColour(255, 255, 255), wxSOLID));
+	wxPointList pt_list;
+	for (auto pt: m_bed_shape)
+	{
+		Point pt_pix = to_pixels(pt);
+		pt_list.push_back(new wxPoint(pt_pix.x, pt_pix.y));
+	}
+	dc.DrawPolygon(&pt_list, 0, 0);
+
+	// draw grid
+	auto step = 10;  // 1cm grid
+	Polylines polylines;
+	for (auto x = bb.min.x - fmod(bb.min.x, step) + step; x < bb.max.x; x += step) {
+		Polyline pl = Polyline::new_scale({ Pointf(x, bb.min.y), Pointf(x, bb.max.y) });
+		polylines.push_back(pl);
+	}
+	for (auto y = bb.min.y - fmod(bb.min.y, step) + step; y < bb.max.y; y += step) {
+		polylines.push_back(Polyline::new_scale({ Pointf(bb.min.x, y), Pointf(bb.max.x, y) }));
+	}
+	polylines = intersection_pl(polylines, bed_polygon);
+
+	dc.SetPen(*new wxPen(*new wxColour(230, 230, 230), 1, wxSOLID));
+	for (auto pl : polylines)
+	{
+		for (size_t i = 0; i < pl.points.size()-1; i++){
+			Point pt1 = to_pixels(Pointf::new_unscale(pl.points[i]));
+			Point pt2 = to_pixels(Pointf::new_unscale(pl.points[i+1]));
+			dc.DrawLine(pt1.x, pt1.y, pt2.x, pt2.y);
+		}
+	}
+
+	// draw bed contour
+	dc.SetPen(*new wxPen(*new wxColour(0, 0, 0), 1, wxSOLID));
+	dc.SetBrush(*new wxBrush(*new wxColour(0, 0, 0), wxTRANSPARENT));
+	dc.DrawPolygon(&pt_list, 0, 0);
+
+	auto origin_px = to_pixels(Pointf(0, 0));
+
+	// draw axes
+	auto axes_len = 50;
+	auto arrow_len = 6;
+	auto arrow_angle = Geometry::deg2rad(45.0);
+	dc.SetPen(*new wxPen(*new wxColour(255, 0, 0), 2, wxSOLID));  // red
+	auto x_end = Pointf(origin_px.x + axes_len, origin_px.y);
+	dc.DrawLine(wxPoint(origin_px.x, origin_px.y), wxPoint(x_end.x, x_end.y));
+	for (auto angle : { -arrow_angle, arrow_angle }){
+		auto end = x_end;
+		end.translate(-arrow_len, 0);
+		end.rotate(angle, x_end);
+		dc.DrawLine(wxPoint(x_end.x, x_end.y), wxPoint(end.x, end.y));
+	}
+
+	dc.SetPen(*new wxPen(*new wxColour(0, 255, 0), 2, wxSOLID));  // green
+	auto y_end = Pointf(origin_px.x, origin_px.y - axes_len);
+	dc.DrawLine(wxPoint(origin_px.x, origin_px.y), wxPoint(y_end.x, y_end.y));
+	for (auto angle : { -arrow_angle, arrow_angle }) {
+		auto end = y_end;
+		end.translate(0, +arrow_len);
+		end.rotate(angle, y_end);
+		dc.DrawLine(wxPoint(y_end.x, y_end.y), wxPoint(end.x, end.y));
+	}
+
+	// draw origin
+	dc.SetPen(*new wxPen(*new wxColour(0, 0, 0), 1, wxSOLID));
+	dc.SetBrush(*new wxBrush(*new wxColour(0, 0, 0), wxSOLID));
+	dc.DrawCircle(origin_px.x, origin_px.y, 3);
+
+	dc.SetTextForeground(*new wxColour(0, 0, 0));
+	dc.SetFont(*new wxFont(10, wxDEFAULT, wxNORMAL, wxNORMAL));
+	dc.DrawText("(0,0)", origin_px.x + 1, origin_px.y + 2);
+
+	// draw current position
+	if (m_pos!= Pointf(0, 0)) {
+		auto pos_px = to_pixels(m_pos);
+		dc.SetPen(*new wxPen(*new wxColour(200, 0, 0), 2, wxSOLID));
+		dc.SetBrush(*new wxBrush(*new wxColour(200, 0, 0), wxTRANSPARENT));
+		dc.DrawCircle(pos_px.x, pos_px.y, 5);
+
+		dc.DrawLine(pos_px.x - 15, pos_px.y, pos_px.x + 15, pos_px.y);
+		dc.DrawLine(pos_px.x, pos_px.y - 15, pos_px.x, pos_px.y + 15);
+	}
+
+	m_painted = true;
+}
+
+// convert G - code coordinates into pixels
+Point Bed_2D::to_pixels(Pointf point){
+	auto p = Pointf(point);
+	p.scale(m_scale_factor);
+	p.translate(m_shift);
+	return Point(p.x, GetSize().GetHeight() - p.y); 
+}
+
+void Bed_2D::mouse_event(wxMouseEvent event){
+	if (!m_interactive) return;
+	if (!m_painted) return;
+
+	auto pos = event.GetPosition();
+	auto point = to_units(Point(pos.x, pos.y));  
+	if (event.LeftDown() || event.Dragging()) {
+		if (m_on_move)
+			m_on_move(point) ;
+		Refresh();
+	}
+}
+
+// convert pixels into G - code coordinates
+Pointf Bed_2D::to_units(Point point){
+	auto p = Pointf(point.x, GetSize().GetHeight() - point.y);
+	p.translate(m_shift.negative());
+	p.scale(1 / m_scale_factor);
+	return p;
+}
+
+void Bed_2D::set_pos(Pointf pos){
+	m_pos = pos;
+	Refresh();
+}
+
+} // GUI
+} // Slic3r
\ No newline at end of file
diff --git a/xs/src/slic3r/GUI/2DBed.hpp b/xs/src/slic3r/GUI/2DBed.hpp
new file mode 100644
index 000000000..859417efb
--- /dev/null
+++ b/xs/src/slic3r/GUI/2DBed.hpp
@@ -0,0 +1,45 @@
+#include <wx/wx.h>
+#include "Config.hpp"
+
+namespace Slic3r {
+namespace GUI {
+
+class Bed_2D : public wxPanel
+{
+	bool		m_user_drawn_background = false;
+
+	bool		m_painted = false;
+	bool		m_interactive = false;
+	double		m_scale_factor;
+	Pointf		m_shift;
+	Pointf		m_pos;
+	std::function<void(Pointf)>	m_on_move = nullptr;
+
+	Point		to_pixels(Pointf point);
+	Pointf		to_units(Point point);
+	void		repaint();
+	void		mouse_event(wxMouseEvent event);
+	void		set_pos(Pointf pos);
+
+public:
+	Bed_2D(wxWindow* parent) 
+	{
+		Create(parent, wxID_ANY, wxDefaultPosition, wxSize(250, -1), wxTAB_TRAVERSAL);
+//		m_user_drawn_background = $^O ne 'darwin';
+		m_user_drawn_background = true;
+		Bind(wxEVT_PAINT, ([this](wxPaintEvent e) { repaint(); }));
+//		EVT_ERASE_BACKGROUND($self, sub{}) if $self->{user_drawn_background};
+//		Bind(EVT_MOUSE_EVENTS, ([this](wxMouseEvent  event){/*mouse_event()*/; }));
+		Bind(wxEVT_LEFT_DOWN, ([this](wxMouseEvent  event){ mouse_event(event); }));
+		Bind(wxEVT_MOTION, ([this](wxMouseEvent  event){ mouse_event(event); }));
+		Bind(wxEVT_SIZE, ([this](wxSizeEvent e) { Refresh(); }));
+	}
+	~Bed_2D(){}
+
+	std::vector<Pointf>		m_bed_shape;
+		
+};
+
+
+} // GUI
+} // Slic3r
diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp
index 83432446a..cfc0947fe 100644
--- a/xs/src/slic3r/GUI/3DScene.cpp
+++ b/xs/src/slic3r/GUI/3DScene.cpp
@@ -6,8 +6,10 @@
 #include "../../libslic3r/ExtrusionEntity.hpp"
 #include "../../libslic3r/ExtrusionEntityCollection.hpp"
 #include "../../libslic3r/Geometry.hpp"
+#include "../../libslic3r/GCode/PreviewData.hpp"
 #include "../../libslic3r/Print.hpp"
 #include "../../libslic3r/Slicing.hpp"
+#include "GCode/Analyzer.hpp"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -20,6 +22,11 @@
 #include <tbb/parallel_for.h>
 #include <tbb/spin_mutex.h>
 
+#include <wx/bitmap.h>
+#include <wx/dcmemory.h>
+#include <wx/image.h>
+#include <wx/settings.h>
+
 namespace Slic3r {
 
 void GLIndexedVertexArray::load_mesh_flat_shading(const TriangleMesh &mesh)
@@ -201,6 +208,9 @@ void GLVolume::set_range(double min_z, double max_z)
 
 void GLVolume::render() const
 {
+    if (!is_active)
+        return;
+
     glCullFace(GL_BACK);
     glPushMatrix();
     glTranslated(this->origin.x, this->origin.y, this->origin.z);
@@ -335,12 +345,40 @@ void GLVolumeCollection::render_VBOs() const
     GLint color_id = (current_program_id > 0) ? glGetUniformLocation(current_program_id, "uniform_color") : -1;
 
     for (GLVolume *volume : this->volumes) {
-        if (! volume->indexed_vertex_array.vertices_and_normals_interleaved_VBO_id)
+        if (!volume->is_active)
+            continue;
+
+        if (!volume->indexed_vertex_array.vertices_and_normals_interleaved_VBO_id)
             continue;
         GLsizei n_triangles = GLsizei(std::min(volume->indexed_vertex_array.triangle_indices_size, volume->tverts_range.second - volume->tverts_range.first));
         GLsizei n_quads     = GLsizei(std::min(volume->indexed_vertex_array.quad_indices_size,     volume->qverts_range.second - volume->qverts_range.first));
         if (n_triangles + n_quads == 0)
+        {
+            if (_render_interleaved_only_volumes.enabled)
+            {
+                ::glDisableClientState(GL_VERTEX_ARRAY);
+                ::glDisableClientState(GL_NORMAL_ARRAY);
+                ::glEnable(GL_BLEND);
+                ::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+                if (color_id >= 0)
+                {
+                    float color[4];
+                    ::memcpy((void*)color, (const void*)volume->color, 3 * sizeof(float));
+                    color[3] = _render_interleaved_only_volumes.alpha;
+                    ::glUniform4fv(color_id, 1, (const GLfloat*)color);
+                }
+                else
+                    ::glColor4f(volume->color[0], volume->color[1], volume->color[2], _render_interleaved_only_volumes.alpha);
+
+                volume->render();
+
+                ::glDisable(GL_BLEND);
+                ::glEnableClientState(GL_VERTEX_ARRAY);
+                ::glEnableClientState(GL_NORMAL_ARRAY);
+            }
             continue;
+        }
         if (color_id >= 0)
             glUniform4fv(color_id, 1, (const GLfloat*)volume->color);
         else
@@ -373,10 +411,29 @@ void GLVolumeCollection::render_legacy() const
  
     for (GLVolume *volume : this->volumes) {
         assert(! volume->indexed_vertex_array.vertices_and_normals_interleaved_VBO_id);
+        if (!volume->is_active)
+            continue;
+
         GLsizei n_triangles = GLsizei(std::min(volume->indexed_vertex_array.triangle_indices_size, volume->tverts_range.second - volume->tverts_range.first));
         GLsizei n_quads     = GLsizei(std::min(volume->indexed_vertex_array.quad_indices_size,     volume->qverts_range.second - volume->qverts_range.first));
         if (n_triangles + n_quads == 0)
+        {
+            if (_render_interleaved_only_volumes.enabled)
+            {
+                ::glDisableClientState(GL_VERTEX_ARRAY);
+                ::glDisableClientState(GL_NORMAL_ARRAY);
+                ::glEnable(GL_BLEND);
+                ::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+                ::glColor4f(volume->color[0], volume->color[1], volume->color[2], _render_interleaved_only_volumes.alpha);
+                volume->render();
+
+                ::glDisable(GL_BLEND);
+                ::glEnableClientState(GL_VERTEX_ARRAY);
+                ::glEnableClientState(GL_NORMAL_ARRAY);
+            }
             continue;
+        }
         glColor4f(volume->color[0], volume->color[1], volume->color[2], volume->color[3]);
         glVertexPointer(3, GL_FLOAT, 6 * sizeof(float), volume->indexed_vertex_array.vertices_and_normals_interleaved.data() + 3);
         glNormalPointer(GL_FLOAT, 6 * sizeof(float), volume->indexed_vertex_array.vertices_and_normals_interleaved.data());
@@ -609,6 +666,321 @@ static void thick_lines_to_indexed_vertex_array(
 #undef BOTTOM
 }
 
+// caller is responsible for supplying NO lines with zero length
+static void thick_lines_to_indexed_vertex_array(const Lines3& lines,
+    const std::vector<double>& widths,
+    const std::vector<double>& heights,
+    bool closed,
+    GLIndexedVertexArray& volume)
+{
+    assert(!lines.empty());
+    if (lines.empty())
+        return;
+
+#define LEFT    0
+#define RIGHT   1
+#define TOP     2
+#define BOTTOM  3
+
+    // left, right, top, bottom
+    int      idx_initial[4] = { -1, -1, -1, -1 };
+    int      idx_prev[4] = { -1, -1, -1, -1 };
+    double   z_prev = 0.0;
+    Vectorf3 n_right_prev;
+    Vectorf3 n_top_prev;
+    Vectorf3 unit_v_prev;
+    double   width_initial = 0.0;
+
+    // new vertices around the line endpoints
+    // left, right, top, bottom
+    Pointf3 a[4];
+    Pointf3 b[4];
+
+    // loop once more in case of closed loops
+    size_t lines_end = closed ? (lines.size() + 1) : lines.size();
+    for (size_t ii = 0; ii < lines_end; ++ii)
+    {
+        size_t i = (ii == lines.size()) ? 0 : ii;
+
+        const Line3& line = lines[i];
+        double height = heights[i];
+        double width = widths[i];
+
+        Vectorf3 unit_v = normalize(Vectorf3::new_unscale(line.vector()));
+
+        Vectorf3 n_top;
+        Vectorf3 n_right;
+        Vectorf3 unit_positive_z(0.0, 0.0, 1.0);
+
+        if ((line.a.x == line.b.x) && (line.a.y == line.b.y))
+        {
+            // vertical segment
+            n_right = (line.a.z < line.b.z) ? Vectorf3(-1.0, 0.0, 0.0) : Vectorf3(1.0, 0.0, 0.0);
+            n_top = Vectorf3(0.0, 1.0, 0.0);
+        }
+        else
+        {
+            // generic segment
+            n_right = normalize(cross(unit_v, unit_positive_z));
+            n_top = normalize(cross(n_right, unit_v));
+        }
+
+        Vectorf3 rl_displacement = 0.5 * width * n_right;
+        Vectorf3 tb_displacement = 0.5 * height * n_top;
+        Pointf3 l_a = Pointf3::new_unscale(line.a);
+        Pointf3 l_b = Pointf3::new_unscale(line.b);
+
+        a[RIGHT] = l_a + rl_displacement;
+        a[LEFT] = l_a - rl_displacement;
+        a[TOP] = l_a + tb_displacement;
+        a[BOTTOM] = l_a - tb_displacement;
+        b[RIGHT] = l_b + rl_displacement;
+        b[LEFT] = l_b - rl_displacement;
+        b[TOP] = l_b + tb_displacement;
+        b[BOTTOM] = l_b - tb_displacement;
+
+        Vectorf3 n_bottom = -n_top;
+        Vectorf3 n_left = -n_right;
+
+        int idx_a[4];
+        int idx_b[4];
+        int idx_last = int(volume.vertices_and_normals_interleaved.size() / 6);
+
+        bool z_different = (z_prev != l_a.z);
+        z_prev = l_b.z;
+
+        // Share top / bottom vertices if possible.
+        if (ii == 0)
+        {
+            idx_a[TOP] = idx_last++;
+            volume.push_geometry(a[TOP], n_top);
+        }
+        else
+            idx_a[TOP] = idx_prev[TOP];
+
+        if ((ii == 0) || z_different)
+        {
+            // Start of the 1st line segment or a change of the layer thickness while maintaining the print_z.
+            idx_a[BOTTOM] = idx_last++;
+            volume.push_geometry(a[BOTTOM], n_bottom);
+            idx_a[LEFT] = idx_last++;
+            volume.push_geometry(a[LEFT], n_left);
+            idx_a[RIGHT] = idx_last++;
+            volume.push_geometry(a[RIGHT], n_right);
+        }
+        else
+            idx_a[BOTTOM] = idx_prev[BOTTOM];
+
+        if (ii == 0)
+        {
+            // Start of the 1st line segment.
+            width_initial = width;
+            ::memcpy(idx_initial, idx_a, sizeof(int) * 4);
+        }
+        else
+        {
+            // Continuing a previous segment.
+            // Share left / right vertices if possible.
+            double v_dot = dot(unit_v_prev, unit_v);
+            bool is_sharp = v_dot < 0.707; // sin(45 degrees)
+            bool is_right_turn = dot(n_top_prev, cross(unit_v_prev, unit_v)) > 0.0;
+
+            if (is_sharp)
+            {
+                // Allocate new left / right points for the start of this segment as these points will receive their own normals to indicate a sharp turn.
+                idx_a[RIGHT] = idx_last++;
+                volume.push_geometry(a[RIGHT], n_right);
+                idx_a[LEFT] = idx_last++;
+                volume.push_geometry(a[LEFT], n_left);
+            }
+
+            if (v_dot > 0.9)
+            {
+                // The two successive segments are nearly collinear.
+                idx_a[LEFT] = idx_prev[LEFT];
+                idx_a[RIGHT] = idx_prev[RIGHT];
+            }
+            else if (!is_sharp)
+            {
+                // Create a sharp corner with an overshot and average the left / right normals.
+                // At the crease angle of 45 degrees, the overshot at the corner will be less than (1-1/cos(PI/8)) = 8.2% over an arc.
+
+                // averages normals
+                Vectorf3 average_n_right = normalize(0.5 * (n_right + n_right_prev));
+                Vectorf3 average_n_left = -average_n_right;
+                Vectorf3 average_rl_displacement = 0.5 * width * average_n_right;
+
+                // updates vertices around a
+                a[RIGHT] = l_a + average_rl_displacement;
+                a[LEFT] = l_a - average_rl_displacement;
+
+                // updates previous line normals
+                float* normal_left_prev = volume.vertices_and_normals_interleaved.data() + idx_prev[LEFT] * 6;
+                normal_left_prev[0] = float(average_n_left.x);
+                normal_left_prev[1] = float(average_n_left.y);
+                normal_left_prev[2] = float(average_n_left.z);
+
+                float* normal_right_prev = volume.vertices_and_normals_interleaved.data() + idx_prev[RIGHT] * 6;
+                normal_right_prev[0] = float(average_n_right.x);
+                normal_right_prev[1] = float(average_n_right.y);
+                normal_right_prev[2] = float(average_n_right.z);
+
+                // updates previous line's vertices around b
+                float* b_left_prev = normal_left_prev + 3;
+                b_left_prev[0] = float(a[LEFT].x);
+                b_left_prev[1] = float(a[LEFT].y);
+                b_left_prev[2] = float(a[LEFT].z);
+
+                float* b_right_prev = normal_right_prev + 3;
+                b_right_prev[0] = float(a[RIGHT].x);
+                b_right_prev[1] = float(a[RIGHT].y);
+                b_right_prev[2] = float(a[RIGHT].z);
+
+                idx_a[LEFT] = idx_prev[LEFT];
+                idx_a[RIGHT] = idx_prev[RIGHT];
+            }
+            else if (is_right_turn)
+            {
+                // Right turn. Fill in the right turn wedge.
+                volume.push_triangle(idx_prev[RIGHT], idx_a[RIGHT], idx_prev[TOP]);
+                volume.push_triangle(idx_prev[RIGHT], idx_prev[BOTTOM], idx_a[RIGHT]);
+            }
+            else
+            {
+                // Left turn. Fill in the left turn wedge.
+                volume.push_triangle(idx_prev[LEFT], idx_prev[TOP], idx_a[LEFT]);
+                volume.push_triangle(idx_prev[LEFT], idx_a[LEFT], idx_prev[BOTTOM]);
+            }
+
+            if (ii == lines.size())
+            {
+                if (!is_sharp)
+                {
+                    // Closing a loop with smooth transition. Unify the closing left / right vertices.
+                    ::memcpy(volume.vertices_and_normals_interleaved.data() + idx_initial[LEFT] * 6, volume.vertices_and_normals_interleaved.data() + idx_prev[LEFT] * 6, sizeof(float) * 6);
+                    ::memcpy(volume.vertices_and_normals_interleaved.data() + idx_initial[RIGHT] * 6, volume.vertices_and_normals_interleaved.data() + idx_prev[RIGHT] * 6, sizeof(float) * 6);
+                    volume.vertices_and_normals_interleaved.erase(volume.vertices_and_normals_interleaved.end() - 12, volume.vertices_and_normals_interleaved.end());
+                    // Replace the left / right vertex indices to point to the start of the loop. 
+                    for (size_t u = volume.quad_indices.size() - 16; u < volume.quad_indices.size(); ++u)
+                    {
+                        if (volume.quad_indices[u] == idx_prev[LEFT])
+                            volume.quad_indices[u] = idx_initial[LEFT];
+                        else if (volume.quad_indices[u] == idx_prev[RIGHT])
+                            volume.quad_indices[u] = idx_initial[RIGHT];
+                    }
+                }
+
+                // This is the last iteration, only required to solve the transition.
+                break;
+            }
+        }
+
+        // Only new allocate top / bottom vertices, if not closing a loop.
+        if (closed && (ii + 1 == lines.size()))
+            idx_b[TOP] = idx_initial[TOP];
+        else
+        {
+            idx_b[TOP] = idx_last++;
+            volume.push_geometry(b[TOP], n_top);
+        }
+
+        if (closed && (ii + 1 == lines.size()) && (width == width_initial))
+            idx_b[BOTTOM] = idx_initial[BOTTOM];
+        else
+        {
+            idx_b[BOTTOM] = idx_last++;
+            volume.push_geometry(b[BOTTOM], n_bottom);
+        }
+
+        // Generate new vertices for the end of this line segment.
+        idx_b[LEFT] = idx_last++;
+        volume.push_geometry(b[LEFT], n_left);
+        idx_b[RIGHT] = idx_last++;
+        volume.push_geometry(b[RIGHT], n_right);
+
+        ::memcpy(idx_prev, idx_b, 4 * sizeof(int));
+        n_right_prev = n_right;
+        n_top_prev = n_top;
+        unit_v_prev = unit_v;
+
+        if (!closed)
+        {
+            // Terminate open paths with caps.
+            if (i == 0)
+                volume.push_quad(idx_a[BOTTOM], idx_a[RIGHT], idx_a[TOP], idx_a[LEFT]);
+
+            // We don't use 'else' because both cases are true if we have only one line.
+            if (i + 1 == lines.size())
+                volume.push_quad(idx_b[BOTTOM], idx_b[LEFT], idx_b[TOP], idx_b[RIGHT]);
+        }
+
+        // Add quads for a straight hollow tube-like segment.
+        // bottom-right face
+        volume.push_quad(idx_a[BOTTOM], idx_b[BOTTOM], idx_b[RIGHT], idx_a[RIGHT]);
+        // top-right face
+        volume.push_quad(idx_a[RIGHT], idx_b[RIGHT], idx_b[TOP], idx_a[TOP]);
+        // top-left face
+        volume.push_quad(idx_a[TOP], idx_b[TOP], idx_b[LEFT], idx_a[LEFT]);
+        // bottom-left face
+        volume.push_quad(idx_a[LEFT], idx_b[LEFT], idx_b[BOTTOM], idx_a[BOTTOM]);
+    }
+
+#undef LEFT
+#undef RIGHT
+#undef TOP
+#undef BOTTOM
+}
+
+static void point_to_indexed_vertex_array(const Point3& point,
+    double width,
+    double height,
+    GLIndexedVertexArray& volume)
+{
+    // builds a double piramid, with vertices on the local axes, around the point
+
+    Pointf3 center = Pointf3::new_unscale(point);
+
+    double scale_factor = 1.0;
+    double w = scale_factor * width;
+    double h = scale_factor * height;
+
+    // new vertices ids
+    int idx_last = int(volume.vertices_and_normals_interleaved.size() / 6);
+    int idxs[6];
+    for (int i = 0; i < 6; ++i)
+    {
+        idxs[i] = idx_last + i;
+    }
+
+    Vectorf3 displacement_x(w, 0.0, 0.0);
+    Vectorf3 displacement_y(0.0, w, 0.0);
+    Vectorf3 displacement_z(0.0, 0.0, h);
+
+    Vectorf3 unit_x(1.0, 0.0, 0.0);
+    Vectorf3 unit_y(0.0, 1.0, 0.0);
+    Vectorf3 unit_z(0.0, 0.0, 1.0);
+
+    // vertices
+    volume.push_geometry(center - displacement_x, -unit_x); // idxs[0]
+    volume.push_geometry(center + displacement_x, unit_x);  // idxs[1]
+    volume.push_geometry(center - displacement_y, -unit_y); // idxs[2]
+    volume.push_geometry(center + displacement_y, unit_y);  // idxs[3]
+    volume.push_geometry(center - displacement_z, -unit_z); // idxs[4]
+    volume.push_geometry(center + displacement_z, unit_z);  // idxs[5]
+
+    // top piramid faces
+    volume.push_triangle(idxs[0], idxs[2], idxs[5]);
+    volume.push_triangle(idxs[2], idxs[1], idxs[5]);
+    volume.push_triangle(idxs[1], idxs[3], idxs[5]);
+    volume.push_triangle(idxs[3], idxs[0], idxs[5]);
+
+    // bottom piramid faces
+    volume.push_triangle(idxs[2], idxs[0], idxs[4]);
+    volume.push_triangle(idxs[1], idxs[2], idxs[4]);
+    volume.push_triangle(idxs[3], idxs[1], idxs[4]);
+    volume.push_triangle(idxs[0], idxs[3], idxs[4]);
+}
+
 static void thick_lines_to_verts(
     const Lines                 &lines, 
     const std::vector<double>   &widths,
@@ -620,6 +992,32 @@ static void thick_lines_to_verts(
     thick_lines_to_indexed_vertex_array(lines, widths, heights, closed, top_z, volume.indexed_vertex_array);
 }
 
+static void thick_lines_to_verts(const Lines3& lines,
+    const std::vector<double>& widths,
+    const std::vector<double>& heights,
+    bool closed,
+    GLVolume& volume)
+{
+    thick_lines_to_indexed_vertex_array(lines, widths, heights, closed, volume.indexed_vertex_array);
+}
+
+static void thick_point_to_verts(const Point3& point,
+    double width,
+    double height,
+    GLVolume& volume)
+{
+    point_to_indexed_vertex_array(point, width, height, volume.indexed_vertex_array);
+}
+
+// Fill in the qverts and tverts with quads and triangles for the extrusion_path.
+static inline void extrusionentity_to_verts(const ExtrusionPath &extrusion_path, float print_z, GLVolume &volume)
+{
+    Lines               lines = extrusion_path.polyline.lines();
+    std::vector<double> widths(lines.size(), extrusion_path.width);
+    std::vector<double> heights(lines.size(), extrusion_path.height);
+    thick_lines_to_verts(lines, widths, heights, false, print_z, volume);
+}
+
 // Fill in the qverts and tverts with quads and triangles for the extrusion_path.
 static inline void extrusionentity_to_verts(const ExtrusionPath &extrusion_path, float print_z, const Point &copy, GLVolume &volume)
 {
@@ -703,6 +1101,192 @@ static void extrusionentity_to_verts(const ExtrusionEntity *extrusion_entity, fl
     }
 }
 
+static void polyline3_to_verts(const Polyline3& polyline, double width, double height, GLVolume& volume)
+{
+    Lines3 lines = polyline.lines();
+    std::vector<double> widths(lines.size(), width);
+    std::vector<double> heights(lines.size(), height);
+    thick_lines_to_verts(lines, widths, heights, false, volume);
+}
+
+static void point3_to_verts(const Point3& point, double width, double height, GLVolume& volume)
+{
+    thick_point_to_verts(point, width, height, volume);
+}
+
+_3DScene::GCodePreviewVolumeIndex _3DScene::s_gcode_preview_volume_index;
+_3DScene::LegendTexture _3DScene::s_legend_texture;
+
+const unsigned char _3DScene::LegendTexture::Squares_Border_Color[3] = { 64, 64, 64 };
+const unsigned char _3DScene::LegendTexture::Background_Color[3] = { 9, 91, 134 };
+const unsigned char _3DScene::LegendTexture::Opacity = 255;
+
+// Generate a texture data, but don't load it into the GPU yet, as the GPU context may not yet be valid.
+bool _3DScene::LegendTexture::generate(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors)
+{
+    // Mark the texture as released, but don't release the texture from the GPU yet.
+    m_tex_width = m_tex_height = 0;
+    m_data.clear();
+
+    // collects items to render
+    const std::string& title = preview_data.get_legend_title();
+    const GCodePreviewData::LegendItemsList& items = preview_data.get_legend_items(tool_colors);
+
+    unsigned int items_count = (unsigned int)items.size();
+    if (items_count == 0)
+        // nothing to render, return
+        return false;
+
+    wxMemoryDC memDC;
+    // select default font
+    memDC.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
+
+    // calculates texture size
+    wxCoord w, h;
+    memDC.GetTextExtent(title, &w, &h);
+    unsigned int title_width = (unsigned int)w;
+    unsigned int title_height = (unsigned int)h;
+
+    unsigned int max_text_width = 0;
+    unsigned int max_text_height = 0;
+    for (const GCodePreviewData::LegendItem& item : items)
+    {
+        memDC.GetTextExtent(item.text, &w, &h);
+        max_text_width = std::max(max_text_width, (unsigned int)w);
+        max_text_height = std::max(max_text_height, (unsigned int)h);
+    }
+
+    m_tex_width = std::max(2 * Px_Border + title_width, 2 * (Px_Border + Px_Square_Contour) + Px_Square + Px_Text_Offset + max_text_width);
+    m_tex_height = 2 * (Px_Border + Px_Square_Contour) + title_height + Px_Title_Offset + items_count * Px_Square;
+    if (items_count > 1)
+        m_tex_height += (items_count - 1) * Px_Square_Contour;
+
+    // generates bitmap
+    wxBitmap bitmap(m_tex_width, m_tex_height);
+
+#if defined(__APPLE__) || defined(_MSC_VER)
+    bitmap.UseAlpha();
+#endif
+
+    memDC.SelectObject(bitmap);
+    memDC.SetBackground(wxBrush(wxColour(Background_Color[0], Background_Color[1], Background_Color[2])));
+    memDC.Clear();
+
+    memDC.SetTextForeground(*wxWHITE);
+
+    // draw title
+    unsigned int title_x = Px_Border;
+    unsigned int title_y = Px_Border;
+    memDC.DrawText(title, title_x, title_y);
+
+    // draw icons contours as background
+    unsigned int squares_contour_x = Px_Border;
+    unsigned int squares_contour_y = Px_Border + title_height + Px_Title_Offset;
+    unsigned int squares_contour_width = Px_Square + 2 * Px_Square_Contour;
+    unsigned int squares_contour_height = items_count * Px_Square + 2 * Px_Square_Contour;
+    if (items_count > 1)
+        squares_contour_height += (items_count - 1) * Px_Square_Contour;
+
+    wxColour color(Squares_Border_Color[0], Squares_Border_Color[1], Squares_Border_Color[2]);
+    wxPen pen(color);
+    wxBrush brush(color);
+    memDC.SetPen(pen);
+    memDC.SetBrush(brush);
+    memDC.DrawRectangle(wxRect(squares_contour_x, squares_contour_y, squares_contour_width, squares_contour_height));
+
+    // draw items (colored icon + text)
+    unsigned int icon_x = squares_contour_x + Px_Square_Contour;
+    unsigned int icon_x_inner = icon_x + 1;
+    unsigned int icon_y = squares_contour_y + Px_Square_Contour;
+    unsigned int icon_y_step = Px_Square + Px_Square_Contour;
+
+    unsigned int text_x = icon_x + Px_Square + Px_Text_Offset;
+    unsigned int text_y_offset = (Px_Square - max_text_height) / 2;
+
+    unsigned int px_inner_square = Px_Square - 2;
+
+    for (const GCodePreviewData::LegendItem& item : items)
+    {
+        // draw darker icon perimeter
+        const std::vector<unsigned char>& item_color_bytes = item.color.as_bytes();
+        wxImage::HSVValue dark_hsv = wxImage::RGBtoHSV(wxImage::RGBValue(item_color_bytes[0], item_color_bytes[1], item_color_bytes[2]));
+        dark_hsv.value *= 0.75;
+        wxImage::RGBValue dark_rgb = wxImage::HSVtoRGB(dark_hsv);
+        color.Set(dark_rgb.red, dark_rgb.green, dark_rgb.blue, item_color_bytes[3]);
+        pen.SetColour(color);
+        brush.SetColour(color);
+        memDC.SetPen(pen);
+        memDC.SetBrush(brush);
+        memDC.DrawRectangle(wxRect(icon_x, icon_y, Px_Square, Px_Square));
+
+        // draw icon interior
+        color.Set(item_color_bytes[0], item_color_bytes[1], item_color_bytes[2], item_color_bytes[3]);
+        pen.SetColour(color);
+        brush.SetColour(color);
+        memDC.SetPen(pen);
+        memDC.SetBrush(brush);
+        memDC.DrawRectangle(wxRect(icon_x_inner, icon_y + 1, px_inner_square, px_inner_square));
+
+        // draw text
+        memDC.DrawText(item.text, text_x, icon_y + text_y_offset);
+
+        // update y
+        icon_y += icon_y_step;
+    }
+
+    memDC.SelectObject(wxNullBitmap);
+
+    // Convert the bitmap into a linear data ready to be loaded into the GPU.
+    {
+        wxImage image = bitmap.ConvertToImage();
+        image.SetMaskColour(Background_Color[0], Background_Color[1], Background_Color[2]);
+
+        // prepare buffer
+        m_data.assign(4 * m_tex_width * m_tex_height, 0);
+        for (unsigned int h = 0; h < m_tex_height; ++h)
+        {
+            unsigned int hh = h * m_tex_width;
+            unsigned char* px_ptr = m_data.data() + 4 * hh;
+            for (unsigned int w = 0; w < m_tex_width; ++w)
+            {
+                *px_ptr++ = image.GetRed(w, h);
+                *px_ptr++ = image.GetGreen(w, h);
+                *px_ptr++ = image.GetBlue(w, h);
+                *px_ptr++ = image.IsTransparent(w, h) ? 0 : Opacity;
+            }
+        }
+    }
+    return true;
+}
+
+unsigned int _3DScene::LegendTexture::finalize()
+{
+    if (! m_data.empty()) {
+        // sends buffer to gpu
+        ::glGenTextures(1, &m_tex_id);
+        ::glBindTexture(GL_TEXTURE_2D, m_tex_id);
+        ::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, (GLsizei)m_tex_width, (GLsizei)m_tex_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const GLvoid*)m_data.data());
+        ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+        ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+        ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
+        ::glBindTexture(GL_TEXTURE_2D, 0);
+        m_data.clear();
+    }
+    return (m_tex_width > 0 && m_tex_height > 0) ? m_tex_id : 0;
+}
+
+void _3DScene::LegendTexture::_destroy_texture()
+{
+    if (m_tex_id > 0)
+    {
+        ::glDeleteTextures(1, &m_tex_id);
+        m_tex_id = 0;
+        m_tex_height = 0;
+        m_tex_width = 0;
+    }
+    m_data.clear();
+}
+
 void _3DScene::_glew_init()
 { 
     glewInit();
@@ -735,6 +1319,59 @@ static inline std::vector<float> parse_colors(const std::vector<std::string> &sc
     return output;
 }
 
+void _3DScene::load_gcode_preview(const Print* print, const GCodePreviewData* preview_data, GLVolumeCollection* volumes, const std::vector<std::string>& str_tool_colors, bool use_VBOs)
+{
+    if ((preview_data == nullptr) || (volumes == nullptr))
+        return;
+
+    if (volumes->empty())
+    {
+        std::vector<float> tool_colors = parse_colors(str_tool_colors);
+
+        s_gcode_preview_volume_index.reset();
+
+        _load_gcode_extrusion_paths(*preview_data, *volumes, tool_colors, use_VBOs);
+        _load_gcode_travel_paths(*preview_data, *volumes, tool_colors, use_VBOs);
+        _load_gcode_retractions(*preview_data, *volumes, use_VBOs);
+        _load_gcode_unretractions(*preview_data, *volumes, use_VBOs);
+
+        if (volumes->empty())
+        {
+            reset_legend_texture();
+            volumes->set_render_interleaved_only_volumes(GLVolumeCollection::RenderInterleavedOnlyVolumes(false, 0.0f));
+        }
+        else
+        {
+            _generate_legend_texture(*preview_data, tool_colors);
+
+            _load_shells(*print, *volumes, use_VBOs);
+            volumes->set_render_interleaved_only_volumes(GLVolumeCollection::RenderInterleavedOnlyVolumes(true, 0.25f));
+        }
+    }
+
+    _update_gcode_volumes_visibility(*preview_data, *volumes);
+}
+
+unsigned int _3DScene::get_legend_texture_id()
+{
+    return s_legend_texture.get_texture_id();
+}
+
+unsigned int _3DScene::get_legend_texture_width()
+{
+    return s_legend_texture.get_texture_width();
+}
+
+unsigned int _3DScene::get_legend_texture_height()
+{
+    return s_legend_texture.get_texture_height();
+}
+
+void _3DScene::reset_legend_texture()
+{
+    s_legend_texture.reset_texture();
+}
+
 // Create 3D thick extrusion lines for a skirt and brim.
 // Adds a new Slic3r::GUI::3DScene::Volume to volumes.
 void _3DScene::_load_print_toolpaths(
@@ -743,7 +1380,7 @@ void _3DScene::_load_print_toolpaths(
     const std::vector<std::string>  &tool_colors,
     bool                             use_VBOs)
 {
-    if (! print->has_skirt() && print->config.brim_width.value == 0)
+    if (!print->has_skirt() && print->config.brim_width.value == 0)
         return;
     
     const float color[] = { 0.5f, 1.0f, 0.5f, 1.f }; // greenish
@@ -1092,4 +1729,569 @@ void _3DScene::_load_wipe_tower_toolpaths(
     BOOST_LOG_TRIVIAL(debug) << "Loading wipe tower toolpaths in parallel - end"; 
 }
 
+void _3DScene::_load_gcode_extrusion_paths(const GCodePreviewData& preview_data, GLVolumeCollection& volumes, const std::vector<float>& tool_colors, bool use_VBOs)
+{
+    // helper functions to select data in dependence of the extrusion view type
+    struct Helper
+    {
+        static float path_filter(GCodePreviewData::Extrusion::EViewType type, const ExtrusionPath& path)
+        {
+            switch (type)
+            {
+            case GCodePreviewData::Extrusion::FeatureType:
+                return (float)path.role();
+            case GCodePreviewData::Extrusion::Height:
+                return path.height;
+            case GCodePreviewData::Extrusion::Width:
+                return path.width;
+            case GCodePreviewData::Extrusion::Feedrate:
+                return path.feedrate;
+            case GCodePreviewData::Extrusion::Tool:
+                return (float)path.extruder_id;
+            }
+
+            return 0.0f;
+        }
+
+        static const GCodePreviewData::Color& path_color(const GCodePreviewData& data, const std::vector<float>& tool_colors, float value)
+        {
+            switch (data.extrusion.view_type)
+            {
+            case GCodePreviewData::Extrusion::FeatureType:
+                return data.get_extrusion_role_color((ExtrusionRole)(int)value);
+            case GCodePreviewData::Extrusion::Height:
+                return data.get_extrusion_height_color(value);
+            case GCodePreviewData::Extrusion::Width:
+                return data.get_extrusion_width_color(value);
+            case GCodePreviewData::Extrusion::Feedrate:
+                return data.get_extrusion_feedrate_color(value);
+            case GCodePreviewData::Extrusion::Tool:
+                {
+                    static GCodePreviewData::Color color;
+                    ::memcpy((void*)color.rgba, (const void*)(tool_colors.data() + (unsigned int)value * 4), 4 * sizeof(float));
+                    return color;
+                }
+            }
+
+            return GCodePreviewData::Color::Dummy;
+        }
+    };
+
+    // Helper structure for filters
+    struct Filter
+    {
+        float value;
+        ExtrusionRole role;
+        GLVolume* volume;
+
+        Filter(float value, ExtrusionRole role)
+            : value(value)
+            , role(role)
+            , volume(nullptr)
+        {
+        }
+
+        bool operator == (const Filter& other) const
+        {
+            if (value != other.value)
+                return false;
+
+            if (role != other.role)
+                return false;
+
+            return true;
+        }
+    };
+
+    typedef std::vector<Filter> FiltersList;
+
+    size_t initial_volumes_count = volumes.volumes.size();
+
+    // detects filters
+    FiltersList filters;
+    for (const GCodePreviewData::Extrusion::Layer& layer : preview_data.extrusion.layers)
+    {
+        for (const ExtrusionPath& path : layer.paths)
+        {
+            ExtrusionRole role = path.role();
+            float path_filter = Helper::path_filter(preview_data.extrusion.view_type, path);
+            if (std::find(filters.begin(), filters.end(), Filter(path_filter, role)) == filters.end())
+                filters.emplace_back(path_filter, role);
+        }
+    }
+
+    // nothing to render, return
+    if (filters.empty())
+        return;
+
+    // creates a new volume for each filter
+    for (Filter& filter : filters)
+    {
+        s_gcode_preview_volume_index.first_volumes.emplace_back(GCodePreviewVolumeIndex::Extrusion, (unsigned int)filter.role, (unsigned int)volumes.volumes.size());
+
+        GLVolume* volume = new GLVolume(Helper::path_color(preview_data, tool_colors, filter.value).rgba);
+        if (volume != nullptr)
+        {
+            filter.volume = volume;
+            volumes.volumes.emplace_back(volume);
+        }
+        else
+        {
+            // an error occourred - restore to previous state and return
+            s_gcode_preview_volume_index.first_volumes.pop_back();
+            if (initial_volumes_count != volumes.volumes.size())
+            {
+                std::vector<GLVolume*>::iterator begin = volumes.volumes.begin() + initial_volumes_count;
+                std::vector<GLVolume*>::iterator end = volumes.volumes.end();
+                for (std::vector<GLVolume*>::iterator it = begin; it < end; ++it)
+                {
+                    GLVolume* volume = *it;
+                    delete volume;
+                }
+                volumes.volumes.erase(begin, end);
+                return;
+            }
+        }
+    }
+
+    // populates volumes
+    for (const GCodePreviewData::Extrusion::Layer& layer : preview_data.extrusion.layers)
+    {
+        for (const ExtrusionPath& path : layer.paths)
+        {
+            float path_filter = Helper::path_filter(preview_data.extrusion.view_type, path);
+            FiltersList::iterator filter = std::find(filters.begin(), filters.end(), Filter(path_filter, path.role()));
+            if (filter != filters.end())
+            {
+                filter->volume->print_zs.push_back(layer.z);
+                filter->volume->offsets.push_back(filter->volume->indexed_vertex_array.quad_indices.size());
+                filter->volume->offsets.push_back(filter->volume->indexed_vertex_array.triangle_indices.size());
+
+                extrusionentity_to_verts(path, layer.z, *filter->volume);
+            }
+        }
+    }
+
+    // finalize volumes and sends geometry to gpu
+    if (volumes.volumes.size() > initial_volumes_count)
+    {
+        for (size_t i = initial_volumes_count; i < volumes.volumes.size(); ++i)
+        {
+            GLVolume* volume = volumes.volumes[i];
+            volume->bounding_box = volume->indexed_vertex_array.bounding_box();
+            volume->indexed_vertex_array.finalize_geometry(use_VBOs);
+        }
+    }
+}
+
+void _3DScene::_load_gcode_travel_paths(const GCodePreviewData& preview_data, GLVolumeCollection& volumes, const std::vector<float>& tool_colors, bool use_VBOs)
+{
+    size_t initial_volumes_count = volumes.volumes.size();
+    s_gcode_preview_volume_index.first_volumes.emplace_back(GCodePreviewVolumeIndex::Travel, 0, (unsigned int)initial_volumes_count);
+
+    bool res = true;
+    switch (preview_data.extrusion.view_type)
+    {
+    case GCodePreviewData::Extrusion::Feedrate:
+        {
+            res = _travel_paths_by_feedrate(preview_data, volumes);
+            break;
+        }
+    case GCodePreviewData::Extrusion::Tool:
+        {
+            res = _travel_paths_by_tool(preview_data, volumes, tool_colors);
+            break;
+        }
+    default:
+        {
+            res = _travel_paths_by_type(preview_data, volumes);
+            break;
+        }
+    }
+
+    if (!res)
+    {
+        // an error occourred - restore to previous state and return
+        if (initial_volumes_count != volumes.volumes.size())
+        {
+            std::vector<GLVolume*>::iterator begin = volumes.volumes.begin() + initial_volumes_count;
+            std::vector<GLVolume*>::iterator end = volumes.volumes.end();
+            for (std::vector<GLVolume*>::iterator it = begin; it < end; ++it)
+            {
+                GLVolume* volume = *it;
+                delete volume;
+            }
+            volumes.volumes.erase(begin, end);
+        }
+
+        return;
+    }
+
+    // finalize volumes and sends geometry to gpu
+    if (volumes.volumes.size() > initial_volumes_count)
+    {
+        for (size_t i = initial_volumes_count; i < volumes.volumes.size(); ++i)
+        {
+            GLVolume* volume = volumes.volumes[i];
+            volume->bounding_box = volume->indexed_vertex_array.bounding_box();
+            volume->indexed_vertex_array.finalize_geometry(use_VBOs);
+        }
+    }
+}
+
+bool _3DScene::_travel_paths_by_type(const GCodePreviewData& preview_data, GLVolumeCollection& volumes)
+{
+    // Helper structure for types
+    struct Type
+    {
+        GCodePreviewData::Travel::EType value;
+        GLVolume* volume;
+
+        explicit Type(GCodePreviewData::Travel::EType value)
+            : value(value)
+            , volume(nullptr)
+        {
+        }
+
+        bool operator == (const Type& other) const
+        {
+            return value == other.value;
+        }
+    };
+
+    typedef std::vector<Type> TypesList;
+
+    // colors travels by travel type
+
+    // detects types
+    TypesList types;
+    for (const GCodePreviewData::Travel::Polyline& polyline : preview_data.travel.polylines)
+    {
+        if (std::find(types.begin(), types.end(), Type(polyline.type)) == types.end())
+            types.emplace_back(polyline.type);
+    }
+
+    // nothing to render, return
+    if (types.empty())
+        return true;
+
+    // creates a new volume for each type
+    for (Type& type : types)
+    {
+        GLVolume* volume = new GLVolume(preview_data.travel.type_colors[type.value].rgba);
+        if (volume == nullptr)
+            return false;
+        else
+        {
+            type.volume = volume;
+            volumes.volumes.emplace_back(volume);
+        }
+    }
+
+    // populates volumes
+    for (const GCodePreviewData::Travel::Polyline& polyline : preview_data.travel.polylines)
+    {
+        TypesList::iterator type = std::find(types.begin(), types.end(), Type(polyline.type));
+        if (type != types.end())
+        {
+            type->volume->print_zs.push_back(unscale(polyline.polyline.bounding_box().max.z));
+            type->volume->offsets.push_back(type->volume->indexed_vertex_array.quad_indices.size());
+            type->volume->offsets.push_back(type->volume->indexed_vertex_array.triangle_indices.size());
+
+            polyline3_to_verts(polyline.polyline, preview_data.travel.width, preview_data.travel.height, *type->volume);
+        }
+    }
+
+    return true;
+}
+
+bool _3DScene::_travel_paths_by_feedrate(const GCodePreviewData& preview_data, GLVolumeCollection& volumes)
+{
+    // Helper structure for feedrate
+    struct Feedrate
+    {
+        float value;
+        GLVolume* volume;
+
+        explicit Feedrate(float value)
+            : value(value)
+            , volume(nullptr)
+        {
+        }
+
+        bool operator == (const Feedrate& other) const
+        {
+            return value == other.value;
+        }
+    };
+
+    typedef std::vector<Feedrate> FeedratesList;
+
+    // colors travels by feedrate
+
+    // detects feedrates
+    FeedratesList feedrates;
+    for (const GCodePreviewData::Travel::Polyline& polyline : preview_data.travel.polylines)
+    {
+        if (std::find(feedrates.begin(), feedrates.end(), Feedrate(polyline.feedrate)) == feedrates.end())
+            feedrates.emplace_back(polyline.feedrate);
+    }
+
+    // nothing to render, return
+    if (feedrates.empty())
+        return true;
+
+    // creates a new volume for each feedrate
+    for (Feedrate& feedrate : feedrates)
+    {
+        GLVolume* volume = new GLVolume(preview_data.get_extrusion_feedrate_color(feedrate.value).rgba);
+        if (volume == nullptr)
+            return false;
+        else
+        {
+            feedrate.volume = volume;
+            volumes.volumes.emplace_back(volume);
+        }
+    }
+
+    // populates volumes
+    for (const GCodePreviewData::Travel::Polyline& polyline : preview_data.travel.polylines)
+    {
+        FeedratesList::iterator feedrate = std::find(feedrates.begin(), feedrates.end(), Feedrate(polyline.feedrate));
+        if (feedrate != feedrates.end())
+        {
+            feedrate->volume->print_zs.push_back(unscale(polyline.polyline.bounding_box().max.z));
+            feedrate->volume->offsets.push_back(feedrate->volume->indexed_vertex_array.quad_indices.size());
+            feedrate->volume->offsets.push_back(feedrate->volume->indexed_vertex_array.triangle_indices.size());
+
+            polyline3_to_verts(polyline.polyline, preview_data.travel.width, preview_data.travel.height, *feedrate->volume);
+        }
+    }
+
+    return true;
+}
+
+bool _3DScene::_travel_paths_by_tool(const GCodePreviewData& preview_data, GLVolumeCollection& volumes, const std::vector<float>& tool_colors)
+{
+    // Helper structure for tool
+    struct Tool
+    {
+        unsigned int value;
+        GLVolume* volume;
+
+        explicit Tool(unsigned int value)
+            : value(value)
+            , volume(nullptr)
+        {
+        }
+
+        bool operator == (const Tool& other) const
+        {
+            return value == other.value;
+        }
+    };
+
+    typedef std::vector<Tool> ToolsList;
+
+    // colors travels by tool
+
+    // detects tools
+    ToolsList tools;
+    for (const GCodePreviewData::Travel::Polyline& polyline : preview_data.travel.polylines)
+    {
+        if (std::find(tools.begin(), tools.end(), Tool(polyline.extruder_id)) == tools.end())
+            tools.emplace_back(polyline.extruder_id);
+    }
+
+    // nothing to render, return
+    if (tools.empty())
+        return true;
+
+    // creates a new volume for each tool
+    for (Tool& tool : tools)
+    {
+        GLVolume* volume = new GLVolume(tool_colors.data() + tool.value * 4);
+        if (volume == nullptr)
+            return false;
+        else
+        {
+            tool.volume = volume;
+            volumes.volumes.emplace_back(volume);
+        }
+    }
+
+    // populates volumes
+    for (const GCodePreviewData::Travel::Polyline& polyline : preview_data.travel.polylines)
+    {
+        ToolsList::iterator tool = std::find(tools.begin(), tools.end(), Tool(polyline.extruder_id));
+        if (tool != tools.end())
+        {
+            tool->volume->print_zs.push_back(unscale(polyline.polyline.bounding_box().max.z));
+            tool->volume->offsets.push_back(tool->volume->indexed_vertex_array.quad_indices.size());
+            tool->volume->offsets.push_back(tool->volume->indexed_vertex_array.triangle_indices.size());
+
+            polyline3_to_verts(polyline.polyline, preview_data.travel.width, preview_data.travel.height, *tool->volume);
+        }
+    }
+
+    return true;
+}
+
+void _3DScene::_load_gcode_retractions(const GCodePreviewData& preview_data, GLVolumeCollection& volumes, bool use_VBOs)
+{
+    s_gcode_preview_volume_index.first_volumes.emplace_back(GCodePreviewVolumeIndex::Retraction, 0, (unsigned int)volumes.volumes.size());
+
+    // nothing to render, return
+    if (preview_data.retraction.positions.empty())
+        return;
+
+    GLVolume* volume = new GLVolume(preview_data.retraction.color.rgba);
+    if (volume != nullptr)
+    {
+        volumes.volumes.emplace_back(volume);
+
+        for (const GCodePreviewData::Retraction::Position& position : preview_data.retraction.positions)
+        {
+            volume->print_zs.push_back(unscale(position.position.z));
+            volume->offsets.push_back(volume->indexed_vertex_array.quad_indices.size());
+            volume->offsets.push_back(volume->indexed_vertex_array.triangle_indices.size());
+
+            point3_to_verts(position.position, position.width, position.height, *volume);
+        }
+
+        // finalize volumes and sends geometry to gpu
+        volume->bounding_box = volume->indexed_vertex_array.bounding_box();
+        volume->indexed_vertex_array.finalize_geometry(use_VBOs);
+    }
+}
+
+void _3DScene::_load_gcode_unretractions(const GCodePreviewData& preview_data, GLVolumeCollection& volumes, bool use_VBOs)
+{
+    s_gcode_preview_volume_index.first_volumes.emplace_back(GCodePreviewVolumeIndex::Unretraction, 0, (unsigned int)volumes.volumes.size());
+
+    // nothing to render, return
+    if (preview_data.unretraction.positions.empty())
+        return;
+
+    GLVolume* volume = new GLVolume(preview_data.unretraction.color.rgba);
+    if (volume != nullptr)
+    {
+        volumes.volumes.emplace_back(volume);
+
+        for (const GCodePreviewData::Retraction::Position& position : preview_data.unretraction.positions)
+        {
+            volume->print_zs.push_back(unscale(position.position.z));
+            volume->offsets.push_back(volume->indexed_vertex_array.quad_indices.size());
+            volume->offsets.push_back(volume->indexed_vertex_array.triangle_indices.size());
+
+            point3_to_verts(position.position, position.width, position.height, *volume);
+        }
+
+        // finalize volumes and sends geometry to gpu
+        volume->bounding_box = volume->indexed_vertex_array.bounding_box();
+        volume->indexed_vertex_array.finalize_geometry(use_VBOs);
+    }
+}
+
+void _3DScene::_update_gcode_volumes_visibility(const GCodePreviewData& preview_data, GLVolumeCollection& volumes)
+{
+    unsigned int size = (unsigned int)s_gcode_preview_volume_index.first_volumes.size();
+    for (unsigned int i = 0; i < size; ++i)
+    {
+        std::vector<GLVolume*>::iterator begin = volumes.volumes.begin() + s_gcode_preview_volume_index.first_volumes[i].id;
+        std::vector<GLVolume*>::iterator end = (i + 1 < size) ? volumes.volumes.begin() + s_gcode_preview_volume_index.first_volumes[i + 1].id : volumes.volumes.end();
+
+        for (std::vector<GLVolume*>::iterator it = begin; it != end; ++it)
+        {
+            GLVolume* volume = *it;
+
+            switch (s_gcode_preview_volume_index.first_volumes[i].type)
+            {
+            case GCodePreviewVolumeIndex::Extrusion:
+                {
+                    volume->is_active = preview_data.extrusion.is_role_flag_set((ExtrusionRole)s_gcode_preview_volume_index.first_volumes[i].flag);
+                    break;
+                }
+            case GCodePreviewVolumeIndex::Travel:
+                {
+                    volume->is_active = preview_data.travel.is_visible;
+                    volume->zoom_to_volumes = false;
+                    break;
+                }
+            case GCodePreviewVolumeIndex::Retraction:
+                {
+                    volume->is_active = preview_data.retraction.is_visible;
+                    volume->zoom_to_volumes = false;
+                    break;
+                }
+            case GCodePreviewVolumeIndex::Unretraction:
+                {
+                    volume->is_active = preview_data.unretraction.is_visible;
+                    volume->zoom_to_volumes = false;
+                    break;
+                }
+            case GCodePreviewVolumeIndex::Shell:
+                {
+                    volume->is_active = preview_data.shell.is_visible;
+                    volume->zoom_to_volumes = false;
+                    break;
+                }
+            default:
+                {
+                    volume->is_active = false;
+                    volume->zoom_to_volumes = false;
+                    break;
+                }
+            }
+        }
+    }
+}
+
+void _3DScene::_generate_legend_texture(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors)
+{
+    s_legend_texture.generate(preview_data, tool_colors);
+}
+
+unsigned int _3DScene::finalize_legend_texture()
+{
+    return s_legend_texture.finalize();
+}
+
+void _3DScene::_load_shells(const Print& print, GLVolumeCollection& volumes, bool use_VBOs)
+{
+    size_t initial_volumes_count = volumes.volumes.size();
+    s_gcode_preview_volume_index.first_volumes.emplace_back(GCodePreviewVolumeIndex::Shell, 0, (unsigned int)initial_volumes_count);
+
+    if (print.objects.empty())
+        // nothing to render, return
+        return;
+
+    // adds objects' volumes 
+    unsigned int object_id = 0;
+    for (PrintObject* obj : print.objects)
+    {
+        ModelObject* model_obj = obj->model_object();
+
+        std::vector<int> instance_ids(model_obj->instances.size());
+        for (int i = 0; i < model_obj->instances.size(); ++i)
+        {
+            instance_ids[i] = i;
+        }
+
+        for (ModelInstance* instance : model_obj->instances)
+        {
+            volumes.load_object(model_obj, object_id, instance_ids, "object", "object", "object", use_VBOs);
+        }
+
+        ++object_id;
+    }
+
+    // adds wipe tower's volume
+    coordf_t max_z = print.objects[0]->model_object()->get_model()->bounding_box().max.z;
+    const PrintConfig& config = print.config;
+    unsigned int extruders_count = config.nozzle_diameter.size();
+    if ((extruders_count > 1) && config.single_extruder_multi_material && config.wipe_tower && !config.complete_objects)
+        volumes.load_wipe_tower_preview(1000, config.wipe_tower_x, config.wipe_tower_y, config.wipe_tower_width, config.wipe_tower_per_color_wipe * (extruders_count - 1), max_z, use_VBOs);
+}
+
 }
diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp
index 3649db779..60df05dc1 100644
--- a/xs/src/slic3r/GUI/3DScene.hpp
+++ b/xs/src/slic3r/GUI/3DScene.hpp
@@ -7,12 +7,15 @@
 #include "../../libslic3r/TriangleMesh.hpp"
 #include "../../libslic3r/Utils.hpp"
 
+class wxBitmap;
+
 namespace Slic3r {
 
 class Print;
 class PrintObject;
 class Model;
 class ModelObject;
+class GCodePreviewData;
 
 // A container for interleaved arrays of 3D vertices and normals,
 // possibly indexed by triangles and / or quads.
@@ -106,6 +109,10 @@ public:
         push_geometry(float(x), float(y), float(z), float(nx), float(ny), float(nz));
     }
 
+    inline void push_geometry(const Pointf3& p, const Vectorf3& n) {
+        push_geometry(p.x, p.y, p.z, n.x, n.y, n.z);
+    }
+
     inline void push_triangle(int idx1, int idx2, int idx3) {
         if (this->triangle_indices.size() + 3 > this->vertices_and_normals_interleaved.capacity())
             this->triangle_indices.reserve(next_highest_power_of_2(this->triangle_indices.size() + 3));
@@ -207,6 +214,8 @@ public:
         select_group_id(-1),
         drag_group_id(-1),
         selected(false),
+        is_active(true),
+        zoom_to_volumes(true),
         hover(false),
         tverts_range(0, size_t(-1)),
         qverts_range(0, size_t(-1))
@@ -243,6 +252,10 @@ public:
     int                 drag_group_id;
     // Is this object selected?
     bool                selected;
+    // Whether or not this volume is active for rendering
+    bool                is_active;
+    // Whether or not to use this volume when applying zoom_to_volumes()
+    bool                zoom_to_volumes;
     // Boolean: Is mouse over this object?
     bool                hover;
 
@@ -258,6 +271,7 @@ public:
     // Offset into qverts & tverts, or offsets into indices stored into an OpenGL name_index_buffer.
     std::vector<size_t>         offsets;
 
+
     int                 object_idx() const { return this->composite_id / 1000000; }
     int                 volume_idx() const { return (this->composite_id / 1000) % 1000; }
     int                 instance_idx() const { return this->composite_id % 1000; }
@@ -299,6 +313,28 @@ public:
 
 class GLVolumeCollection
 {
+public:
+    struct RenderInterleavedOnlyVolumes
+    {
+        bool enabled;
+        float alpha; // [0..1]
+
+        RenderInterleavedOnlyVolumes()
+            : enabled(false)
+            , alpha(0.0f)
+        {
+        }
+
+        RenderInterleavedOnlyVolumes(bool enabled, float alpha)
+            : enabled(enabled)
+            , alpha(alpha)
+        {
+        }
+    };
+
+private:
+    RenderInterleavedOnlyVolumes _render_interleaved_only_volumes;
+
 public:
     std::vector<GLVolume*> volumes;
     
@@ -334,6 +370,8 @@ public:
     bool empty() const { return volumes.empty(); }
     void set_range(double low, double high) { for (GLVolume *vol : this->volumes) vol->set_range(low, high); }
 
+    void set_render_interleaved_only_volumes(const RenderInterleavedOnlyVolumes& render_interleaved_only_volumes) { _render_interleaved_only_volumes = render_interleaved_only_volumes; }
+
 private:
     GLVolumeCollection(const GLVolumeCollection &other);
     GLVolumeCollection& operator=(const GLVolumeCollection &);
@@ -341,9 +379,86 @@ private:
 
 class _3DScene
 {
+    struct GCodePreviewVolumeIndex
+    {
+        enum EType
+        {
+            Extrusion,
+            Travel,
+            Retraction,
+            Unretraction,
+            Shell,
+            Num_Geometry_Types
+        };
+
+        struct FirstVolume
+        {
+            EType type;
+            unsigned int flag;
+            // Index of the first volume in a GLVolumeCollection.
+            unsigned int id;
+
+            FirstVolume(EType type, unsigned int flag, unsigned int id) : type(type), flag(flag), id(id) {}
+        };
+
+        std::vector<FirstVolume> first_volumes;
+
+        void reset() { first_volumes.clear(); }
+    };
+
+    static GCodePreviewVolumeIndex s_gcode_preview_volume_index;
+
+    class LegendTexture
+    {
+        static const unsigned int Px_Title_Offset = 5;
+        static const unsigned int Px_Text_Offset = 5;
+        static const unsigned int Px_Square = 20;
+        static const unsigned int Px_Square_Contour = 1;
+        static const unsigned int Px_Border = Px_Square / 2;
+        static const unsigned char Squares_Border_Color[3];
+        static const unsigned char Background_Color[3];
+        static const unsigned char Opacity;
+
+        unsigned int m_tex_id;
+        unsigned int m_tex_width;
+        unsigned int m_tex_height;
+
+    public:
+        LegendTexture() : m_tex_id(0), m_tex_width(0), m_tex_height(0) {}
+        ~LegendTexture() { _destroy_texture(); }
+        
+        // Generate a texture data, but don't load it into the GPU yet, as the glcontext may not be valid yet.
+        bool generate(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors);
+        // If not loaded, load the texture data into the GPU. Return a texture ID or 0 if the texture has zero size.
+        unsigned int finalize();
+
+        unsigned int get_texture_id() const { return m_tex_id; }
+        unsigned int get_texture_width() const { return m_tex_width; }
+        unsigned int get_texture_height() const { return m_tex_height; }
+
+        void reset_texture() { _destroy_texture(); }
+
+    private:
+        bool _create_texture(const GCodePreviewData& preview_data, const wxBitmap& bitmap);
+        void _destroy_texture();
+        // generate() fills in m_data with the pixels, while finalize() moves the data to the GPU before rendering.
+        std::vector<unsigned char> m_data;
+    };
+
+    static LegendTexture s_legend_texture;
+
 public:
     static void _glew_init();
 
+    static void load_gcode_preview(const Print* print, const GCodePreviewData* preview_data, GLVolumeCollection* volumes, const std::vector<std::string>& str_tool_colors, bool use_VBOs);
+
+    static unsigned int get_legend_texture_id();
+    static unsigned int get_legend_texture_width();
+    static unsigned int get_legend_texture_height();
+
+    static void reset_legend_texture();
+    static unsigned int finalize_legend_texture();
+
     static void _load_print_toolpaths(
         const Print                     *print,
         GLVolumeCollection              *volumes,
@@ -356,12 +471,30 @@ public:
         const std::vector<std::string>  &tool_colors,
         bool                             use_VBOs);
 
-
     static void _load_wipe_tower_toolpaths(
         const Print                    *print,
         GLVolumeCollection             *volumes,
         const std::vector<std::string> &tool_colors_str,
         bool                            use_VBOs);
+
+private:
+    // generates gcode extrusion paths geometry
+    static void _load_gcode_extrusion_paths(const GCodePreviewData& preview_data, GLVolumeCollection& volumes, const std::vector<float>& tool_colors, bool use_VBOs);
+    // generates gcode travel paths geometry
+    static void _load_gcode_travel_paths(const GCodePreviewData& preview_data, GLVolumeCollection& volumes, const std::vector<float>& tool_colors, bool use_VBOs);
+    static bool _travel_paths_by_type(const GCodePreviewData& preview_data, GLVolumeCollection& volumes);
+    static bool _travel_paths_by_feedrate(const GCodePreviewData& preview_data, GLVolumeCollection& volumes);
+    static bool _travel_paths_by_tool(const GCodePreviewData& preview_data, GLVolumeCollection& volumes, const std::vector<float>& tool_colors);
+    // generates gcode retractions geometry
+    static void _load_gcode_retractions(const GCodePreviewData& preview_data, GLVolumeCollection& volumes, bool use_VBOs);
+    // generates gcode unretractions geometry
+    static void _load_gcode_unretractions(const GCodePreviewData& preview_data, GLVolumeCollection& volumes, bool use_VBOs);
+    // sets gcode geometry visibility according to user selection
+    static void _update_gcode_volumes_visibility(const GCodePreviewData& preview_data, GLVolumeCollection& volumes);
+    // generates the legend texture in dependence of the current shown view type
+    static void _generate_legend_texture(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors);
+    // generates objects and wipe tower geometry
+    static void _load_shells(const Print& print, GLVolumeCollection& volumes, bool use_VBOs);
 };
 
 }
diff --git a/xs/src/slic3r/GUI/AppConfig.cpp b/xs/src/slic3r/GUI/AppConfig.cpp
index 9378a2094..99339e2f3 100644
--- a/xs/src/slic3r/GUI/AppConfig.cpp
+++ b/xs/src/slic3r/GUI/AppConfig.cpp
@@ -29,7 +29,7 @@ void AppConfig::set_defaults()
 {
     // Reset the empty fields to defaults.
     if (get("autocenter").empty())
-        set("autocenter", "1");
+        set("autocenter", "0");
     // Disable background processing by default as it is not stable.
     if (get("background_processing").empty())
         set("background_processing", "0");
diff --git a/xs/src/slic3r/GUI/BedShapeDialog.cpp b/xs/src/slic3r/GUI/BedShapeDialog.cpp
new file mode 100644
index 000000000..5ee0c1f8b
--- /dev/null
+++ b/xs/src/slic3r/GUI/BedShapeDialog.cpp
@@ -0,0 +1,341 @@
+#include "BedShapeDialog.hpp"
+
+#include <wx/sizer.h>
+#include <wx/statbox.h>
+#include <wx/wx.h> 
+#include "Polygon.hpp"
+#include "BoundingBox.hpp"
+#include <wx/numformatter.h>
+#include "Model.hpp"
+#include "boost/nowide/iostream.hpp"
+
+namespace Slic3r {
+namespace GUI {
+
+void BedShapeDialog::build_dialog(ConfigOptionPoints* default_pt)
+{
+	m_panel = new BedShapePanel(this);
+	m_panel->build_panel(default_pt);
+
+	auto main_sizer = new wxBoxSizer(wxVERTICAL);
+	main_sizer->Add(m_panel, 1, wxEXPAND);
+	main_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10);
+
+	SetSizer(main_sizer);
+	SetMinSize(GetSize());
+	main_sizer->SetSizeHints(this);
+
+	// needed to actually free memory
+	this->Bind(wxEVT_CLOSE_WINDOW, ([this](wxCloseEvent e){
+		EndModal(wxID_OK);
+		Destroy();
+	}));
+}
+
+void BedShapePanel::build_panel(ConfigOptionPoints* default_pt)
+{
+//	on_change(nullptr);
+
+	auto box = new wxStaticBox(this, wxID_ANY, _L("Shape"));
+	auto sbsizer = new wxStaticBoxSizer(box, wxVERTICAL);
+
+	// shape options
+	m_shape_options_book = new wxChoicebook(this, wxID_ANY, wxDefaultPosition, wxSize(300, -1), wxCHB_TOP);
+	sbsizer->Add(m_shape_options_book);
+
+	auto optgroup = init_shape_options_page(_L("Rectangular"));
+		ConfigOptionDef def;
+		def.type = coPoints;
+		def.default_value = new ConfigOptionPoints{ Pointf(200, 200) };
+		def.label = _LU8("Size");
+		def.tooltip = _LU8("Size in X and Y of the rectangular plate.");
+		Option option(def, "rect_size");
+		optgroup->append_single_option_line(option);
+
+		def.type = coPoints;
+		def.default_value = new ConfigOptionPoints{ Pointf(0, 0) };
+		def.label = _LU8("Origin");
+		def.tooltip = _LU8("Distance of the 0,0 G-code coordinate from the front left corner of the rectangle.");
+		option = Option(def, "rect_origin");
+		optgroup->append_single_option_line(option);
+
+		optgroup = init_shape_options_page(_L("Circular"));
+		def.type = coFloat;
+		def.default_value = new ConfigOptionFloat(200);
+		def.sidetext = _LU8("mm");
+		def.label = _LU8("Diameter");
+		def.tooltip = _LU8("Diameter of the print bed. It is assumed that origin (0,0) is located in the center.");
+		option = Option(def, "diameter");
+		optgroup->append_single_option_line(option);
+
+		optgroup = init_shape_options_page(_L("Custom"));
+		Line line{ "", "" };
+		line.full_width = 1;
+		line.widget = [this](wxWindow* parent) {
+			auto btn = new wxButton(parent, wxID_ANY, _L("Load shape from STL..."), wxDefaultPosition, wxDefaultSize);
+			
+			auto sizer = new wxBoxSizer(wxHORIZONTAL);
+			sizer->Add(btn);
+
+			btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e)
+			{
+				load_stl();
+			}));
+
+			return sizer;
+		};
+		optgroup->append_line(line);
+
+	Bind(wxEVT_CHOICEBOOK_PAGE_CHANGED, ([this](wxCommandEvent e)
+	{
+		update_shape();
+	}));
+
+	// right pane with preview canvas
+	m_canvas = new Bed_2D(this);
+	m_canvas->m_bed_shape = default_pt->values;
+
+	// main sizer
+	auto top_sizer = new wxBoxSizer(wxHORIZONTAL);
+	top_sizer->Add(sbsizer, 0, wxEXPAND | wxLeft | wxTOP | wxBOTTOM, 10);
+	if (m_canvas)
+		top_sizer->Add(m_canvas, 1, wxEXPAND | wxALL, 10) ;
+
+	SetSizerAndFit(top_sizer);
+
+	set_shape(default_pt);
+	update_preview();
+}
+
+#define SHAPE_RECTANGULAR	0
+#define SHAPE_CIRCULAR		1
+#define SHAPE_CUSTOM		2
+
+// Called from the constructor.
+// Create a panel for a rectangular / circular / custom bed shape.
+ConfigOptionsGroupShp BedShapePanel::init_shape_options_page(wxString title){
+
+	auto panel = new wxPanel(m_shape_options_book);
+	ConfigOptionsGroupShp optgroup;
+	optgroup = std::make_shared<ConfigOptionsGroup>(panel, _L("Settings"));
+
+	optgroup->label_width = 100;
+	optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value){
+		update_shape();
+	};
+		
+	m_optgroups.push_back(optgroup);
+	panel->SetSizerAndFit(optgroup->sizer);
+	m_shape_options_book->AddPage(panel, title);
+
+	return optgroup;
+}
+
+// Called from the constructor.
+// Set the initial bed shape from a list of points.
+// Deduce the bed shape type(rect, circle, custom)
+// This routine shall be smart enough if the user messes up
+// with the list of points in the ini file directly.
+void BedShapePanel::set_shape(ConfigOptionPoints* points)
+{
+	auto polygon = Polygon::new_scale(points->values);
+
+	// is this a rectangle ?
+	if (points->size() == 4) {
+		auto lines = polygon.lines();
+		if (lines[0].parallel_to(lines[2]) && lines[1].parallel_to(lines[3])) {
+			// okay, it's a rectangle
+			// find origin
+			// the || 0 hack prevents "-0" which might confuse the user
+			int x_min, x_max, y_min, y_max;
+			x_max = x_min = points->values[0].x;
+			y_max = y_min = points->values[0].y;
+			for (auto pt : points->values){
+				if (x_min > pt.x) x_min = pt.x;
+				if (x_max < pt.x) x_max = pt.x;
+				if (y_min > pt.y) y_min = pt.y;
+				if (y_max < pt.y) y_max = pt.y;
+			}
+			if (x_min < 0) x_min = 0;
+			if (x_max < 0) x_max = 0;
+			if (y_min < 0) y_min = 0;
+			if (y_max < 0) y_max = 0;
+			auto origin = new ConfigOptionPoints{ Pointf(-x_min, -y_min) };
+
+			m_shape_options_book->SetSelection(SHAPE_RECTANGULAR);
+			auto optgroup = m_optgroups[SHAPE_RECTANGULAR];
+			optgroup->set_value("rect_size", new ConfigOptionPoints{ Pointf(x_max - x_min, y_max - y_min) });//[x_max - x_min, y_max - y_min]);
+			optgroup->set_value("rect_origin", origin);
+			update_shape();
+			return;
+		}
+	}
+
+	// is this a circle ?
+	{
+		// Analyze the array of points.Do they reside on a circle ?
+		auto center = polygon.bounding_box().center();
+		std::vector<double> vertex_distances;
+		double avg_dist = 0;
+		for (auto pt: polygon.points)
+		{
+			double distance = center.distance_to(pt);
+			vertex_distances.push_back(distance);
+			avg_dist += distance;
+		}
+			
+		bool defined_value = true;
+		for (auto el: vertex_distances)
+		{
+			if (abs(el - avg_dist) > 10 * SCALED_EPSILON)
+				defined_value = false;
+			break;
+		}
+		if (defined_value) {
+			// all vertices are equidistant to center
+			m_shape_options_book->SetSelection(SHAPE_CIRCULAR);
+			auto optgroup = m_optgroups[SHAPE_CIRCULAR];
+			boost::any ret = wxNumberFormatter::ToString(unscale(avg_dist * 2), 0);
+ 			optgroup->set_value("diameter", ret);
+			update_shape();
+			return;
+		}
+	}
+
+	if (points->size() < 3) {
+		// Invalid polygon.Revert to default bed dimensions.
+		m_shape_options_book->SetSelection(SHAPE_RECTANGULAR);
+		auto optgroup = m_optgroups[SHAPE_RECTANGULAR];
+		optgroup->set_value("rect_size", new ConfigOptionPoints{ Pointf(200, 200) });
+		optgroup->set_value("rect_origin", new ConfigOptionPoints{ Pointf(0, 0) });
+		update_shape();
+		return;
+	}
+
+	// This is a custom bed shape, use the polygon provided.
+	m_shape_options_book->SetSelection(SHAPE_CUSTOM);
+	// Copy the polygon to the canvas, make a copy of the array.
+	m_canvas->m_bed_shape = points->values;
+	update_shape();
+}
+
+void BedShapePanel::update_preview()
+{
+	if (m_canvas) m_canvas->Refresh();
+	Refresh();
+}
+
+// Update the bed shape from the dialog fields.
+void BedShapePanel::update_shape()
+{
+	auto page_idx = m_shape_options_book->GetSelection();
+	if (page_idx == SHAPE_RECTANGULAR) {
+		Pointf rect_size, rect_origin;
+		try{
+			rect_size = boost::any_cast<Pointf>(m_optgroups[SHAPE_RECTANGULAR]->get_value("rect_size")); }
+		catch (const std::exception &e){
+			return;}
+		try{
+			rect_origin = boost::any_cast<Pointf>(m_optgroups[SHAPE_RECTANGULAR]->get_value("rect_origin"));
+		}
+		catch (const std::exception &e){
+			return;}
+		
+		auto x = rect_size.x;
+		auto y = rect_size.y;
+		// empty strings or '-' or other things
+		if (x == 0 || y == 0)	return;
+		double x0 = 0.0;
+		double y0 = 0.0;
+		double x1 = x;
+		double y1 = y;
+
+		auto dx = rect_origin.x;
+		auto dy = rect_origin.y;
+
+		x0 -= dx;
+		x1 -= dx;
+		y0 -= dy;
+		y1 -= dy;
+		m_canvas->m_bed_shape = {	Pointf(x0, y0),
+									Pointf(x1, y0),
+									Pointf(x1, y1),
+									Pointf(x0, y1)};
+	} 
+	else if(page_idx == SHAPE_CIRCULAR) {
+		double diameter;
+		try{
+			diameter = boost::any_cast<double>(m_optgroups[SHAPE_CIRCULAR]->get_value("diameter"));
+		}
+		catch (const std::exception &e){
+			return;
+		} 
+ 		if (diameter == 0.0) return ;
+		auto r = diameter / 2;
+		auto twopi = 2 * PI;
+		auto edges = 60;
+		std::vector<Pointf> points;
+		for (size_t i = 1; i <= 60; ++i){
+			auto angle = i * twopi / edges;
+			points.push_back(Pointf(r*cos(angle), r*sin(angle)));
+		}
+		m_canvas->m_bed_shape = points;
+	}
+
+//	$self->{on_change}->();
+	update_preview();
+}
+
+// Loads an stl file, projects it to the XY plane and calculates a polygon.
+void BedShapePanel::load_stl()
+{
+	t_file_wild_card vec_FILE_WILDCARDS = get_file_wild_card();
+	std::vector<std::string> file_types = { "known", "stl", "obj", "amf", "prusa"};
+	wxString MODEL_WILDCARD;
+	for (auto file_type: file_types)
+		MODEL_WILDCARD += vec_FILE_WILDCARDS.at(file_type) + "|";
+
+	auto dialog = new wxFileDialog(this, _L("Choose a file to import bed shape from (STL/OBJ/AMF/PRUSA):"), "", "",
+		MODEL_WILDCARD, wxFD_OPEN | wxFD_FILE_MUST_EXIST);
+	if (dialog->ShowModal() != wxID_OK) {
+		dialog->Destroy();
+		return;
+	}
+	wxArrayString input_file;
+	dialog->GetPaths(input_file);
+	dialog->Destroy();
+
+	std::string file_name = input_file[0].ToStdString();
+
+	Model model;
+	try {
+		model = Model::read_from_file(file_name);
+	}
+	catch (std::exception &e) {
+		auto msg = _L("Error! ") + file_name + " : " + e.what() + ".";
+		show_error(this, msg);
+		exit(1);
+	}
+
+	auto mesh = model.mesh();
+	auto expolygons = mesh.horizontal_projection();
+
+	if (expolygons.size() == 0) {
+		show_error(this, _L("The selected file contains no geometry."));
+		return;
+	}
+	if (expolygons.size() > 1) {
+		show_error(this, _L("The selected file contains several disjoint areas. This is not supported."));
+		return;
+	}
+
+	auto polygon = expolygons[0].contour;
+	std::vector<Pointf> points;
+	for (auto pt : polygon.points)
+		points.push_back(Pointf::new_unscale(pt));
+	m_canvas->m_bed_shape = points;
+	update_preview();
+}
+
+} // GUI
+} // Slic3r
diff --git a/xs/src/slic3r/GUI/BedShapeDialog.hpp b/xs/src/slic3r/GUI/BedShapeDialog.hpp
new file mode 100644
index 000000000..81b0a41e3
--- /dev/null
+++ b/xs/src/slic3r/GUI/BedShapeDialog.hpp
@@ -0,0 +1,51 @@
+// The bed shape dialog.
+// The dialog opens from Print Settins tab->Bed Shape : Set...
+
+#include "OptionsGroup.hpp"
+#include "2DBed.hpp"
+
+
+#include <wx/dialog.h>
+#include <wx/choicebk.h>
+
+namespace Slic3r {
+namespace GUI {
+
+using ConfigOptionsGroupShp = std::shared_ptr<ConfigOptionsGroup>;
+class BedShapePanel : public wxPanel
+{
+	wxChoicebook*	m_shape_options_book;
+	Bed_2D*			m_canvas;
+
+	std::vector <ConfigOptionsGroupShp>	m_optgroups;
+
+public:
+	BedShapePanel(wxWindow* parent) : wxPanel(parent, wxID_ANY){}
+	~BedShapePanel(){}
+
+	void		build_panel(ConfigOptionPoints* default_pt);
+	
+	ConfigOptionsGroupShp	init_shape_options_page(wxString title);
+	void		set_shape(ConfigOptionPoints* points);
+	void		update_preview();
+	void		update_shape();
+	void		load_stl();
+	
+	// Returns the resulting bed shape polygon. This value will be stored to the ini file.
+	std::vector<Pointf>	GetValue() { return m_canvas->m_bed_shape; }
+};
+
+class BedShapeDialog : public wxDialog
+{
+	BedShapePanel*	m_panel;
+public:
+	BedShapeDialog(wxWindow* parent) : wxDialog(parent, wxID_ANY, _L("Bed Shape"),
+		wxDefaultPosition, wxSize(350, 700), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER){}
+	~BedShapeDialog(){  }
+
+	void		build_dialog(ConfigOptionPoints* default_pt);
+	std::vector<Pointf>	GetValue() { return m_panel->GetValue(); }
+};
+
+} // GUI
+} // Slic3r
diff --git a/xs/src/slic3r/GUI/ConfigExceptions.hpp b/xs/src/slic3r/GUI/ConfigExceptions.hpp
new file mode 100644
index 000000000..9038d3445
--- /dev/null
+++ b/xs/src/slic3r/GUI/ConfigExceptions.hpp
@@ -0,0 +1,15 @@
+#include <exception> 
+namespace Slic3r {
+
+class ConfigError : public std::runtime_error { 
+using std::runtime_error::runtime_error;
+};
+
+namespace GUI {
+
+class ConfigGUITypeError : public ConfigError { 
+using ConfigError::ConfigError;
+};
+}
+
+}
diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp
new file mode 100644
index 000000000..330af6d0a
--- /dev/null
+++ b/xs/src/slic3r/GUI/Field.cpp
@@ -0,0 +1,570 @@
+#include "GUI.hpp"//"slic3r_gui.hpp"
+#include "Field.hpp"
+
+//#include <wx/event.h>
+#include <regex>
+#include <wx/numformatter.h>
+#include <wx/tooltip.h>
+#include "PrintConfig.hpp"
+#include <boost/algorithm/string/predicate.hpp>
+
+namespace Slic3r { namespace GUI {
+
+	void Field::on_kill_focus(wxEvent& event) {
+        // Without this, there will be nasty focus bugs on Windows.
+        // Also, docs for wxEvent::Skip() say "In general, it is recommended to skip all 
+        // non-command events to allow the default handling to take place."
+		event.Skip();
+		std::cerr << "calling Field::on_kill_focus from " << m_opt_id<< "\n";
+        // call the registered function if it is available
+        if (m_on_kill_focus!=nullptr) 
+            m_on_kill_focus();
+    }
+    void Field::on_change_field()
+	{
+//        std::cerr << "calling Field::_on_change \n";
+        if (m_on_change != nullptr  && !m_disable_change_event)
+            m_on_change(m_opt_id, get_value());
+    }
+
+	wxString Field::get_tooltip_text(const wxString& default_string)
+	{
+		wxString tooltip_text("");
+		wxString tooltip = wxString::FromUTF8(m_opt.tooltip.c_str());
+		if (tooltip.length() > 0)
+			tooltip_text = tooltip + "(" + _L("default") + ": " +
+							(boost::iends_with(m_opt_id, "_gcode") ? "\n" : "") + 
+							default_string + ")";
+
+		return tooltip_text;
+	}
+
+	bool Field::is_matched(std::string string, std::string pattern)
+	{
+		std::regex regex_pattern(pattern, std::regex_constants::icase); // use ::icase to make the matching case insensitive like /i in perl
+		return std::regex_match(string, regex_pattern);
+	}
+
+	boost::any Field::get_value_by_opt_type(wxString str, ConfigOptionType type)
+	{
+		boost::any ret_val;
+		switch (m_opt.type){
+		case coInt:
+			ret_val = wxAtoi(str);
+			break;
+		case coPercent:
+		case coPercents:
+		case coFloats:
+		case coFloat:{
+			if (m_opt.type == coPercent) str.RemoveLast();
+			double val;
+			str.ToCDouble(&val);
+			ret_val = val;
+			break; }
+		case coString:
+		case coStrings:
+			ret_val = str.ToStdString();
+			break;
+		case coFloatOrPercent:{
+			if (str.Last() == '%')
+				str.RemoveLast();
+			double val;
+			str.ToCDouble(&val);
+			ret_val = val;
+			break;
+		}
+		default:
+			break;
+		}
+
+		return ret_val;
+	}
+
+	void TextCtrl::BUILD() {
+        auto size = wxSize(wxDefaultSize);
+        if (m_opt.height >= 0) size.SetHeight(m_opt.height);
+        if (m_opt.width >= 0) size.SetWidth(m_opt.width);
+
+		wxString text_value = wxString(""); 
+
+		switch (m_opt.type) {
+		case coFloatOrPercent:
+		{
+			if (static_cast<const ConfigOptionFloatOrPercent*>(m_opt.default_value)->percent)
+			{
+				text_value = wxString::Format(_T("%i"), int(m_opt.default_value->getFloat()));
+				text_value += "%";
+			}
+			else
+				text_value = wxNumberFormatter::ToString(m_opt.default_value->getFloat(), 2);
+			break;
+		}
+		case coPercent:
+		{
+			text_value = wxString::Format(_T("%i"), int(m_opt.default_value->getFloat()));
+			text_value += "%";
+			break;
+		}	
+		case coPercents:
+		{
+			const ConfigOptionPercents *vec = static_cast<const ConfigOptionPercents*>(m_opt.default_value);
+			if (vec == nullptr || vec->empty()) break;
+			if (vec->size() > 1)
+				break;
+			double val = vec->get_at(0);
+			text_value = val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 2, wxNumberFormatter::Style_None);
+			break;
+		}			
+		case coFloat:
+		{
+			double val = m_opt.default_value->getFloat();
+			text_value = (val - int(val)) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 2, wxNumberFormatter::Style_None);
+			break;
+		}			
+		case coFloats:
+		{
+			const ConfigOptionFloats *vec = static_cast<const ConfigOptionFloats*>(m_opt.default_value);
+			if (vec == nullptr || vec->empty()) break;
+			if (vec->size() > 1)
+				break;
+			double val = vec->get_at(0);
+			text_value = val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 2, wxNumberFormatter::Style_None);
+			break;
+		}
+		case coString:			
+			text_value = static_cast<const ConfigOptionString*>(m_opt.default_value)->value;
+			break;
+		case coStrings:
+		{
+			const ConfigOptionStrings *vec = static_cast<const ConfigOptionStrings*>(m_opt.default_value);
+			if (vec == nullptr || vec->empty()) break;
+			if (vec->size() > 1)
+				break;
+			text_value = vec->values.at(0);
+			break;
+		}
+		default:
+			break; 
+		}
+
+		auto temp = new wxTextCtrl(m_parent, wxID_ANY, text_value, wxDefaultPosition, size, (m_opt.multiline ? wxTE_MULTILINE : 0));
+
+		temp->SetToolTip(get_tooltip_text(text_value));
+        
+		temp->Bind(wxEVT_LEFT_DOWN, ([temp](wxEvent& event)
+		{
+			//! to allow the default handling
+			event.Skip();
+			//! eliminating the g-code pop up text description
+			temp->GetToolTip()->Enable(false);
+		}), temp->GetId());
+
+		temp->Bind(wxEVT_KILL_FOCUS, ([this, temp](wxEvent& e)
+		{
+			on_kill_focus(e);
+			temp->GetToolTip()->Enable(true);
+		}), temp->GetId());
+
+		temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent) { on_change_field(); }), temp->GetId());
+
+        // recast as a wxWindow to fit the calling convention
+        window = dynamic_cast<wxWindow*>(temp);
+    }	
+
+	boost::any TextCtrl::get_value()
+	{
+		wxString ret_str = static_cast<wxTextCtrl*>(window)->GetValue();
+		boost::any ret_val = get_value_by_opt_type(ret_str, m_opt.type);
+
+		return ret_val;
+	}
+
+	void TextCtrl::enable() { dynamic_cast<wxTextCtrl*>(window)->Enable(); dynamic_cast<wxTextCtrl*>(window)->SetEditable(true); }
+    void TextCtrl::disable() { dynamic_cast<wxTextCtrl*>(window)->Disable(); dynamic_cast<wxTextCtrl*>(window)->SetEditable(false); }
+
+void CheckBox::BUILD() {
+	auto size = wxSize(wxDefaultSize);
+	if (m_opt.height >= 0) size.SetHeight(m_opt.height);
+	if (m_opt.width >= 0) size.SetWidth(m_opt.width);
+
+	bool check_value =	m_opt.type == coBool ? 
+						m_opt.default_value->getBool() : m_opt.type == coBools ? 
+						static_cast<ConfigOptionBools*>(m_opt.default_value)->values.at(0) : 
+    					false;
+
+	auto temp = new wxCheckBox(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size); 
+	temp->SetValue(check_value);
+	if (m_opt.readonly) temp->Disable();
+
+	temp->Bind(wxEVT_CHECKBOX, ([this](wxCommandEvent e) { on_change_field(); }), temp->GetId());
+
+	temp->SetToolTip(get_tooltip_text(check_value ? "true" : "false")); 
+
+	// recast as a wxWindow to fit the calling convention
+	window = dynamic_cast<wxWindow*>(temp);
+}
+
+int undef_spin_val = -9999;		//! Probably, It's not necessary
+
+void SpinCtrl::BUILD() {
+	auto size = wxSize(wxDefaultSize);
+	if (m_opt.height >= 0) size.SetHeight(m_opt.height);
+	if (m_opt.width >= 0) size.SetWidth(m_opt.width);
+
+	wxString	text_value = wxString("");
+	int			default_value = 0;
+
+	switch (m_opt.type) {
+	case coInt:
+		default_value = m_opt.default_value->getInt();
+		text_value = wxString::Format(_T("%i"), default_value);
+		break;
+	case coInts:
+	{
+		const ConfigOptionInts *vec = static_cast<const ConfigOptionInts*>(m_opt.default_value);
+		if (vec == nullptr || vec->empty()) break;
+		for (size_t id = 0; id < vec->size(); ++id)
+		{
+			default_value = vec->get_at(id);
+			text_value += wxString::Format(_T("%i"), default_value);
+		}
+		break;
+	}
+	default:
+		break;
+	}
+
+	auto temp = new wxSpinCtrl(m_parent, wxID_ANY, text_value, wxDefaultPosition, size,
+		0, m_opt.min >0 ? m_opt.min : 0, m_opt.max < 2147483647 ? m_opt.max : 2147483647, default_value);
+
+	temp->Bind(wxEVT_SPINCTRL, ([this](wxCommandEvent e) { tmp_value = undef_spin_val; on_change_field(); }), temp->GetId());
+	temp->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) { tmp_value = undef_spin_val; on_kill_focus(e); }), temp->GetId());
+	temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent e)
+	{
+// 		# On OSX / Cocoa, wxSpinCtrl::GetValue() doesn't return the new value
+// 		# when it was changed from the text control, so the on_change callback
+// 		# gets the old one, and on_kill_focus resets the control to the old value.
+// 		# As a workaround, we get the new value from $event->GetString and store
+// 		#�here temporarily so that we can return it from $self->get_value
+		std::string value = e.GetString().utf8_str().data();
+		if (is_matched(value, "^\\d+$"))
+			tmp_value = std::stoi(value);
+		on_change_field();
+// 		# We don't reset tmp_value here because _on_change might put callbacks
+// 		# in the CallAfter queue, and we want the tmp value to be available from
+// 		# them as well.
+	}), temp->GetId());
+	
+	temp->SetToolTip(get_tooltip_text(text_value));
+
+	// recast as a wxWindow to fit the calling convention
+	window = dynamic_cast<wxWindow*>(temp);
+}
+
+void Choice::BUILD() {
+	auto size = wxSize(wxDefaultSize);
+	if (m_opt.height >= 0) size.SetHeight(m_opt.height);
+	if (m_opt.width >= 0) size.SetWidth(m_opt.width);
+
+	wxComboBox* temp;	
+	if (!m_opt.gui_type.empty() && m_opt.gui_type.compare("select_open") != 0)
+		temp = new wxComboBox(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size);
+	else
+		temp = new wxComboBox(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, NULL, wxCB_READONLY);
+
+	// recast as a wxWindow to fit the calling convention
+	window = dynamic_cast<wxWindow*>(temp);
+
+	if (m_opt.enum_labels.empty() && m_opt.enum_values.empty()){
+	}
+	else{
+		for (auto el : m_opt.enum_labels.empty() ? m_opt.enum_values : m_opt.enum_labels)
+			temp->Append(wxString(el));
+		set_selection();
+	}
+ 	temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent e) { on_change_field(); }), temp->GetId());
+ 	temp->Bind(wxEVT_COMBOBOX, ([this](wxCommandEvent e) { on_change_field(); }), temp->GetId());
+
+	temp->SetToolTip(get_tooltip_text(temp->GetValue()));
+}
+
+void Choice::set_selection()
+{
+	wxString text_value = wxString("");
+	switch (m_opt.type){
+	case coFloat:
+	case coPercent:	{
+		double val = m_opt.default_value->getFloat();
+		text_value = val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 1);
+		size_t idx = 0;
+		for (auto el : m_opt.enum_values)
+		{
+			if (el.compare(text_value) == 0)
+				break;
+			++idx;
+		}
+		if (m_opt.type == coPercent) text_value += "%";
+		idx == m_opt.enum_values.size() ?
+			dynamic_cast<wxComboBox*>(window)->SetValue(text_value) :
+			dynamic_cast<wxComboBox*>(window)->SetSelection(idx);
+		break;
+	}
+	case coEnum:{
+		int id_value = static_cast<const ConfigOptionEnum<SeamPosition>*>(m_opt.default_value)->value; //!!
+		dynamic_cast<wxComboBox*>(window)->SetSelection(id_value);
+		break;
+	}
+	case coInt:{
+		int val = m_opt.default_value->getInt(); //!!
+		text_value = wxString::Format(_T("%i"), int(val));
+		size_t idx = 0;
+		for (auto el : m_opt.enum_values)
+		{
+			if (el.compare(text_value) == 0)
+				break;
+			++idx;
+		}
+		idx == m_opt.enum_values.size() ?
+			dynamic_cast<wxComboBox*>(window)->SetValue(text_value) :
+			dynamic_cast<wxComboBox*>(window)->SetSelection(idx);
+		break;
+	}
+	case coStrings:{
+		text_value = static_cast<const ConfigOptionStrings*>(m_opt.default_value)->values.at(0);
+
+		size_t idx = 0;
+		for (auto el : m_opt.enum_values)
+		{
+			if (el.compare(text_value) == 0)
+				break;
+			++idx;
+		}
+		idx == m_opt.enum_values.size() ?
+			dynamic_cast<wxComboBox*>(window)->SetValue(text_value) :
+			dynamic_cast<wxComboBox*>(window)->SetSelection(idx);
+		break;
+	}
+	}
+}
+
+void Choice::set_value(const std::string value)  //! Redundant?
+{
+	m_disable_change_event = true;
+
+	size_t idx=0;
+	for (auto el : m_opt.enum_values)
+	{
+		if (el.compare(value) == 0)
+			break;
+		++idx;
+	}
+
+	idx == m_opt.enum_values.size() ? 
+		dynamic_cast<wxComboBox*>(window)->SetValue(value) :
+		dynamic_cast<wxComboBox*>(window)->SetSelection(idx);
+	
+	m_disable_change_event = false;
+}
+
+void Choice::set_value(boost::any value)
+{
+	m_disable_change_event = true;
+
+	switch (m_opt.type){
+	case coInt:
+	case coFloat:
+	case coPercent:
+	case coStrings:{
+		wxString text_value;
+		if (m_opt.type == coInt) 
+			text_value = wxString::Format(_T("%i"), int(boost::any_cast<int>(value)));
+		else
+			text_value = boost::any_cast<wxString>(value);
+		auto idx = 0;
+		for (auto el : m_opt.enum_values)
+		{
+			if (el.compare(text_value) == 0)
+				break;
+			++idx;
+		}
+		if (m_opt.type == coPercent) text_value += "%";
+		idx == m_opt.enum_values.size() ?
+			dynamic_cast<wxComboBox*>(window)->SetValue(text_value) :
+			dynamic_cast<wxComboBox*>(window)->SetSelection(idx);
+		break;
+	}
+	case coEnum:{
+		dynamic_cast<wxComboBox*>(window)->SetSelection(boost::any_cast<int>(value));
+		break;
+	}
+	default:
+		break;
+	}
+
+	m_disable_change_event = false;
+}
+
+//! it's needed for _update_serial_ports()
+void Choice::set_values(const std::vector<std::string> values)
+{
+	if (values.empty())
+		return;
+	m_disable_change_event = true;
+
+// 	#�it looks that Clear() also clears the text field in recent wxWidgets versions,
+// 	# but we want to preserve it
+	auto ww = dynamic_cast<wxComboBox*>(window);
+	auto value = ww->GetValue();
+	ww->Clear();
+	for (auto el : values)
+		ww->Append(wxString(el));
+	ww->SetValue(value);
+
+	m_disable_change_event = false;
+}
+
+boost::any Choice::get_value()
+{
+	boost::any ret_val;
+	wxString ret_str = static_cast<wxComboBox*>(window)->GetValue();	
+
+	if (m_opt.type != coEnum)
+		ret_val = get_value_by_opt_type(ret_str, m_opt.type);
+	else
+	{
+		int ret_enum = static_cast<wxComboBox*>(window)->GetSelection(); 
+		if (m_opt_id.compare("external_fill_pattern") == 0)
+		{
+			if (!m_opt.enum_values.empty()){
+				std::string key = m_opt.enum_values[ret_enum];
+				t_config_enum_values map_names = ConfigOptionEnum<InfillPattern>::get_enum_values();
+				int value = map_names.at(key);
+
+				ret_val = static_cast<InfillPattern>(value);
+			}
+			else
+				ret_val = static_cast<InfillPattern>(0);
+		}
+		if (m_opt_id.compare("fill_pattern") == 0)
+			ret_val = static_cast<InfillPattern>(ret_enum);
+		else if (m_opt_id.compare("gcode_flavor") == 0)
+			ret_val = static_cast<GCodeFlavor>(ret_enum);
+		else if (m_opt_id.compare("support_material_pattern") == 0)
+			ret_val = static_cast<SupportMaterialPattern>(ret_enum);
+		else if (m_opt_id.compare("seam_position") == 0)
+			ret_val = static_cast<SeamPosition>(ret_enum);
+	}	
+
+	return ret_val;
+}
+
+void ColourPicker::BUILD()
+{
+	auto size = wxSize(wxDefaultSize);
+	if (m_opt.height >= 0) size.SetHeight(m_opt.height);
+	if (m_opt.width >= 0) size.SetWidth(m_opt.width);
+
+	wxString clr(static_cast<ConfigOptionStrings*>(m_opt.default_value)->values.at(0));
+	auto temp = new wxColourPickerCtrl(m_parent, wxID_ANY, clr, wxDefaultPosition, size);
+		
+	// 	// recast as a wxWindow to fit the calling convention
+	window = dynamic_cast<wxWindow*>(temp);
+
+	temp->Bind(wxEVT_COLOURPICKER_CHANGED, ([this](wxCommandEvent e) { on_change_field(); }), temp->GetId());
+
+	temp->SetToolTip(get_tooltip_text(clr));
+}
+
+boost::any ColourPicker::get_value(){
+	boost::any ret_val;
+
+	auto colour = static_cast<wxColourPickerCtrl*>(window)->GetColour();
+	auto clr_str = wxString::Format(wxT("#%02X%02X%02X"), colour.Red(), colour.Green(), colour.Blue());
+	ret_val = clr_str.ToStdString();
+
+	return ret_val;
+}
+
+void PointCtrl::BUILD()
+{
+	auto size = wxSize(wxDefaultSize);
+	if (m_opt.height >= 0) size.SetHeight(m_opt.height);
+	if (m_opt.width >= 0) size.SetWidth(m_opt.width);
+
+	auto temp = new wxBoxSizer(wxHORIZONTAL);
+	// 	$self->wxSizer($sizer);
+	// 
+	wxSize field_size(40, -1);
+
+	auto default_pt = static_cast<ConfigOptionPoints*>(m_opt.default_value)->values.at(0);
+	double val = default_pt.x;
+	wxString X = val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 2, wxNumberFormatter::Style_None);
+	val = default_pt.y;
+	wxString Y = val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 2, wxNumberFormatter::Style_None);
+
+	x_textctrl = new wxTextCtrl(m_parent, wxID_ANY, X, wxDefaultPosition, field_size);
+	y_textctrl = new wxTextCtrl(m_parent, wxID_ANY, Y, wxDefaultPosition, field_size);
+
+	temp->Add(new wxStaticText(m_parent, wxID_ANY, "x : "), 0, wxALIGN_CENTER_VERTICAL, 0);
+	temp->Add(x_textctrl);
+	temp->Add(new wxStaticText(m_parent, wxID_ANY, "   y : "), 0, wxALIGN_CENTER_VERTICAL, 0);
+	temp->Add(y_textctrl);
+
+	x_textctrl->Bind(wxEVT_TEXT, ([this](wxCommandEvent e) { on_change_field(); }), x_textctrl->GetId());
+	y_textctrl->Bind(wxEVT_TEXT, ([this](wxCommandEvent e) { on_change_field(); }), y_textctrl->GetId());
+
+	// 	// recast as a wxWindow to fit the calling convention
+	sizer = dynamic_cast<wxSizer*>(temp);
+
+	x_textctrl->SetToolTip(get_tooltip_text(X+", "+Y));
+	y_textctrl->SetToolTip(get_tooltip_text(X+", "+Y));
+}
+
+void PointCtrl::set_value(const Pointf value)
+{
+	m_disable_change_event = true;
+
+	double val = value.x;
+	x_textctrl->SetValue(val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 2, wxNumberFormatter::Style_None));
+	val = value.y;
+	y_textctrl->SetValue(val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 2, wxNumberFormatter::Style_None));
+
+	m_disable_change_event = false;
+}
+
+void PointCtrl::set_value(boost::any value)
+{
+	Pointf pt;
+	try
+	{
+		pt = boost::any_cast<ConfigOptionPoints*>(value)->values.at(0);
+	}
+	catch (const std::exception &e)
+	{
+		try{
+			pt = boost::any_cast<Pointf>(value);
+		}
+		catch (const std::exception &e)
+		{
+			std::cerr << "Error! Can't cast PointCtrl value" << m_opt_id << "\n";
+			return;
+		}		
+	}	
+	set_value(pt);
+}
+
+boost::any PointCtrl::get_value()
+{
+	Pointf ret_point;
+	double val;
+	x_textctrl->GetValue().ToDouble(&val);
+	ret_point.x = val;
+	y_textctrl->GetValue().ToDouble(&val);
+	ret_point.y = val;
+	return ret_point;
+}
+
+} // GUI
+} // Slic3r
+
+
diff --git a/xs/src/slic3r/GUI/Field.hpp b/xs/src/slic3r/GUI/Field.hpp
new file mode 100644
index 000000000..93ba32efd
--- /dev/null
+++ b/xs/src/slic3r/GUI/Field.hpp
@@ -0,0 +1,270 @@
+#ifndef SLIC3R_GUI_FIELD_HPP
+#define SLIC3R_GUI_FIELD_HPP
+
+#include <wx/wxprec.h>
+#ifndef WX_PRECOMP
+    #include <wx/wx.h>
+#endif
+
+#include <memory>
+#include <functional>
+#include <boost/any.hpp>
+
+#include <wx/spinctrl.h>
+#include <wx/clrpicker.h>
+
+#include "../../libslic3r/libslic3r.h"
+#include "../../libslic3r/Config.hpp"
+
+//#include "slic3r_gui.hpp"
+#include "GUI.hpp"
+
+namespace Slic3r { namespace GUI {
+
+class Field;
+using t_field = std::unique_ptr<Field>;
+using t_kill_focus = std::function<void()>;
+using t_change = std::function<void(t_config_option_key, boost::any)>;
+
+class Field {
+protected:
+    // factory function to defer and enforce creation of derived type. 
+    virtual void	PostInitialize() { BUILD(); }
+    
+    /// Finish constructing the Field's wxWidget-related properties, including setting its own sizer, etc.
+    virtual void	BUILD() = 0;
+
+    /// Call the attached on_kill_focus method. 
+	//! It's important to use wxEvent instead of wxFocusEvent,
+	//! in another case we can't unfocused control at all
+	void			on_kill_focus(wxEvent& event);
+    /// Call the attached on_change method. 
+    void			on_change_field();
+
+public:
+    /// parent wx item, opportunity to refactor (probably not necessary - data duplication)
+    wxWindow*		m_parent {nullptr};
+
+    /// Function object to store callback passed in from owning object.
+	t_kill_focus	m_on_kill_focus {nullptr};
+
+    /// Function object to store callback passed in from owning object.
+	t_change		m_on_change {nullptr};
+
+	// This is used to avoid recursive invocation of the field change/update by wxWidgets.
+    bool			m_disable_change_event {false};
+
+    /// Copy of ConfigOption for deduction purposes
+    const ConfigOptionDef			m_opt {ConfigOptionDef()};
+	const t_config_option_key		m_opt_id;//! {""};
+
+    /// Sets a value for this control.
+    /// subclasses should overload with a specific version
+    /// Postcondition: Method does not fire the on_change event.
+    virtual void		set_value(boost::any value) = 0;
+    
+    /// Gets a boost::any representing this control.
+    /// subclasses should overload with a specific version
+    virtual boost::any	get_value() = 0;
+
+    virtual void		enable() = 0;
+    virtual void		disable() = 0;
+
+    /// Fires the enable or disable function, based on the input.
+    inline void			toggle(bool en) { en ? enable() : disable(); }
+
+	virtual wxString	get_tooltip_text(const wxString& default_string);
+
+    Field(const ConfigOptionDef& opt, const t_config_option_key& id) : m_opt(opt), m_opt_id(id) {};
+    Field(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : m_parent(parent), m_opt(opt), m_opt_id(id) {};
+
+    /// If you don't know what you are getting back, check both methods for nullptr. 
+    virtual wxSizer*	getSizer()  { return nullptr; }
+    virtual wxWindow*	getWindow() { return nullptr; }
+
+	bool		is_matched(std::string string, std::string pattern);
+	boost::any	get_value_by_opt_type(wxString str, ConfigOptionType type);
+
+    /// Factory method for generating new derived classes.
+    template<class T>
+    static t_field Create(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id)  // interface for creating shared objects
+    {
+        auto p = Slic3r::make_unique<T>(parent, opt, id);
+        p->PostInitialize();
+		return std::move(p); //!p;
+    }
+};
+
+/// Convenience function, accepts a const reference to t_field and checks to see whether 
+/// or not both wx pointers are null.
+inline bool is_bad_field(const t_field& obj) { return obj->getSizer() == nullptr && obj->getWindow() == nullptr; }
+
+/// Covenience function to determine whether this field is a valid window field.
+inline bool is_window_field(const t_field& obj) { return !is_bad_field(obj) && obj->getWindow() != nullptr; }
+
+/// Covenience function to determine whether this field is a valid sizer field.
+inline bool is_sizer_field(const t_field& obj) { return !is_bad_field(obj) && obj->getSizer() != nullptr; }
+
+class TextCtrl : public Field {
+    using Field::Field;
+public:
+	TextCtrl(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt,  id) {}
+	TextCtrl(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {}
+
+    void BUILD();
+    wxWindow* window {nullptr};
+
+    virtual void	set_value(std::string value) {
+		m_disable_change_event = true;
+        dynamic_cast<wxTextCtrl*>(window)->SetValue(wxString(value));
+		m_disable_change_event = false;
+    }
+    virtual void	set_value(boost::any value) {
+		m_disable_change_event = true;
+		dynamic_cast<wxTextCtrl*>(window)->SetValue(boost::any_cast<wxString>(value));
+		m_disable_change_event = false;
+    }
+
+	boost::any		get_value() override;
+
+    virtual void	enable();
+    virtual void	disable();
+    virtual wxWindow* getWindow() { return window; }
+};
+
+class CheckBox : public Field {
+	using Field::Field;
+public:
+	CheckBox(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {}
+	CheckBox(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {}
+
+	wxWindow*		window{ nullptr };
+	void			BUILD() override;
+
+	void			set_value(const bool value) {
+		m_disable_change_event = true;
+		dynamic_cast<wxCheckBox*>(window)->SetValue(value);
+		m_disable_change_event = false;
+	}
+	void			set_value(boost::any value) {
+		m_disable_change_event = true;
+		dynamic_cast<wxCheckBox*>(window)->SetValue(boost::any_cast<bool>(value));
+		m_disable_change_event = false;
+	}
+	boost::any		get_value() override {
+		return boost::any(dynamic_cast<wxCheckBox*>(window)->GetValue());
+	}
+
+	void			enable() override { dynamic_cast<wxCheckBox*>(window)->Enable(); }
+	void			disable() override { dynamic_cast<wxCheckBox*>(window)->Disable(); }
+	wxWindow*		getWindow() override { return window; }
+};
+
+class SpinCtrl : public Field {
+	using Field::Field;
+public:
+	SpinCtrl(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id), tmp_value(-9999) {}
+	SpinCtrl(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id), tmp_value(-9999) {}
+
+	int				tmp_value;
+
+	wxWindow*		window{ nullptr };
+	void			BUILD() override;
+
+	void			set_value(const std::string value) {
+		m_disable_change_event = true;
+		dynamic_cast<wxSpinCtrl*>(window)->SetValue(value);
+		m_disable_change_event = false;
+	}
+	void			set_value(boost::any value) {
+		m_disable_change_event = true;
+		dynamic_cast<wxSpinCtrl*>(window)->SetValue(boost::any_cast<int>(value));
+		m_disable_change_event = false;
+	}
+	boost::any		get_value() override {
+		return boost::any(dynamic_cast<wxSpinCtrl*>(window)->GetValue());
+	}
+
+	void			enable() override { dynamic_cast<wxSpinCtrl*>(window)->Enable(); }
+	void			disable() override { dynamic_cast<wxSpinCtrl*>(window)->Disable(); }
+	wxWindow*		getWindow() override { return window; }
+};
+
+class Choice : public Field {
+	using Field::Field;
+public:
+	Choice(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {}
+	Choice(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {}
+
+	wxWindow*		window{ nullptr };
+	void			BUILD() override;
+
+	void			set_selection();
+	void			set_value(const std::string value);
+	void			set_value(boost::any value);
+	void			set_values(const std::vector<std::string> values);
+	boost::any		get_value() override;
+
+	void			enable() override { dynamic_cast<wxComboBox*>(window)->Enable(); };
+	void			disable() override{ dynamic_cast<wxComboBox*>(window)->Disable(); };
+	wxWindow*		getWindow() override { return window; }
+};
+
+class ColourPicker : public Field {
+	using Field::Field;
+public:
+	ColourPicker(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {}
+	ColourPicker(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {}
+
+	wxWindow*		window{ nullptr };
+	void			BUILD()  override;
+
+	void			set_value(const std::string value) {
+		m_disable_change_event = true;
+		dynamic_cast<wxColourPickerCtrl*>(window)->SetColour(value);
+		m_disable_change_event = false;
+	 	}
+	void			set_value(boost::any value) {
+		m_disable_change_event = true;
+		dynamic_cast<wxColourPickerCtrl*>(window)->SetColour(boost::any_cast<wxString>(value));
+		m_disable_change_event = false;
+	}
+
+	boost::any		get_value() override;
+
+	void			enable() override { dynamic_cast<wxColourPickerCtrl*>(window)->Enable(); };
+	void			disable() override{ dynamic_cast<wxColourPickerCtrl*>(window)->Disable(); };
+	wxWindow*		getWindow() override { return window; }
+};
+
+class PointCtrl : public Field {
+	using Field::Field;
+public:
+	PointCtrl(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {}
+	PointCtrl(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {}
+
+	wxSizer*		sizer{ nullptr };
+	wxTextCtrl*		x_textctrl;
+	wxTextCtrl*		y_textctrl;
+
+	void			BUILD()  override;
+
+	void			set_value(const Pointf value);
+	void			set_value(boost::any value);
+	boost::any		get_value() override;
+
+	void			enable() override {
+		x_textctrl->Enable();
+		y_textctrl->Enable(); };
+	void			disable() override{
+		x_textctrl->Disable();
+		y_textctrl->Disable(); };
+	wxSizer*		getSizer() override { return sizer; }
+};
+
+
+#endif
+} // GUI
+} // Slic3r
+
+
diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp
index 8db0508f1..0d7d58e0f 100644
--- a/xs/src/slic3r/GUI/GUI.cpp
+++ b/xs/src/slic3r/GUI/GUI.cpp
@@ -4,22 +4,47 @@
 
 #include <boost/algorithm/string/predicate.hpp>
 #include <boost/filesystem.hpp>
+#include <boost/lexical_cast.hpp>
+
+#include <boost/algorithm/string/split.hpp>
+#include <boost/algorithm/string/classification.hpp>
 
 #if __APPLE__
 #import <IOKit/pwr_mgt/IOPMLib.h>
 #elif _WIN32
 #include <Windows.h>
+// Undefine min/max macros incompatible with the standard library
+// For example, std::numeric_limits<std::streamsize>::max()
+// produces some weird errors
+#ifdef min
+#undef min
+#endif
+#ifdef max
+#undef max
+#endif
 #include "boost/nowide/convert.hpp"
 #pragma comment(lib, "user32.lib")
 #endif
 
 #include <wx/app.h>
 #include <wx/button.h>
+#include <wx/config.h>
+#include <wx/dir.h>
+#include <wx/filename.h>
 #include <wx/frame.h>
 #include <wx/menu.h>
 #include <wx/notebook.h>
 #include <wx/panel.h>
 #include <wx/sizer.h>
+#include <wx/combo.h>
+#include <wx/window.h>
+
+#include "wxExtensions.hpp"
+
+#include "Tab.hpp"
+#include "TabIface.hpp"
+#include "AppConfig.hpp"
+#include "Utils.hpp"
 
 namespace Slic3r { namespace GUI {
 
@@ -147,6 +172,10 @@ wxApp       *g_wxApp        = nullptr;
 wxFrame     *g_wxMainFrame  = nullptr;
 wxNotebook  *g_wxTabPanel   = nullptr;
 
+std::vector<Tab *> g_tabs_list;
+
+wxLocale*	g_wxLocale;
+
 void set_wxapp(wxApp *app)
 {
     g_wxApp = app;
@@ -162,25 +191,337 @@ void set_tab_panel(wxNotebook *tab_panel)
     g_wxTabPanel = tab_panel;
 }
 
-void add_debug_menu(wxMenuBar *menu)
+std::vector<Tab *>& get_tabs_list()
 {
-#if 0
-    auto debug_menu = new wxMenu();
-    debug_menu->Append(wxWindow::NewControlId(1), "Some debug");
-    menu->Append(debug_menu, _T("&Debug"));
-#endif
+	return g_tabs_list;
 }
 
-void create_preset_tab(const char *name)
+bool checked_tab(Tab* tab)
 {
-    auto  *panel  = new wxPanel(g_wxTabPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL);
-    // Vertical sizer to hold the choice menu and the rest of the page.
-    auto  *sizer  = new wxBoxSizer(wxVERTICAL);
-    sizer->SetSizeHints(panel);
-    panel->SetSizer(sizer);
-    auto  *button = new wxButton(panel, wxID_ANY, "Hello World", wxDefaultPosition, wxDefaultSize, 0);
-    sizer->Add(button, 0, 0, 0);
-    g_wxTabPanel->AddPage(panel, name);
+	bool ret = true;
+	if (find(g_tabs_list.begin(), g_tabs_list.end(), tab) == g_tabs_list.end())
+		ret = false;
+	return ret;
+}
+
+void delete_tab_from_list(Tab* tab)
+{
+	std::vector<Tab *>::iterator itr = find(g_tabs_list.begin(), g_tabs_list.end(), tab);
+	if (itr != g_tabs_list.end())
+		g_tabs_list.erase(itr);
+}
+
+bool select_language(wxArrayString & names,
+	wxArrayLong & identifiers)
+{
+	wxCHECK_MSG(names.Count() == identifiers.Count(), false,
+		_L("Array of language names and identifiers should have the same size."));
+	int init_selection = 0;
+	long current_language = g_wxLocale ? g_wxLocale->GetLanguage() : wxLANGUAGE_UNKNOWN;
+	for (auto lang : identifiers){
+		if (lang == current_language)
+			break;
+		else
+			++init_selection;
+	}
+	if (init_selection == identifiers.size())
+		init_selection = 0;
+	long index = wxGetSingleChoiceIndex(_L("Select the language"), _L("Language"), 
+										names, init_selection);
+	if (index != -1)
+	{
+		g_wxLocale = new wxLocale;
+		g_wxLocale->Init(identifiers[index]);
+		g_wxLocale->AddCatalogLookupPathPrefix(wxPathOnly(localization_dir()));
+		g_wxLocale->AddCatalog(g_wxApp->GetAppName());
+		return true;
+	}
+	return false;
+}
+
+bool load_language()
+{
+	wxConfig config(g_wxApp->GetAppName());
+	long language;
+	if (!config.Read(wxT("wxTranslation_Language"),
+		&language, wxLANGUAGE_UNKNOWN))
+	{
+		language = wxLANGUAGE_UNKNOWN;
+	}
+	if (language == wxLANGUAGE_UNKNOWN) 
+		return false;
+	wxArrayString	names;
+	wxArrayLong		identifiers;
+	get_installed_languages(names, identifiers);
+	for (size_t i = 0; i < identifiers.Count(); i++)
+	{
+		if (identifiers[i] == language)
+		{
+			g_wxLocale = new wxLocale;
+			g_wxLocale->Init(identifiers[i]);
+			g_wxLocale->AddCatalogLookupPathPrefix(wxPathOnly(localization_dir()));
+			g_wxLocale->AddCatalog(g_wxApp->GetAppName());
+			return true;
+		}
+	}
+	return false;
+}
+
+void save_language()
+{
+	wxConfig config(g_wxApp->GetAppName());
+	long language = wxLANGUAGE_UNKNOWN;
+	if (g_wxLocale)	{
+		language = g_wxLocale->GetLanguage();
+	}
+	config.Write(wxT("wxTranslation_Language"), language);
+	config.Flush();
+}
+
+void get_installed_languages(wxArrayString & names,
+	wxArrayLong & identifiers)
+{
+	names.Clear();
+	identifiers.Clear();
+
+	wxDir dir(wxPathOnly(localization_dir()));
+	wxString filename;
+	const wxLanguageInfo * langinfo;
+	wxString name = wxLocale::GetLanguageName(wxLANGUAGE_DEFAULT);
+	if (!name.IsEmpty())
+	{
+		names.Add(_L("Default"));
+		identifiers.Add(wxLANGUAGE_DEFAULT);
+	}
+	for (bool cont = dir.GetFirst(&filename, wxEmptyString, wxDIR_DIRS);
+		cont; cont = dir.GetNext(&filename))
+	{
+		wxLogTrace(wxTraceMask(),
+			"L10n: Directory found = \"%s\"",
+			filename.GetData());
+		langinfo = wxLocale::FindLanguageInfo(filename);
+		if (langinfo != NULL)
+		{
+			auto full_file_name = dir.GetName() + wxFileName::GetPathSeparator() +
+				filename + wxFileName::GetPathSeparator() +
+				g_wxApp->GetAppName() + wxT(".mo");
+			if (wxFileExists(full_file_name))
+			{
+				names.Add(langinfo->Description);
+				identifiers.Add(langinfo->Language);
+			}
+		}
+	}
+}
+
+void add_debug_menu(wxMenuBar *menu, int event_language_change)
+{
+//#if 0
+    auto local_menu = new wxMenu();
+	local_menu->Append(wxWindow::NewControlId(1), _L("Change Application Language"));
+	local_menu->Bind(wxEVT_MENU, [event_language_change](wxEvent&){
+		wxArrayString names;
+		wxArrayLong identifiers;
+		get_installed_languages(names, identifiers);
+		if (select_language(names, identifiers)){
+			save_language();
+			show_info(g_wxTabPanel, "Application will be restarted", "Attention!");
+			if (event_language_change > 0) {
+				wxCommandEvent event(event_language_change);
+				g_wxApp->ProcessEvent(event);
+			}
+		}
+	});
+	menu->Append(local_menu, _T("&Localization"));
+//#endif
+}
+
+void create_preset_tabs(PresetBundle *preset_bundle, AppConfig *app_config,
+						bool no_controller, bool is_disabled_button_browse, bool is_user_agent,
+						int event_value_change, int event_presets_changed,
+						int event_button_browse, int event_button_test)
+{	
+	add_created_tab(new TabPrint	(g_wxTabPanel, no_controller), preset_bundle, app_config);
+	add_created_tab(new TabFilament	(g_wxTabPanel, no_controller), preset_bundle, app_config);
+	add_created_tab(new TabPrinter	(g_wxTabPanel, no_controller, is_disabled_button_browse, is_user_agent), 
+					preset_bundle, app_config);
+	for (size_t i = 0; i < g_wxTabPanel->GetPageCount(); ++ i) {
+		Tab *tab = dynamic_cast<Tab*>(g_wxTabPanel->GetPage(i));
+		if (! tab)
+			continue;
+		tab->set_event_value_change(wxEventType(event_value_change));
+		tab->set_event_presets_changed(wxEventType(event_presets_changed));
+		if (tab->name() == "printer"){
+			TabPrinter* tab_printer = static_cast<TabPrinter*>(tab);
+			tab_printer->set_event_button_browse(wxEventType(event_button_browse));
+			tab_printer->set_event_button_test(wxEventType(event_button_test));
+		}
+	}
+}
+
+TabIface* get_preset_tab_iface(char *name)
+{
+	for (size_t i = 0; i < g_wxTabPanel->GetPageCount(); ++ i) {
+		Tab *tab = dynamic_cast<Tab*>(g_wxTabPanel->GetPage(i));
+		if (! tab)
+			continue;
+		if (tab->name() == name) {
+			return new TabIface(tab);
+		}
+	}
+	return new TabIface(nullptr);
+}
+
+// opt_index = 0, by the reason of zero-index in ConfigOptionVector by default (in case only one element)
+void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, boost::any value, int opt_index /*= 0*/)
+{
+	try{
+		switch (config.def()->get(opt_key)->type){
+		case coFloatOrPercent:{
+			const auto &val = *config.option<ConfigOptionFloatOrPercent>(opt_key);
+			config.set_key_value(opt_key, new ConfigOptionFloatOrPercent(boost::any_cast<double>(value), val.percent));
+			break;}
+		case coPercent:
+			config.set_key_value(opt_key, new ConfigOptionPercent(boost::any_cast<double>(value)));
+			break;
+		case coFloat:{
+			double& val = config.opt_float(opt_key);
+			val = boost::any_cast<double>(value);
+			break;
+		}
+		case coPercents:
+		case coFloats:{
+			double& val = config.opt_float(opt_key, 0);
+			val = boost::any_cast<double>(value);
+			break;
+		}			
+		case coString:
+			config.set_key_value(opt_key, new ConfigOptionString(boost::any_cast<std::string>(value)));
+			break;
+		case coStrings:{
+			if (opt_key.compare("compatible_printers") == 0){
+				config.option<ConfigOptionStrings>(opt_key)->values.resize(0);
+				for (auto el : boost::any_cast<std::vector<std::string>>(value))
+					config.option<ConfigOptionStrings>(opt_key)->values.push_back(el);
+			}
+			else{
+				ConfigOptionStrings* vec_new = new ConfigOptionStrings{ boost::any_cast<std::string>(value) };
+				config.option<ConfigOptionStrings>(opt_key)->set_at(vec_new, opt_index, opt_index);
+			}
+			}
+			break;
+		case coBool:
+			config.set_key_value(opt_key, new ConfigOptionBool(boost::any_cast<bool>(value)));
+			break;
+		case coBools:{
+			ConfigOptionBools* vec_new = new ConfigOptionBools{ boost::any_cast<bool>(value) };
+			config.option<ConfigOptionBools>(opt_key)->set_at(vec_new, opt_index, opt_index);
+			break;}
+		case coInt:
+			config.set_key_value(opt_key, new ConfigOptionInt(boost::any_cast<int>(value)));
+			break;
+		case coInts:{
+			ConfigOptionInts* vec_new = new ConfigOptionInts{ boost::any_cast<int>(value) };
+			config.option<ConfigOptionInts>(opt_key)->set_at(vec_new, opt_index, opt_index);
+			}
+			break;
+		case coEnum:{
+			if (opt_key.compare("external_fill_pattern") == 0 ||
+				opt_key.compare("fill_pattern") == 0)
+				config.set_key_value(opt_key, new ConfigOptionEnum<InfillPattern>(boost::any_cast<InfillPattern>(value))); 
+			else if (opt_key.compare("gcode_flavor") == 0)
+				config.set_key_value(opt_key, new ConfigOptionEnum<GCodeFlavor>(boost::any_cast<GCodeFlavor>(value))); 
+			else if (opt_key.compare("support_material_pattern") == 0)
+				config.set_key_value(opt_key, new ConfigOptionEnum<SupportMaterialPattern>(boost::any_cast<SupportMaterialPattern>(value)));
+			else if (opt_key.compare("seam_position") == 0)
+				config.set_key_value(opt_key, new ConfigOptionEnum<SeamPosition>(boost::any_cast<SeamPosition>(value)));
+			}
+			break;
+		case coPoints:{
+			ConfigOptionPoints points;
+			points.values = boost::any_cast<std::vector<Pointf>>(value);
+			config.set_key_value(opt_key, new ConfigOptionPoints(points));
+			}
+			break;
+		case coNone:
+			break;
+		default:
+			break;
+		}
+	}
+	catch (const std::exception &e)
+	{
+		int i = 0;//no reason, just experiment
+	}
+}
+
+void add_created_tab(Tab* panel, PresetBundle *preset_bundle, AppConfig *app_config)
+{
+	panel->m_show_btn_incompatible_presets = app_config->get("show_incompatible_presets").empty();
+	panel->create_preset_tab(preset_bundle);
+
+	// Load the currently selected preset into the GUI, update the preset selection box.
+	panel->load_current_preset();
+	g_wxTabPanel->AddPage(panel, panel->title());
+}
+
+void show_error(wxWindow* parent, wxString message){
+	auto msg_wingow = new wxMessageDialog(parent, message, _L("Error"), wxOK | wxICON_ERROR);
+	msg_wingow->ShowModal();
+}
+
+void show_info(wxWindow* parent, wxString message, wxString title){
+	auto msg_wingow = new wxMessageDialog(parent, message, title.empty() ? _L("Notice") : title, wxOK | wxICON_INFORMATION);
+	msg_wingow->ShowModal();
+}
+
+wxApp* get_app(){
+	return g_wxApp;
+}
+
+void create_combochecklist(wxComboCtrl* comboCtrl, std::string text, std::string items, bool initial_value)
+{
+    if (comboCtrl == nullptr)
+        return;
+
+    wxCheckListBoxComboPopup* popup = new wxCheckListBoxComboPopup;
+    if (popup != nullptr)
+    {
+        comboCtrl->SetPopupControl(popup);
+        popup->SetStringValue(text);
+        popup->Connect(wxID_ANY, wxEVT_CHECKLISTBOX, wxCommandEventHandler(wxCheckListBoxComboPopup::OnCheckListBox), nullptr, popup);
+        popup->Connect(wxID_ANY, wxEVT_LISTBOX, wxCommandEventHandler(wxCheckListBoxComboPopup::OnListBoxSelection), nullptr, popup);
+
+        std::vector<std::string> items_str;
+        boost::split(items_str, items, boost::is_any_of("|"), boost::token_compress_off);
+
+        for (const std::string& item : items_str)
+        {
+            popup->Append(item);
+        }
+
+        for (unsigned int i = 0; i < popup->GetCount(); ++i)
+        {
+            popup->Check(i, initial_value);
+        }
+    }
+}
+
+int combochecklist_get_flags(wxComboCtrl* comboCtrl)
+{
+    int flags = 0;
+
+    wxCheckListBoxComboPopup* popup = wxDynamicCast(comboCtrl->GetPopupControl(), wxCheckListBoxComboPopup);
+    if (popup != nullptr)
+    {
+        for (unsigned int i = 0; i < popup->GetCount(); ++i)
+        {
+            if (popup->IsChecked(i))
+                flags |= 1 << i;
+        }
+    }
+
+    return flags;
 }
 
 } }
diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp
index 3634e0bc8..14f429713 100644
--- a/xs/src/slic3r/GUI/GUI.hpp
+++ b/xs/src/slic3r/GUI/GUI.hpp
@@ -3,13 +3,50 @@
 
 #include <string>
 #include <vector>
+#include "Config.hpp"
 
 class wxApp;
 class wxFrame;
+class wxWindow;
 class wxMenuBar;
 class wxNotebook;
+class wxComboCtrl;
+class wxString;
+class wxArrayString;
+class wxArrayLong;
 
-namespace Slic3r { namespace GUI {
+namespace Slic3r { 
+
+class PresetBundle;
+class PresetCollection;
+class AppConfig;
+class DynamicPrintConfig;
+class TabIface;
+
+//! macro used to localization, return wxString
+#define _L(s) wxGetTranslation(s)
+//! macro used to localization, return const CharType *
+#define _LU8(s) wxGetTranslation(s).ToUTF8().data()
+
+namespace GUI {
+
+class Tab;
+// Map from an file_type name to full file wildcard name.
+typedef std::map<std::string, std::string> t_file_wild_card;
+inline t_file_wild_card& get_file_wild_card() {
+	static t_file_wild_card FILE_WILDCARDS;
+	if (FILE_WILDCARDS.empty()){
+		FILE_WILDCARDS["known"] = "Known files (*.stl, *.obj, *.amf, *.xml, *.prusa)|*.stl;*.STL;*.obj;*.OBJ;*.amf;*.AMF;*.xml;*.XML;*.prusa;*.PRUSA";
+		FILE_WILDCARDS["stl"] = "STL files (*.stl)|*.stl;*.STL";
+		FILE_WILDCARDS["obj"] = "OBJ files (*.obj)|*.obj;*.OBJ";
+		FILE_WILDCARDS["amf"] = "AMF files (*.amf)|*.amf;*.AMF;*.xml;*.XML";
+		FILE_WILDCARDS["prusa"] = "Prusa Control files (*.prusa)|*.prusa;*.PRUSA";
+		FILE_WILDCARDS["ini"] = "INI files *.ini|*.ini;*.INI";
+		FILE_WILDCARDS["gcode"] = "G-code files (*.gcode, *.gco, *.g, *.ngc)|*.gcode;*.GCODE;*.gco;*.GCO;*.g;*.G;*.ngc;*.NGC";
+		FILE_WILDCARDS["svg"] = "SVG files *.svg|*.svg;*.SVG";
+	}
+	return FILE_WILDCARDS;
+}
 
 void disable_screensaver();
 void enable_screensaver();
@@ -22,11 +59,45 @@ void set_wxapp(wxApp *app);
 void set_main_frame(wxFrame *main_frame);
 void set_tab_panel(wxNotebook *tab_panel);
 
-void add_debug_menu(wxMenuBar *menu);
-// Create a new preset tab (print, filament or printer),
-// add it at the end of the tab panel.
-void create_preset_tab(const char *name);
+void add_debug_menu(wxMenuBar *menu, int event_language_change);
+// Create a new preset tab (print, filament and printer),
+void create_preset_tabs(PresetBundle *preset_bundle, AppConfig *app_config, 
+						bool no_controller, bool is_disabled_button_browse,	bool is_user_agent,
+						int event_value_change, int event_presets_changed,
+						int event_button_browse, int event_button_test);
+TabIface* get_preset_tab_iface(char *name);
 
-} }
+// add it at the end of the tab panel.
+void add_created_tab(Tab* panel, PresetBundle *preset_bundle, AppConfig *app_config);
+// Change option value in config
+void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, boost::any value, int opt_index = 0);
+
+void show_error(wxWindow* parent, wxString message);
+void show_info(wxWindow* parent, wxString message, wxString title);
+
+// load language saved at application config 
+bool load_language();
+// save language at application config 
+void save_language();
+// get list of installed languages 
+void get_installed_languages(wxArrayString & names, wxArrayLong & identifiers);
+// select language from the list of installed languages
+bool select_language(wxArrayString & names, wxArrayLong & identifiers);
+
+std::vector<Tab *>& get_tabs_list();
+bool checked_tab(Tab* tab);
+void delete_tab_from_list(Tab* tab);
+
+// Creates a wxCheckListBoxComboPopup inside the given wxComboCtrl, filled with the given text and items.
+// Items are all initialized to the given value.
+// Items must be separated by '|', for example "Item1|Item2|Item3", and so on.
+void create_combochecklist(wxComboCtrl* comboCtrl, std::string text, std::string items, bool initial_value);
+
+// Returns the current state of the items listed in the wxCheckListBoxComboPopup contained in the given wxComboCtrl,
+// encoded inside an int.
+int combochecklist_get_flags(wxComboCtrl* comboCtrl);
+
+}
+}
 
 #endif
diff --git a/xs/src/slic3r/GUI/OptionsGroup.cpp b/xs/src/slic3r/GUI/OptionsGroup.cpp
new file mode 100644
index 000000000..a6d91cfc1
--- /dev/null
+++ b/xs/src/slic3r/GUI/OptionsGroup.cpp
@@ -0,0 +1,410 @@
+#include "OptionsGroup.hpp"
+#include "ConfigExceptions.hpp"
+
+#include <utility>
+#include <wx/tooltip.h>
+#include <wx/numformatter.h>
+
+namespace Slic3r { namespace GUI {
+
+const t_field& OptionsGroup::build_field(const Option& opt) {
+    return build_field(opt.opt_id, opt.opt);
+}
+const t_field& OptionsGroup::build_field(const t_config_option_key& id) {
+	const ConfigOptionDef& opt = m_options.at(id).opt;
+    return build_field(id, opt);
+}
+
+const t_field& OptionsGroup::build_field(const t_config_option_key& id, const ConfigOptionDef& opt) {
+    // Check the gui_type field first, fall through
+    // is the normal type.
+    if (opt.gui_type.compare("select") == 0) {
+    } else if (opt.gui_type.compare("select_open") == 0) {
+		m_fields.emplace(id, STDMOVE(Choice::Create<Choice>(m_parent, opt, id)));
+    } else if (opt.gui_type.compare("color") == 0) {
+		m_fields.emplace(id, STDMOVE(ColourPicker::Create<ColourPicker>(m_parent, opt, id)));
+    } else if (opt.gui_type.compare("f_enum_open") == 0 || 
+                opt.gui_type.compare("i_enum_open") == 0 ||
+                opt.gui_type.compare("i_enum_closed") == 0) {
+		m_fields.emplace(id, STDMOVE(Choice::Create<Choice>(m_parent, opt, id)));
+    } else if (opt.gui_type.compare("slider") == 0) {
+    } else if (opt.gui_type.compare("i_spin") == 0) { // Spinctrl
+    } else { 
+        switch (opt.type) {
+            case coFloatOrPercent:
+            case coFloat:
+            case coFloats:
+			case coPercent:
+			case coPercents:
+			case coString:
+			case coStrings:
+				m_fields.emplace(id, STDMOVE(TextCtrl::Create<TextCtrl>(m_parent, opt, id)));
+                break;
+			case coBool:
+			case coBools:
+				m_fields.emplace(id, STDMOVE(CheckBox::Create<CheckBox>(m_parent, opt, id)));
+				break;
+			case coInt:
+			case coInts:
+				m_fields.emplace(id, STDMOVE(SpinCtrl::Create<SpinCtrl>(m_parent, opt, id)));
+				break;
+            case coEnum:
+				m_fields.emplace(id, STDMOVE(Choice::Create<Choice>(m_parent, opt, id)));
+				break;
+            case coPoints:
+				m_fields.emplace(id, STDMOVE(PointCtrl::Create<PointCtrl>(m_parent, opt, id)));
+				break;
+            case coNone:   break;
+            default:
+				throw /*//!ConfigGUITypeError("")*/std::logic_error("This control doesn't exist till now"); break;
+        }
+    }
+    // Grab a reference to fields for convenience
+    const t_field& field = m_fields[id];
+	field->m_on_change = [this](std::string opt_id, boost::any value){
+			//! This function will be called from Field.					
+			//! Call OptionGroup._on_change(...)
+			if (!this->m_disabled) 
+				this->on_change_OG(opt_id, value);
+	};
+	field->m_on_kill_focus = [this](){
+			//! This function will be called from Field.					
+			if (!this->m_disabled) 
+				this->on_kill_focus();
+	};
+    field->m_parent = parent();
+    // assign function objects for callbacks, etc.
+    return field;
+}
+
+void OptionsGroup::append_line(const Line& line) {
+//!    if (line.sizer != nullptr || (line.widget != nullptr && line.full_width > 0)){
+	if ( (line.sizer != nullptr || line.widget != nullptr) && line.full_width){
+		if (line.sizer != nullptr) {
+            sizer->Add(line.sizer, 0, wxEXPAND | wxALL, wxOSX ? 0 : 15);
+            return;
+        }
+        if (line.widget != nullptr) {
+            sizer->Add(line.widget(m_parent), 0, wxEXPAND | wxALL, wxOSX ? 0 : 15);
+            return;
+        }
+    }
+
+	auto option_set = line.get_options();
+	for (auto opt : option_set) 
+		m_options.emplace(opt.opt_id, opt);
+
+	// if we have a single option with no label, no sidetext just add it directly to sizer
+	if (option_set.size() == 1 && label_width == 0 && option_set.front().opt.full_width &&
+		option_set.front().opt.sidetext.size() == 0 && option_set.front().side_widget == nullptr && 
+		line.get_extra_widgets().size() == 0) {
+		const auto& option = option_set.front();
+		const auto& field = build_field(option);
+
+		if (is_window_field(field))
+			sizer->Add(field->getWindow(), 0, wxEXPAND | wxALL, wxOSX ? 0 : 5);
+		if (is_sizer_field(field))
+			sizer->Add(field->getSizer(), 0, wxEXPAND | wxALL, wxOSX ? 0 : 5);
+		return;
+	}
+
+    auto grid_sizer = m_grid_sizer;
+
+    // Build a label if we have it
+    if (label_width != 0) {
+		auto label = new wxStaticText(parent(), wxID_ANY, line.label + (line.label.IsEmpty() ? "" : ":"), 
+							wxDefaultPosition, wxSize(label_width, -1));
+        label->SetFont(label_font);
+        label->Wrap(label_width); // avoid a Linux/GTK bug
+		grid_sizer->Add(label, 0, wxALIGN_CENTER_VERTICAL,0);
+		if (line.label_tooltip.compare("") != 0)
+			label->SetToolTip(line.label_tooltip);
+    }
+
+    // If there's a widget, build it and add the result to the sizer.
+    if (line.widget != nullptr) {
+        auto wgt = line.widget(parent());
+		grid_sizer->Add(wgt, 0, wxEXPAND | wxBOTTOM | wxTOP, wxOSX ? 0 : 5);
+        return;
+    }
+    
+    // if we have a single option with no sidetext just add it directly to the grid sizer
+    if (option_set.size() == 1 && option_set.front().opt.sidetext.size() == 0 &&
+        option_set.front().side_widget == nullptr && line.get_extra_widgets().size() == 0) {
+        const auto& option = option_set.front();
+        const auto& field = build_field(option);
+//!         std::cerr << "single option, no sidetext.\n";
+//!         std::cerr << "field parent is not null?: " << (field->parent != nullptr) << "\n";
+
+        if (is_window_field(field)) 
+			grid_sizer->Add(field->getWindow(), 0, (option.opt.full_width ? wxEXPAND : 0) |
+							wxBOTTOM | wxTOP | wxALIGN_CENTER_VERTICAL, wxOSX ? 0 : 2);
+        if (is_sizer_field(field)) 
+            grid_sizer->Add(field->getSizer(), 0, (option.opt.full_width ? wxEXPAND : 0) | wxALIGN_CENTER_VERTICAL, 0);
+        return;
+    }
+
+    // if we're here, we have more than one option or a single option with sidetext
+    // so we need a horizontal sizer to arrange these things
+    auto sizer = new wxBoxSizer(wxHORIZONTAL);
+	grid_sizer->Add(sizer, 0, wxEXPAND | wxALL, 0);
+	for (auto opt : option_set) {
+		ConfigOptionDef option = opt.opt;
+		// add label if any
+		if (option.label != "") {
+			auto field_label = new wxStaticText(parent(), wxID_ANY, wxString::FromUTF8(option.label.c_str()) + ":", wxDefaultPosition, wxDefaultSize);
+			field_label->SetFont(label_font);
+			sizer->Add(field_label, 0, wxALIGN_CENTER_VERTICAL, 0);
+		}
+
+		// add field
+		const Option& opt_ref = opt;
+		auto& field = build_field(opt_ref);
+		is_sizer_field(field) ? 
+			sizer->Add(field->getSizer(), 0, wxALIGN_CENTER_VERTICAL, 0) :
+			sizer->Add(field->getWindow(), 0, wxALIGN_CENTER_VERTICAL, 0);
+		
+		// add sidetext if any
+		if (option.sidetext != "") {
+			auto sidetext = new wxStaticText(parent(), wxID_ANY, wxString::FromUTF8(option.sidetext.c_str()), wxDefaultPosition, wxDefaultSize);
+			sidetext->SetFont(sidetext_font);
+			sizer->Add(sidetext, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 4);
+		}
+
+		// add side widget if any
+		if (opt.side_widget != nullptr) {
+			sizer->Add(opt.side_widget(parent())/*!.target<wxWindow>()*/, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 1);	//! requires verification
+		}
+
+		if (opt.opt_id != option_set.back().opt_id) //! istead of (opt != option_set.back())
+		{
+			sizer->AddSpacer(6);
+	    }
+	}
+	// add extra sizers if any
+	for (auto extra_widget : line.get_extra_widgets()) {
+		sizer->Add(extra_widget(parent())/*!.target<wxWindow>()*/, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 4);		//! requires verification
+	}
+}
+
+Line OptionsGroup::create_single_option_line(const Option& option) const {
+	Line retval{ wxString::FromUTF8(option.opt.label.c_str()), wxString::FromUTF8(option.opt.tooltip.c_str()) };
+    Option tmp(option);
+    tmp.opt.label = std::string("");
+    retval.append_option(tmp);
+    return retval;
+}
+
+void OptionsGroup::on_change_OG(t_config_option_key id, /*config_value*/boost::any value) {
+	if (m_on_change != nullptr)
+		m_on_change(id, value);
+}
+
+Option ConfigOptionsGroup::get_option(const std::string opt_key, int opt_index /*= -1*/)
+{
+	if (!m_config->has(opt_key)) {
+		//! exception  ("No $opt_key in ConfigOptionsGroup config");
+	}
+
+	std::string opt_id = opt_index == -1 ? opt_key : opt_key + "#" + std::to_string(opt_index);
+	std::pair<std::string, int> pair(opt_key, opt_index);
+	m_opt_map.emplace(opt_id, pair);
+
+	return Option(*m_config->def()->get(opt_key), opt_id);
+}
+
+void ConfigOptionsGroup::on_change_OG(t_config_option_key opt_id, boost::any value)
+{
+	if (!m_opt_map.empty())
+	{
+		auto it = m_opt_map.find(opt_id);
+		if (it == m_opt_map.end())
+		{
+			OptionsGroup::on_change_OG(opt_id, value);
+			return;
+		}		
+
+		auto itOption = it->second;
+		std::string opt_key = itOption.first;
+		int opt_index = itOption.second;
+
+		auto option = m_options.at(opt_id).opt;
+
+		// get value
+//!		auto field_value = get_value(opt_id);
+		if (option.gui_flags.compare("serialized")==0) {
+			if (opt_index != -1){
+				// 		die "Can't set serialized option indexed value" ;
+			}
+			// 		# Split a string to multiple strings by a semi - colon.This is the old way of storing multi - string values.
+			// 		# Currently used for the post_process config value only.
+			// 		my @values = split / ; / , $field_value;
+			// 		$self->config->set($opt_key, \@values);
+		}
+		else {
+			if (opt_index == -1) {
+				// change_opt_value(*m_config, opt_key, field_value);
+				//!? why field_value?? in this case changed value will be lose! No?
+				change_opt_value(*m_config, opt_key, value);
+			}
+			else {
+				change_opt_value(*m_config, opt_key, value, opt_index);
+// 				auto value = m_config->get($opt_key);
+// 				$value->[$opt_index] = $field_value;
+// 				$self->config->set($opt_key, $value);
+			}
+		}
+	}
+
+	OptionsGroup::on_change_OG(opt_id, value); //!? Why doing this
+}
+
+void ConfigOptionsGroup::reload_config(){
+	for (std::map< std::string, std::pair<std::string, int> >::iterator it = m_opt_map.begin(); it != m_opt_map.end(); ++it) {
+		auto opt_id = it->first;
+		std::string opt_key = m_opt_map.at(opt_id).first;
+		int opt_index = m_opt_map.at(opt_id).second;
+		auto option = m_options.at(opt_id).opt;
+		set_value(opt_id, config_value(opt_key, opt_index, option.gui_flags.compare("serialized") == 0 ));
+	}
+
+}
+
+boost::any ConfigOptionsGroup::config_value(std::string opt_key, int opt_index, bool deserialize){
+
+	if (deserialize) {
+		// Want to edit a vector value(currently only multi - strings) in a single edit box.
+		// Aggregate the strings the old way.
+		// Currently used for the post_process config value only.
+		if (opt_index != -1)
+			throw std::out_of_range("Can't deserialize option indexed value");
+// 		return join(';', m_config->get(opt_key)});
+		return get_config_value(*m_config, opt_key);
+	}
+	else {
+//		return opt_index == -1 ? m_config->get(opt_key) : m_config->get_at(opt_key, opt_index);
+		return get_config_value(*m_config, opt_key, opt_index);
+	}
+}
+
+wxString double_to_string(double const value)
+{
+	int precision = 10 * value - int(10 * value) == 0 ? 1 : 2; 
+	return value - int(value) == 0 ?
+		wxString::Format(_T("%i"), int(value)) :
+		wxNumberFormatter::ToString(value, precision, wxNumberFormatter::Style_None);
+}
+
+boost::any ConfigOptionsGroup::get_config_value(DynamicPrintConfig& config, std::string opt_key, int opt_index/* = -1*/)
+{
+	size_t idx = opt_index == -1 ? 0 : opt_index;
+	
+	boost::any ret;
+	wxString text_value = wxString("");
+	const ConfigOptionDef* opt = config.def()->get(opt_key);
+	switch (opt->type){
+	case coFloatOrPercent:{
+		const auto &value = *config.option<ConfigOptionFloatOrPercent>(opt_key);
+		if (value.percent)
+		{
+			text_value = wxString::Format(_T("%i"), int(value.value));
+			text_value += "%";
+		}
+		else
+			text_value = double_to_string(value.value);
+		ret = text_value;
+		break;
+	}
+	case coPercent:{
+		double val = config.option<ConfigOptionPercent>(opt_key)->value;
+		text_value = wxString::Format(_T("%i"), int(val));
+		ret = text_value;// += "%";
+	}
+		break;
+	case coPercents:
+	case coFloats:
+	case coFloat:{
+		double val = opt->type == coFloats ?
+					config.opt_float(opt_key, idx/*0opt_index*/) :
+						opt->type == coFloat ? config.opt_float(opt_key) :
+						config.option<ConfigOptionPercents>(opt_key)->values.at(idx/*0*/);
+		ret = double_to_string(val);
+		}
+		break;
+	case coString:
+		ret = static_cast<wxString>(config.opt_string(opt_key));
+		break;
+	case coStrings:
+		if (config.option<ConfigOptionStrings>(opt_key)->values.empty())
+			ret = text_value;
+		else
+			ret = static_cast<wxString>(config.opt_string(opt_key, static_cast<unsigned int>(idx/*0*/)/*opt_index*/));
+		break;
+	case coBool:
+		ret = config.opt_bool(opt_key);
+		break;
+	case coBools:
+		ret = config.opt_bool(opt_key, idx/*0opt_index*/);
+		break;
+	case coInt:
+		ret = config.opt_int(opt_key);
+		break;
+	case coInts:
+		ret = config.opt_int(opt_key, idx/*0/*opt_index*/);
+		break;
+	case coEnum:{
+		if (opt_key.compare("external_fill_pattern") == 0 ||
+			opt_key.compare("fill_pattern") == 0 ){
+			ret = static_cast<int>(config.option<ConfigOptionEnum<InfillPattern>>(opt_key)->value);
+		}
+		else if (opt_key.compare("gcode_flavor") == 0 ){
+			ret = static_cast<int>(config.option<ConfigOptionEnum<GCodeFlavor>>(opt_key)->value);
+		}
+		else if (opt_key.compare("support_material_pattern") == 0){
+			ret = static_cast<int>(config.option<ConfigOptionEnum<SupportMaterialPattern>>(opt_key)->value);
+		}
+		else if (opt_key.compare("seam_position") == 0)
+			ret = static_cast<int>(config.option<ConfigOptionEnum<SeamPosition>>(opt_key)->value);
+	}
+		break;
+	case coPoints:{
+		const auto &value = *config.option<ConfigOptionPoints>(opt_key);
+		ret = value.values.at(idx/*0*/);
+		}
+		break;
+	case coNone:
+	default:
+		break;
+	}
+	return ret;
+}
+
+Field* ConfigOptionsGroup::get_fieldc(t_config_option_key opt_key, int opt_index){
+	std::string opt_id = "";
+	for (std::map< std::string, std::pair<std::string, int> >::iterator it = m_opt_map.begin(); it != m_opt_map.end(); ++it) {
+		if (opt_key == m_opt_map.at(it->first).first && opt_index == m_opt_map.at(it->first).second){
+			opt_id = it->first;
+			break;
+		}
+	}
+	return opt_id.empty() ? nullptr : get_field(opt_id);
+}
+
+void ogStaticText::SetText(wxString value)
+{
+	SetLabel(value);
+	Wrap(400);
+	GetParent()->Layout();
+}
+
+void Option::translate()
+{
+	opt.label = _LU8(opt.label);
+	opt.tooltip = _LU8(opt.tooltip);
+	opt.sidetext = _LU8(opt.sidetext);
+	opt.full_label = _LU8(opt.full_label);
+	opt.category = _LU8(opt.category);
+}
+
+} // GUI
+} // Slic3r
diff --git a/xs/src/slic3r/GUI/OptionsGroup.hpp b/xs/src/slic3r/GUI/OptionsGroup.hpp
new file mode 100644
index 000000000..becc62d71
--- /dev/null
+++ b/xs/src/slic3r/GUI/OptionsGroup.hpp
@@ -0,0 +1,181 @@
+#include <wx/wx.h>
+#include <wx/stattext.h>
+#include <wx/settings.h>
+//#include <wx/window.h>
+
+#include <map>
+#include <functional>
+
+#include "libslic3r/Config.hpp"
+#include "libslic3r/PrintConfig.hpp"
+#include "libslic3r/libslic3r.h"
+
+#include "Field.hpp"
+
+// Translate the ifdef 
+#ifdef __WXOSX__
+    #define wxOSX true
+#else
+    #define wxOSX false
+#endif
+
+#define BORDER(a, b) ((wxOSX ? a : b))
+
+namespace Slic3r { namespace GUI {
+
+/// Widget type describes a function object that returns a wxWindow (our widget) and accepts a wxWidget (parent window).
+using widget_t = std::function<wxSizer*(wxWindow*)>;//!std::function<wxWindow*(wxWindow*)>;
+using column_t = std::function<wxSizer*(const Line&)>;
+
+/// Wraps a ConfigOptionDef and adds function object for creating a side_widget.
+struct Option {
+	ConfigOptionDef			opt { ConfigOptionDef() };
+	t_config_option_key		opt_id;//! {""};
+    widget_t				side_widget {nullptr};
+    bool					readonly {false};
+
+	Option(const ConfigOptionDef& _opt, t_config_option_key id) :
+		opt(_opt), opt_id(id) { translate(); }
+	void		translate();
+};
+using t_option = std::unique_ptr<Option>;	//!
+
+/// Represents option lines
+class Line {
+public:
+    wxString	label {wxString("")};
+    wxString	label_tooltip {wxString("")};
+    size_t		full_width {0}; 
+    wxSizer*	sizer {nullptr};
+    widget_t	widget {nullptr};
+
+    void append_option(const Option& option) {
+        m_options.push_back(option);
+    }
+	void append_widget(const widget_t widget) {
+		m_extra_widgets.push_back(widget);
+    }
+	Line(wxString label, wxString tooltip) :
+		label(label), label_tooltip(tooltip) {}
+
+    const std::vector<widget_t>&	get_extra_widgets() const {return m_extra_widgets;}
+    const std::vector<Option>&		get_options() const { return m_options; }
+
+private:
+	std::vector<Option>		m_options;//! {std::vector<Option>()};
+    std::vector<widget_t>	m_extra_widgets;//! {std::vector<widget_t>()};
+};
+
+using t_optionfield_map = std::map<t_config_option_key, t_field>;
+
+class OptionsGroup {
+public:
+    const bool		staticbox {true};
+    const wxString	title {wxString("")};
+    size_t			label_width {200};
+    wxSizer*		sizer {nullptr};
+    column_t		extra_column {nullptr};
+    t_change		m_on_change {nullptr};
+
+    wxFont			sidetext_font {wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) };
+    wxFont			label_font {wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) };
+
+    /// Returns a copy of the pointer of the parent wxWindow.
+    /// Accessor function is because users are not allowed to change the parent
+    /// but defining it as const means a lot of const_casts to deal with wx functions.
+    inline wxWindow* parent() const { return m_parent; }
+
+    void		append_line(const Line& line);
+    Line		create_single_option_line(const Option& option) const;
+    void		append_single_option_line(const Option& option) { append_line(create_single_option_line(option)); }
+
+    // return a non-owning pointer reference 
+    inline /*const*/ Field*	get_field(t_config_option_key id) const { try { return m_fields.at(id).get(); } catch (std::out_of_range e) { return nullptr; } }
+	bool			set_value(t_config_option_key id, boost::any value) { try { m_fields.at(id)->set_value(value); return true; } catch (std::out_of_range e) { return false; } }
+	boost::any		get_value(t_config_option_key id) { boost::any out; try { out = m_fields.at(id)->get_value(); } catch (std::out_of_range e) { ; } return out; }
+
+	inline void		enable() { for (auto& field : m_fields) field.second->enable(); }
+    inline void		disable() { for (auto& field : m_fields) field.second->disable(); }
+
+    OptionsGroup(wxWindow* _parent, wxString title) : 
+		m_parent(_parent), title(title) {
+        sizer = (staticbox ? new wxStaticBoxSizer(new wxStaticBox(_parent, wxID_ANY, title), wxVERTICAL) : new wxBoxSizer(wxVERTICAL));
+        auto num_columns = 1U;
+        if (label_width != 0) num_columns++;
+        if (extra_column != nullptr) num_columns++;
+        m_grid_sizer = new wxFlexGridSizer(0, num_columns, 0,0);
+        static_cast<wxFlexGridSizer*>(m_grid_sizer)->SetFlexibleDirection(wxHORIZONTAL);
+        static_cast<wxFlexGridSizer*>(m_grid_sizer)->AddGrowableCol(label_width != 0);
+
+        sizer->Add(m_grid_sizer, 0, wxEXPAND | wxALL, wxOSX ? 0: 5);
+    }
+
+protected:
+	std::map<t_config_option_key, Option>	m_options;
+    wxWindow*				m_parent {nullptr};
+
+    /// Field list, contains unique_ptrs of the derived type.
+    /// using types that need to know what it is beyond the public interface 
+    /// need to cast based on the related ConfigOptionDef.
+    t_optionfield_map		m_fields;
+    bool					m_disabled {false};
+    wxGridSizer*			m_grid_sizer {nullptr};
+
+    /// Generate a wxSizer or wxWindow from a configuration option
+    /// Precondition: opt resolves to a known ConfigOption
+    /// Postcondition: fields contains a wx gui object.
+    const t_field&		build_field(const t_config_option_key& id, const ConfigOptionDef& opt);
+    const t_field&		build_field(const t_config_option_key& id);
+    const t_field&		build_field(const Option& opt);
+
+    virtual void		on_kill_focus (){};
+	virtual void		on_change_OG(t_config_option_key opt_id, boost::any value);
+};
+
+class ConfigOptionsGroup: public OptionsGroup {
+public:
+	ConfigOptionsGroup(wxWindow* parent, wxString title, DynamicPrintConfig* _config = nullptr) : 
+		OptionsGroup(parent, title), m_config(_config) {}
+
+    /// reference to libslic3r config, non-owning pointer (?).
+    DynamicPrintConfig*		m_config {nullptr};
+    bool					m_full_labels {0};
+	std::map< std::string, std::pair<std::string, int> > m_opt_map;
+
+	Option		get_option(const std::string opt_key, int opt_index = -1);
+	Line		create_single_option_line(const std::string title, int idx = -1) /*const*/{
+		Option option = get_option(title, idx);
+		return OptionsGroup::create_single_option_line(option);
+	}
+	void		append_single_option_line(const Option& option)	{
+		OptionsGroup::append_single_option_line(option);
+	}
+	void		append_single_option_line(const std::string title, int idx = -1)
+	{
+		Option option = get_option(title, idx);
+		append_single_option_line(option);		
+	}
+
+	void		on_change_OG(t_config_option_key opt_id, boost::any value) override;
+	void		on_kill_focus() override
+	{
+		reload_config();
+	}
+	void		reload_config();
+	boost::any	config_value(std::string opt_key, int opt_index, bool deserialize);
+	// return option value from config 
+	boost::any	get_config_value(DynamicPrintConfig& config, std::string opt_key, int opt_index = -1);
+	Field*		get_fieldc(t_config_option_key opt_key, int opt_index);
+};
+
+//  Static text shown among the options.
+class ogStaticText :public wxStaticText{
+public:
+	ogStaticText() {}
+	ogStaticText(wxWindow* parent, const char *text) : wxStaticText(parent, wxID_ANY, text, wxDefaultPosition, wxDefaultSize){}
+	~ogStaticText(){}
+
+	void SetText(wxString value);
+};
+
+}}
diff --git a/xs/src/slic3r/GUI/Preset.hpp b/xs/src/slic3r/GUI/Preset.hpp
index 1f6a90595..c1d85833b 100644
--- a/xs/src/slic3r/GUI/Preset.hpp
+++ b/xs/src/slic3r/GUI/Preset.hpp
@@ -226,7 +226,7 @@ private:
     {
         Preset key(m_type, name);
         auto it = std::lower_bound(m_presets.begin() + 1, m_presets.end(), key);
-        return (it == m_presets.end() && m_presets.front().name == name) ? m_presets.begin() : it;
+        return ((it == m_presets.end() || it->name != name) && m_presets.front().name == name) ? m_presets.begin() : it;
     }
     std::deque<Preset>::const_iterator find_preset_internal(const std::string &name) const
         { return const_cast<PresetCollection*>(this)->find_preset_internal(name); }
diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp
index decc5d00b..3b4bf097f 100644
--- a/xs/src/slic3r/GUI/PresetBundle.cpp
+++ b/xs/src/slic3r/GUI/PresetBundle.cpp
@@ -280,8 +280,8 @@ void PresetBundle::load_config_file(const std::string &path)
 	if (boost::iends_with(path, ".gcode") || boost::iends_with(path, ".g")) {
 		DynamicPrintConfig config;
 		config.apply(FullPrintConfig::defaults());
-		config.load_from_gcode(path);
-		Preset::normalize(config);
+        config.load_from_gcode_file(path);
+        Preset::normalize(config);
 		load_config_file_config(path, true, std::move(config));
 		return;
 	}
@@ -320,6 +320,18 @@ void PresetBundle::load_config_file(const std::string &path)
     }
 }
 
+void PresetBundle::load_config_string(const char* str, const char* source_filename)
+{
+    if (str != nullptr)
+    {
+        DynamicPrintConfig config;
+        config.apply(FullPrintConfig::defaults());
+        config.load_from_gcode_string(str);
+        Preset::normalize(config);
+        load_config_file_config((source_filename == nullptr) ? "" : source_filename, true, std::move(config));
+    }
+}
+
 // Load a config file from a boost property_tree. This is a private method called from load_config_file.
 void PresetBundle::load_config_file_config(const std::string &name_or_path, bool is_external, DynamicPrintConfig &&config)
 {
diff --git a/xs/src/slic3r/GUI/PresetBundle.hpp b/xs/src/slic3r/GUI/PresetBundle.hpp
index df04efd73..e6aea206d 100644
--- a/xs/src/slic3r/GUI/PresetBundle.hpp
+++ b/xs/src/slic3r/GUI/PresetBundle.hpp
@@ -55,6 +55,11 @@ public:
     // If the file is loaded successfully, its print / filament / printer profiles will be activated.
     void                        load_config_file(const std::string &path);
 
+    // Load an external config source containing the print, filament and printer presets.
+    // The given string must contain the full set of parameters (same as those exported to gcode).
+    // If the string is parsed successfully, its print / filament / printer profiles will be activated.
+    void                        load_config_string(const char* str, const char* source_filename = nullptr);
+
     // Load a config bundle file, into presets and store the loaded presets into separate files
     // of the local configuration directory.
     // Load settings into the provided settings instance.
diff --git a/xs/src/slic3r/GUI/PresetHints.cpp b/xs/src/slic3r/GUI/PresetHints.cpp
index 8e23a5c49..4553ba476 100644
--- a/xs/src/slic3r/GUI/PresetHints.cpp
+++ b/xs/src/slic3r/GUI/PresetHints.cpp
@@ -228,4 +228,45 @@ std::string PresetHints::maximum_volumetric_flow_description(const PresetBundle
  	return out;
 }
 
+std::string PresetHints::recommended_thin_wall_thickness(const PresetBundle &preset_bundle)
+{
+    const DynamicPrintConfig &print_config    = preset_bundle.prints   .get_edited_preset().config;
+    const DynamicPrintConfig &printer_config  = preset_bundle.printers .get_edited_preset().config;
+
+    float   layer_height                        = float(print_config.opt_float("layer_height"));
+    int     num_perimeters                      = print_config.opt_int("perimeters");
+    bool    thin_walls                          = print_config.opt_bool("thin_walls");
+    float   nozzle_diameter                     = float(printer_config.opt_float("nozzle_diameter", 0));
+    
+    if (layer_height <= 0.f)
+        return "Recommended object thin wall thickness: Not available due to invalid layer height.";
+
+    Flow    external_perimeter_flow             = Flow::new_from_config_width(
+        frExternalPerimeter, 
+        *print_config.opt<ConfigOptionFloatOrPercent>("external_perimeter_extrusion_width"), 
+        nozzle_diameter, layer_height, false);
+    Flow    perimeter_flow                      = Flow::new_from_config_width(
+        frPerimeter, 
+        *print_config.opt<ConfigOptionFloatOrPercent>("perimeter_extrusion_width"), 
+        nozzle_diameter, layer_height, false);
+
+    std::string out;
+    if (num_perimeters > 0) {
+        int num_lines = std::min(num_perimeters * 2, 10);
+        char buf[256];
+        sprintf(buf, "Recommended object thin wall thickness for layer height %.2f and ", layer_height);
+        out += buf;
+        // Start with the width of two closely spaced 
+        double width = external_perimeter_flow.width + external_perimeter_flow.spacing();
+        for (int i = 2; i <= num_lines; thin_walls ? ++ i : i += 2) {
+            if (i > 2)
+                out += ", ";
+            sprintf(buf, "%d lines: %.2lf mm", i, width);
+            out += buf;
+            width += perimeter_flow.spacing() * (thin_walls ? 1.f : 2.f);
+        }
+    }
+    return out;
+}
+
 }; // namespace Slic3r
diff --git a/xs/src/slic3r/GUI/PresetHints.hpp b/xs/src/slic3r/GUI/PresetHints.hpp
index 589cc2f98..39bf0b100 100644
--- a/xs/src/slic3r/GUI/PresetHints.hpp
+++ b/xs/src/slic3r/GUI/PresetHints.hpp
@@ -13,11 +13,16 @@ class PresetHints
 public:
     // Produce a textual description of the cooling logic of a currently active filament.
     static std::string cooling_description(const Preset &preset);
+    
     // Produce a textual description of the maximum flow achived for the current configuration
     // (the current printer, filament and print settigns).
     // This description will be useful for getting a gut feeling for the maximum volumetric
     // print speed achievable with the extruder.
     static std::string maximum_volumetric_flow_description(const PresetBundle &preset_bundle);
+
+    // Produce a textual description of a recommended thin wall thickness
+    // from the provided number of perimeters and the external / internal perimeter width.
+    static std::string recommended_thin_wall_thickness(const PresetBundle &preset_bundle);
 };
 
 } // namespace Slic3r
diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp
new file mode 100644
index 000000000..b27e7b838
--- /dev/null
+++ b/xs/src/slic3r/GUI/Tab.cpp
@@ -0,0 +1,1801 @@
+#include "../../libslic3r/GCodeSender.hpp"
+#include "Tab.hpp"
+#include "PresetBundle.hpp"
+#include "PresetHints.hpp"
+#include "../../libslic3r/Utils.hpp"
+
+#include <wx/app.h>
+#include <wx/button.h>
+#include <wx/scrolwin.h>
+#include <wx/sizer.h>
+
+#include <wx/bmpcbox.h>
+#include <wx/bmpbuttn.h>
+#include <wx/treectrl.h>
+#include <wx/imaglist.h>
+#include <wx/settings.h>
+
+#include <boost/algorithm/string/predicate.hpp>
+
+namespace Slic3r {
+namespace GUI {
+
+// sub new
+void Tab::create_preset_tab(PresetBundle *preset_bundle)
+{
+	m_preset_bundle = preset_bundle;
+
+	// Vertical sizer to hold the choice menu and the rest of the page.
+	Tab *panel = this;
+	auto  *sizer = new wxBoxSizer(wxVERTICAL);
+	sizer->SetSizeHints(panel);
+	panel->SetSizer(sizer);
+
+	// preset chooser
+	m_presets_choice = new wxBitmapComboBox(panel, wxID_ANY, "", wxDefaultPosition, wxSize(270, -1), 0, 0,wxCB_READONLY);
+	const wxBitmap* bmp = new wxBitmap(wxString::FromUTF8(Slic3r::var("flag-green-icon.png").c_str()), wxBITMAP_TYPE_PNG);
+
+	//buttons
+	wxBitmap bmpMenu;
+	bmpMenu = wxBitmap(wxString::FromUTF8(Slic3r::var("disk.png").c_str()), wxBITMAP_TYPE_PNG);
+	m_btn_save_preset = new wxBitmapButton(panel, wxID_ANY, bmpMenu, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
+	bmpMenu = wxBitmap(wxString::FromUTF8(Slic3r::var("delete.png").c_str()), wxBITMAP_TYPE_PNG);
+	m_btn_delete_preset = new wxBitmapButton(panel, wxID_ANY, bmpMenu, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
+
+	m_show_incompatible_presets = false;
+	m_bmp_show_incompatible_presets = new wxBitmap(wxString::FromUTF8(Slic3r::var("flag-red-icon.png").c_str()), wxBITMAP_TYPE_PNG);
+	m_bmp_hide_incompatible_presets = new wxBitmap(wxString::FromUTF8(Slic3r::var("flag-green-icon.png").c_str()), wxBITMAP_TYPE_PNG);
+	m_btn_hide_incompatible_presets = new wxBitmapButton(panel, wxID_ANY, *m_bmp_hide_incompatible_presets, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
+
+	m_btn_save_preset->SetToolTip(_L("Save current ") + m_title);
+	m_btn_delete_preset->SetToolTip(_L("Delete this preset"));
+	m_btn_delete_preset->Disable();
+
+	m_hsizer = new wxBoxSizer(wxHORIZONTAL);
+	sizer->Add(m_hsizer, 0, wxBOTTOM, 3);
+	m_hsizer->Add(m_presets_choice, 1, wxLEFT | wxRIGHT | wxTOP | wxALIGN_CENTER_VERTICAL, 3);
+	m_hsizer->AddSpacer(4);
+	m_hsizer->Add(m_btn_save_preset, 0, wxALIGN_CENTER_VERTICAL);
+	m_hsizer->AddSpacer(4);
+	m_hsizer->Add(m_btn_delete_preset, 0, wxALIGN_CENTER_VERTICAL);
+	m_hsizer->AddSpacer(16);
+	m_hsizer->Add(m_btn_hide_incompatible_presets, 0, wxALIGN_CENTER_VERTICAL);
+
+	//Horizontal sizer to hold the tree and the selected page.
+	m_hsizer = new wxBoxSizer(wxHORIZONTAL);
+	sizer->Add(m_hsizer, 1, wxEXPAND, 0);
+
+	//left vertical sizer
+	m_left_sizer = new wxBoxSizer(wxVERTICAL);
+	m_hsizer->Add(m_left_sizer, 0, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, 3);
+
+	// tree
+	m_treectrl = new wxTreeCtrl(panel, wxID_ANY, wxDefaultPosition, wxSize(185, -1), 
+		wxTR_NO_BUTTONS | wxTR_HIDE_ROOT | wxTR_SINGLE | wxTR_NO_LINES | wxBORDER_SUNKEN | wxWANTS_CHARS);
+	m_left_sizer->Add(m_treectrl, 1, wxEXPAND);
+	m_icons = new wxImageList(16, 16, true, 1);
+	// Index of the last icon inserted into $self->{icons}.
+	m_icon_count = -1;
+	m_treectrl->AssignImageList(m_icons);
+	m_treectrl->AddRoot("root");
+	m_treectrl->SetIndent(0);
+	m_disable_tree_sel_changed_event = 0;
+
+	m_treectrl->Bind(wxEVT_TREE_SEL_CHANGED, &Tab::OnTreeSelChange, this);
+	m_treectrl->Bind(wxEVT_KEY_DOWN, &Tab::OnKeyDown, this);
+
+	m_presets_choice->Bind(wxEVT_COMBOBOX, ([this](wxCommandEvent e){
+		//! Because of The MSW and GTK version of wxBitmapComboBox derived from wxComboBox, 
+		//! but the OSX version derived from wxOwnerDrawnCombo, instead of:
+		//! select_preset(m_presets_choice->GetStringSelection().ToStdString()); 
+		//! we doing next:
+		int selected_item = m_presets_choice->GetSelection();
+		if (selected_item >= 0){
+			std::string selected_string = m_presets_choice->GetString(selected_item).ToUTF8().data();
+			select_preset(selected_string);
+		}
+	}));
+
+	m_btn_save_preset->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e){ save_preset(); }));
+	m_btn_delete_preset->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e){ delete_preset(); }));
+	m_btn_hide_incompatible_presets->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e){
+		toggle_show_hide_incompatible();
+	}));
+
+	// Initialize the DynamicPrintConfig by default keys/values.
+	build();
+	rebuild_page_tree();
+	update();
+}
+
+PageShp Tab::add_options_page(wxString title, std::string icon, bool is_extruder_pages/* = false*/)
+{
+	// Index of icon in an icon list $self->{icons}.
+	auto icon_idx = 0;
+	if (!icon.empty()) {
+		try { icon_idx = m_icon_index.at(icon);}
+		catch (std::out_of_range e) { icon_idx = -1; }
+		if (icon_idx == -1) {
+			// Add a new icon to the icon list.
+			const auto img_icon = new wxIcon(wxString::FromUTF8(Slic3r::var(icon).c_str()), wxBITMAP_TYPE_PNG);
+			m_icons->Add(*img_icon);
+			icon_idx = ++m_icon_count;
+			m_icon_index[icon] = icon_idx;
+		}
+	}
+	// Initialize the page.
+	PageShp page(new Page(this, title, icon_idx));
+	page->SetScrollbars(1, 1, 1, 1);
+	page->Hide();
+	m_hsizer->Add(page.get(), 1, wxEXPAND | wxLEFT, 5);
+	if (!is_extruder_pages) 
+		m_pages.push_back(page);
+
+	page->set_config(m_config);
+	return page;
+}
+
+// Update the combo box label of the selected preset based on its "dirty" state,
+// comparing the selected preset config with $self->{config}.
+void Tab::update_dirty(){
+	m_presets->update_dirty_ui(m_presets_choice);
+	on_presets_changed();
+}
+
+void Tab::update_tab_ui()
+{
+	m_presets->update_tab_ui(m_presets_choice, m_show_incompatible_presets);
+}
+
+// Load a provied DynamicConfig into the tab, modifying the active preset.
+// This could be used for example by setting a Wipe Tower position by interactive manipulation in the 3D view.
+void Tab::load_config(DynamicPrintConfig config)
+{
+	bool modified = 0;
+	boost::any value;
+	for(auto opt_key : m_config->diff(config)) {
+		switch ( config.def()->get(opt_key)->type ){
+		case coFloatOrPercent:
+			value = config.option<ConfigOptionFloatOrPercent>(opt_key)->value;
+			break;
+		case coPercent:
+			value = config.option<ConfigOptionPercent>(opt_key)->value;
+			break;
+		case coFloat:
+			value = config.opt_float(opt_key);
+			break;
+		case coString:
+			value = config.opt_string(opt_key);
+			break;
+		case coPercents:
+			value = config.option<ConfigOptionPercents>(opt_key)->values.at(0);
+			break;
+		case coFloats:
+			value = config.opt_float(opt_key, 0);
+			break;
+		case coStrings:
+			if (config.option<ConfigOptionStrings>(opt_key)->values.empty())
+				value = "";
+			else
+				value = config.opt_string(opt_key, static_cast<unsigned int>(0));
+			break;
+		case coBool:
+			value = config.opt_bool(opt_key);
+			break;
+		case coBools:
+			value = config.opt_bool(opt_key, 0);
+			break;
+		case coInt:
+			value = config.opt_int(opt_key);
+			break;
+		case coInts:
+			value = config.opt_int(opt_key, 0);
+			break;
+		case coEnum:{
+			if (opt_key.compare("external_fill_pattern") == 0 ||
+				opt_key.compare("fill_pattern") == 0)
+				value = config.option<ConfigOptionEnum<InfillPattern>>(opt_key)->value;
+			else if (opt_key.compare("gcode_flavor") == 0)
+				value = config.option<ConfigOptionEnum<GCodeFlavor>>(opt_key)->value;
+			else if (opt_key.compare("support_material_pattern") == 0)
+				value = config.option<ConfigOptionEnum<SupportMaterialPattern>>(opt_key)->value;
+			else if (opt_key.compare("seam_position") == 0)
+				value = config.option<ConfigOptionEnum<SeamPosition>>(opt_key)->value;
+		}
+			break;
+		case coPoints:
+			break;
+		case coNone:
+			break;
+		default:
+			break;
+		}
+		change_opt_value(*m_config, opt_key, value);
+		modified = 1;
+	}
+	if (modified) {
+		update_dirty();
+		//# Initialize UI components with the config values.
+		reload_config();
+		update();
+	}
+}
+
+// Reload current $self->{config} (aka $self->{presets}->edited_preset->config) into the UI fields.
+void Tab::reload_config(){
+	Freeze();
+	for (auto page : m_pages)
+		page->reload_config();
+ 	Thaw();
+}
+
+Field* Tab::get_field(t_config_option_key opt_key, int opt_index/* = -1*/) const
+{
+	Field* field = nullptr;
+	for (auto page : m_pages){
+		field = page->get_field(opt_key, opt_index);
+		if (field != nullptr)
+			return field;
+	}
+	return field;
+}
+
+// Set a key/value pair on this page. Return true if the value has been modified.
+// Currently used for distributing extruders_count over preset pages of Slic3r::GUI::Tab::Printer
+// after a preset is loaded.
+bool Tab::set_value(t_config_option_key opt_key, boost::any value){
+	bool changed = false;
+	for(auto page: m_pages) {
+		if (page->set_value(opt_key, value))
+		changed = true;
+	}
+	return changed;
+}
+
+// To be called by custom widgets, load a value into a config,
+// update the preset selection boxes (the dirty flags)
+void Tab::load_key_value(std::string opt_key, boost::any value)
+{
+	change_opt_value(*m_config, opt_key, value);
+	// Mark the print & filament enabled if they are compatible with the currently selected preset.
+	if (opt_key.compare("compatible_printers") == 0) {
+		m_preset_bundle->update_compatible_with_printer(0);
+	} 
+	m_presets->update_dirty_ui(m_presets_choice);
+	on_presets_changed();
+	update();
+}
+
+extern wxFrame *g_wxMainFrame;
+
+void Tab::on_value_change(std::string opt_key, boost::any value)
+{
+	if (m_event_value_change > 0) {
+		wxCommandEvent event(m_event_value_change);
+		std::string str_out = opt_key + " " + m_name;
+		event.SetString(str_out);
+		if (opt_key == "extruders_count")
+		{
+			int val = boost::any_cast<size_t>(value);
+			event.SetInt(val);
+		}
+		g_wxMainFrame->ProcessWindowEvent(event);
+	}
+	update();
+}
+
+// Call a callback to update the selection of presets on the platter:
+// To update the content of the selection boxes,
+// to update the filament colors of the selection boxes,
+// to update the "dirty" flags of the selection boxes,
+// to uddate number of "filament" selection boxes when the number of extruders change.
+void Tab::on_presets_changed()
+{
+	if (m_event_presets_changed > 0) {
+		wxCommandEvent event(m_event_presets_changed);
+		event.SetString(m_name);
+		g_wxMainFrame->ProcessWindowEvent(event);
+	}
+}
+
+void Tab::reload_compatible_printers_widget()
+{
+	bool has_any = !m_config->option<ConfigOptionStrings>("compatible_printers")->values.empty();
+	has_any ? m_compatible_printers_btn->Enable() : m_compatible_printers_btn->Disable();
+	m_compatible_printers_checkbox->SetValue(!has_any);
+	get_field("compatible_printers_condition")->toggle(!has_any);
+}
+
+void TabPrint::build()
+{
+	m_presets = &m_preset_bundle->prints;
+	m_config = &m_presets->get_edited_preset().config;
+
+	auto page = add_options_page(_L("Layers and perimeters"), "layers.png");
+		auto optgroup = page->new_optgroup(_L("Layer height"));
+		optgroup->append_single_option_line("layer_height");
+		optgroup->append_single_option_line("first_layer_height");
+
+		optgroup = page->new_optgroup(_L("Vertical shells"));
+		optgroup->append_single_option_line("perimeters");
+		optgroup->append_single_option_line("spiral_vase");
+
+		Line line { "", "" };
+		line.full_width = 1;
+		line.widget = [this](wxWindow* parent) {
+			return description_line_widget(parent, &m_recommended_thin_wall_thickness_description_line);
+		};
+		optgroup->append_line(line);
+
+		optgroup = page->new_optgroup(_L("Horizontal shells"));
+		line = { _L("Solid layers"), "" };
+		line.append_option(optgroup->get_option("top_solid_layers"));
+		line.append_option(optgroup->get_option("bottom_solid_layers"));
+		optgroup->append_line(line);
+
+		optgroup = page->new_optgroup(_L("Quality (slower slicing)"));
+		optgroup->append_single_option_line("extra_perimeters");
+		optgroup->append_single_option_line("ensure_vertical_shell_thickness");
+		optgroup->append_single_option_line("avoid_crossing_perimeters");
+		optgroup->append_single_option_line("thin_walls");
+		optgroup->append_single_option_line("overhangs");
+
+		optgroup = page->new_optgroup(_L("Advanced"));
+		optgroup->append_single_option_line("seam_position");
+		optgroup->append_single_option_line("external_perimeters_first");
+
+	page = add_options_page(_L("Infill"), "infill.png");
+		optgroup = page->new_optgroup(_L("Infill"));
+		optgroup->append_single_option_line("fill_density");
+		optgroup->append_single_option_line("fill_pattern");
+		optgroup->append_single_option_line("external_fill_pattern");
+
+		optgroup = page->new_optgroup(_L("Reducing printing time"));
+		optgroup->append_single_option_line("infill_every_layers");
+		optgroup->append_single_option_line("infill_only_where_needed");
+
+		optgroup = page->new_optgroup(_L("Advanced"));
+		optgroup->append_single_option_line("solid_infill_every_layers");
+		optgroup->append_single_option_line("fill_angle");
+		optgroup->append_single_option_line("solid_infill_below_area");
+		optgroup->append_single_option_line("bridge_angle");
+		optgroup->append_single_option_line("only_retract_when_crossing_perimeters");
+		optgroup->append_single_option_line("infill_first");
+
+	page = add_options_page(_L("Skirt and brim"), "box.png");
+		optgroup = page->new_optgroup(_L("Skirt"));
+		optgroup->append_single_option_line("skirts");
+		optgroup->append_single_option_line("skirt_distance");
+		optgroup->append_single_option_line("skirt_height");
+		optgroup->append_single_option_line("min_skirt_length");
+
+		optgroup = page->new_optgroup(_L("Brim"));
+		optgroup->append_single_option_line("brim_width");
+
+	page = add_options_page(_L("Support material"), "building.png");
+		optgroup = page->new_optgroup(_L("Support material"));
+		optgroup->append_single_option_line("support_material");
+		optgroup->append_single_option_line("support_material_threshold");
+		optgroup->append_single_option_line("support_material_enforce_layers");
+
+		optgroup = page->new_optgroup(_L("Raft"));
+		optgroup->append_single_option_line("raft_layers");
+//		# optgroup->append_single_option_line(get_option_("raft_contact_distance");
+
+		optgroup = page->new_optgroup(_L("Options for support material and raft"));
+		optgroup->append_single_option_line("support_material_contact_distance");
+		optgroup->append_single_option_line("support_material_pattern");
+		optgroup->append_single_option_line("support_material_with_sheath");
+		optgroup->append_single_option_line("support_material_spacing");
+		optgroup->append_single_option_line("support_material_angle");
+		optgroup->append_single_option_line("support_material_interface_layers");
+		optgroup->append_single_option_line("support_material_interface_spacing");
+		optgroup->append_single_option_line("support_material_interface_contact_loops");
+		optgroup->append_single_option_line("support_material_buildplate_only");
+		optgroup->append_single_option_line("support_material_xy_spacing");
+		optgroup->append_single_option_line("dont_support_bridges");
+		optgroup->append_single_option_line("support_material_synchronize_layers");
+
+	page = add_options_page(_L("Speed"), "time.png");
+		optgroup = page->new_optgroup(_L("Speed for print moves"));
+		optgroup->append_single_option_line("perimeter_speed");
+		optgroup->append_single_option_line("small_perimeter_speed");
+		optgroup->append_single_option_line("external_perimeter_speed");
+		optgroup->append_single_option_line("infill_speed");
+		optgroup->append_single_option_line("solid_infill_speed");
+		optgroup->append_single_option_line("top_solid_infill_speed");
+		optgroup->append_single_option_line("support_material_speed");
+		optgroup->append_single_option_line("support_material_interface_speed");
+		optgroup->append_single_option_line("bridge_speed");
+		optgroup->append_single_option_line("gap_fill_speed");
+
+		optgroup = page->new_optgroup(_L("Speed for non-print moves"));
+		optgroup->append_single_option_line("travel_speed");
+
+		optgroup = page->new_optgroup(_L("Modifiers"));
+		optgroup->append_single_option_line("first_layer_speed");
+
+		optgroup = page->new_optgroup(_L("Acceleration control (advanced)"));
+		optgroup->append_single_option_line("perimeter_acceleration");
+		optgroup->append_single_option_line("infill_acceleration");
+		optgroup->append_single_option_line("bridge_acceleration");
+		optgroup->append_single_option_line("first_layer_acceleration");
+		optgroup->append_single_option_line("default_acceleration");
+
+		optgroup = page->new_optgroup(_L("Autospeed (advanced)"));
+		optgroup->append_single_option_line("max_print_speed");
+		optgroup->append_single_option_line("max_volumetric_speed");
+		optgroup->append_single_option_line("max_volumetric_extrusion_rate_slope_positive");
+		optgroup->append_single_option_line("max_volumetric_extrusion_rate_slope_negative");
+
+	page = add_options_page(_L("Multiple Extruders"), "funnel.png");
+		optgroup = page->new_optgroup(_L("Extruders"));
+		optgroup->append_single_option_line("perimeter_extruder");
+		optgroup->append_single_option_line("infill_extruder");
+		optgroup->append_single_option_line("solid_infill_extruder");
+		optgroup->append_single_option_line("support_material_extruder");
+		optgroup->append_single_option_line("support_material_interface_extruder");
+
+		optgroup = page->new_optgroup(_L("Ooze prevention"));
+		optgroup->append_single_option_line("ooze_prevention");
+		optgroup->append_single_option_line("standby_temperature_delta");
+
+		optgroup = page->new_optgroup(_L("Wipe tower"));
+		optgroup->append_single_option_line("wipe_tower");
+		optgroup->append_single_option_line("wipe_tower_x");
+		optgroup->append_single_option_line("wipe_tower_y");
+		optgroup->append_single_option_line("wipe_tower_width");
+		optgroup->append_single_option_line("wipe_tower_per_color_wipe");
+
+		optgroup = page->new_optgroup(_L("Advanced"));
+		optgroup->append_single_option_line("interface_shells");
+
+	page = add_options_page(_L("Advanced"), "wrench.png");
+		optgroup = page->new_optgroup(_L("Extrusion width"), 180);
+		optgroup->append_single_option_line("extrusion_width");
+		optgroup->append_single_option_line("first_layer_extrusion_width");
+		optgroup->append_single_option_line("perimeter_extrusion_width");
+		optgroup->append_single_option_line("external_perimeter_extrusion_width");
+		optgroup->append_single_option_line("infill_extrusion_width");
+		optgroup->append_single_option_line("solid_infill_extrusion_width");
+		optgroup->append_single_option_line("top_infill_extrusion_width");
+		optgroup->append_single_option_line("support_material_extrusion_width");
+
+		optgroup = page->new_optgroup(_L("Overlap"));
+		optgroup->append_single_option_line("infill_overlap");
+
+		optgroup = page->new_optgroup(_L("Flow"));
+		optgroup->append_single_option_line("bridge_flow_ratio");
+
+		optgroup = page->new_optgroup(_L("Other"));
+		optgroup->append_single_option_line("clip_multipart_objects");
+		optgroup->append_single_option_line("elefant_foot_compensation");
+		optgroup->append_single_option_line("xy_size_compensation");
+//		#            optgroup->append_single_option_line("threads");
+		optgroup->append_single_option_line("resolution");
+
+	page = add_options_page(_L("Output options"), "page_white_go.png");
+		optgroup = page->new_optgroup(_L("Sequential printing"));
+		optgroup->append_single_option_line("complete_objects");
+		line = { _L("Extruder clearance (mm)"), "" };
+		Option option = optgroup->get_option("extruder_clearance_radius");
+		option.opt.width = 60;
+		line.append_option(option);
+		option = optgroup->get_option("extruder_clearance_height");
+		option.opt.width = 60;
+		line.append_option(option);
+		optgroup->append_line(line);
+
+		optgroup = page->new_optgroup(_L("Output file"));
+		optgroup->append_single_option_line("gcode_comments");
+		option = optgroup->get_option("output_filename_format");
+		option.opt.full_width = true;
+		optgroup->append_single_option_line(option);
+
+		optgroup = page->new_optgroup(_L("Post-processing scripts"), 0);	
+		option = optgroup->get_option("post_process");
+		option.opt.full_width = true;
+		option.opt.height = 50;
+		optgroup->append_single_option_line(option);
+
+	page = add_options_page(_L("Notes"), "note.png");
+		optgroup = page->new_optgroup(_L("Notes"), 0);						
+		option = optgroup->get_option("notes");
+		option.opt.full_width = true;
+		option.opt.height = 250;
+		optgroup->append_single_option_line(option);
+
+	page = add_options_page(_L("Dependencies"), "wrench.png");
+		optgroup = page->new_optgroup(_L("Profile dependencies"));
+		line = { _L("Compatible printers"), "" };
+		line.widget = [this](wxWindow* parent){
+			return compatible_printers_widget(parent, &m_compatible_printers_checkbox, &m_compatible_printers_btn);
+		};
+		optgroup->append_line(line);
+
+		option = optgroup->get_option("compatible_printers_condition");
+		option.opt.full_width = true;
+		optgroup->append_single_option_line(option);
+}
+
+// Reload current config (aka presets->edited_preset->config) into the UI fields.
+void TabPrint::reload_config(){
+	reload_compatible_printers_widget();
+	Tab::reload_config();
+}
+
+void TabPrint::update()
+{
+	Freeze();
+
+	if ( m_config->opt_bool("spiral_vase") && 
+		!(m_config->opt_int("perimeters") == 1 && m_config->opt_int("top_solid_layers") == 0 &&
+			m_config->option<ConfigOptionPercent>("fill_density")->value == 0)) {
+		wxString msg_text = _L("The Spiral Vase mode requires:\n"
+			"- one perimeter\n"
+ 			"- no top solid layers\n"
+ 			"- 0% fill density\n"
+ 			"- no support material\n"
+ 			"- no ensure_vertical_shell_thickness\n"
+  			"\nShall I adjust those settings in order to enable Spiral Vase?");
+		auto dialog = new wxMessageDialog(parent(), msg_text, _L("Spiral Vase"), wxICON_WARNING | wxYES | wxNO);
+		DynamicPrintConfig new_conf = *m_config;
+ 		if (dialog->ShowModal() == wxID_YES) {
+			new_conf.set_key_value("perimeters", new ConfigOptionInt(1));
+			new_conf.set_key_value("top_solid_layers", new ConfigOptionInt(0));
+			new_conf.set_key_value("fill_density", new ConfigOptionPercent(0));
+			new_conf.set_key_value("support_material", new ConfigOptionBool(false));
+			new_conf.set_key_value("ensure_vertical_shell_thickness", new ConfigOptionBool(false));
+		}
+		else {
+			new_conf.set_key_value("spiral_vase", new ConfigOptionBool(false));
+		}
+ 		load_config(new_conf);
+	}
+
+	auto first_layer_height = m_config->option<ConfigOptionFloatOrPercent>("first_layer_height")->value;
+	auto layer_height = m_config->opt_float("layer_height");
+	if (m_config->opt_bool("wipe_tower") &&
+		( first_layer_height != 0.2 || layer_height < 0.15 || layer_height > 0.35)) {
+		wxString msg_text = _L("The Wipe Tower currently supports only:\n"
+			"- first layer height 0.2mm\n"
+			"- layer height from 0.15mm to 0.35mm\n"
+			"\nShall I adjust those settings in order to enable the Wipe Tower?");
+		auto dialog = new wxMessageDialog(parent(), msg_text, _L("Wipe Tower"), wxICON_WARNING | wxYES | wxNO);
+		DynamicPrintConfig new_conf = *m_config;
+		if (dialog->ShowModal() == wxID_YES) {
+			const auto &val = *m_config->option<ConfigOptionFloatOrPercent>("first_layer_height");
+			new_conf.set_key_value("first_layer_height", new ConfigOptionFloatOrPercent(0.2, val.percent));
+
+			if (m_config->opt_float("layer_height") < 0.15) new_conf.set_key_value("layer_height", new ConfigOptionFloat(0.15)) ;
+			if (m_config->opt_float("layer_height") > 0.35) new_conf.set_key_value("layer_height", new ConfigOptionFloat(0.35));
+		}
+		else 
+			new_conf.set_key_value("wipe_tower", new ConfigOptionBool(false));
+		load_config(new_conf);
+	}
+
+	if (m_config->opt_bool("wipe_tower") && m_config->opt_bool("support_material") && 
+		m_config->opt_float("support_material_contact_distance") > 0. &&
+		(m_config->opt_int("support_material_extruder") != 0 || m_config->opt_int("support_material_interface_extruder") != 0)) {
+		wxString msg_text = _L("The Wipe Tower currently supports the non-soluble supports only\n"
+			"if they are printed with the current extruder without triggering a tool change.\n"
+			"(both support_material_extruder and support_material_interface_extruder need to be set to 0).\n"
+			"\nShall I adjust those settings in order to enable the Wipe Tower?");
+		auto dialog = new wxMessageDialog(parent(), msg_text, _L("Wipe Tower"), wxICON_WARNING | wxYES | wxNO);
+		DynamicPrintConfig new_conf = *m_config;
+		if (dialog->ShowModal() == wxID_YES) {
+			new_conf.set_key_value("support_material_extruder", new ConfigOptionInt(0));
+			new_conf.set_key_value("support_material_interface_extruder", new ConfigOptionInt(0));
+		}
+		else 
+			new_conf.set_key_value("wipe_tower", new ConfigOptionBool(false));
+		load_config(new_conf);
+	}
+
+	if (m_config->opt_bool("wipe_tower") && m_config->opt_bool("support_material") && 
+		m_config->opt_float("support_material_contact_distance") == 0 &&
+		!m_config->opt_bool("support_material_synchronize_layers")) {
+		wxString msg_text = _L("For the Wipe Tower to work with the soluble supports, the support layers\n"
+			"need to be synchronized with the object layers.\n"
+			"\nShall I synchronize support layers in order to enable the Wipe Tower?");
+		auto dialog = new wxMessageDialog(parent(), msg_text, _L("Wipe Tower"), wxICON_WARNING | wxYES | wxNO);
+		DynamicPrintConfig new_conf = *m_config;
+		if (dialog->ShowModal() == wxID_YES) {
+			new_conf.set_key_value("support_material_synchronize_layers", new ConfigOptionBool(true));
+		}
+		else
+			new_conf.set_key_value("wipe_tower", new ConfigOptionBool(false));
+		load_config(new_conf);
+	}
+
+	if (m_config->opt_bool("support_material")) {
+		// Ask only once.
+		if (!m_support_material_overhangs_queried) {
+			m_support_material_overhangs_queried = true;
+			if (!m_config->opt_bool("overhangs")/* != 1*/) {
+				wxString msg_text = _L("Supports work better, if the following feature is enabled:\n"
+					"- Detect bridging perimeters\n"
+					"\nShall I adjust those settings for supports?");
+				auto dialog = new wxMessageDialog(parent(), msg_text, _L("Support Generator"), wxICON_WARNING | wxYES | wxNO | wxCANCEL);
+				DynamicPrintConfig new_conf = *m_config;
+				auto answer = dialog->ShowModal();
+				if (answer == wxID_YES) {
+					// Enable "detect bridging perimeters".
+					new_conf.set_key_value("overhangs", new ConfigOptionBool(true));
+				} else if(answer == wxID_NO) {
+					// Do nothing, leave supports on and "detect bridging perimeters" off.
+				} else if(answer == wxID_CANCEL) {
+					// Disable supports.
+					new_conf.set_key_value("support_material", new ConfigOptionBool(false));
+					m_support_material_overhangs_queried = false;
+				}
+				load_config(new_conf);
+			}
+		}
+	}
+	else {
+		m_support_material_overhangs_queried = false;
+	}
+
+	if (m_config->option<ConfigOptionPercent>("fill_density")->value == 100) {
+		auto fill_pattern = m_config->option<ConfigOptionEnum<InfillPattern>>("fill_pattern")->value;
+		std::string str_fill_pattern = "";
+		t_config_enum_values map_names = m_config->option<ConfigOptionEnum<InfillPattern>>("fill_pattern")->get_enum_values();
+		for (auto it:map_names) {
+			if (fill_pattern == it.second) {
+				str_fill_pattern = it.first;
+				break;
+			}
+		}
+		if (!str_fill_pattern.empty()){
+			auto external_fill_pattern = m_config->def()->get("external_fill_pattern")->enum_values;
+			bool correct_100p_fill = false;
+			for (auto fill : external_fill_pattern)
+			{
+				if (str_fill_pattern.compare(fill) == 0)
+					correct_100p_fill = true;
+			}
+			// get fill_pattern name from enum_labels for using this one at dialog_msg
+			str_fill_pattern = m_config->def()->get("fill_pattern")->enum_labels[fill_pattern];
+			if (!correct_100p_fill){
+				wxString msg_text = _L("The ") + str_fill_pattern + _L(" infill pattern is not supposed to work at 100% density.\n"
+					"\nShall I switch to rectilinear fill pattern?");
+				auto dialog = new wxMessageDialog(parent(), msg_text, _L("Infill"), wxICON_WARNING | wxYES | wxNO);
+				DynamicPrintConfig new_conf = *m_config;
+				if (dialog->ShowModal() == wxID_YES) {
+					new_conf.set_key_value("fill_pattern", new ConfigOptionEnum<InfillPattern>(ipRectilinear));
+					new_conf.set_key_value("fill_density", new ConfigOptionPercent(100));
+				}
+				else
+					new_conf.set_key_value("fill_density", new ConfigOptionPercent(40));
+				load_config(new_conf);
+			}
+		}
+	}
+
+	bool have_perimeters = m_config->opt_int("perimeters") > 0;
+	std::vector<std::string> vec_enable = { "extra_perimeters", "ensure_vertical_shell_thickness", "thin_walls", "overhangs",
+											"seam_position", "external_perimeters_first", "external_perimeter_extrusion_width",
+											"perimeter_speed", "small_perimeter_speed", "external_perimeter_speed" };
+	for (auto el : vec_enable)
+		get_field(el)->toggle(have_perimeters);
+
+	bool have_infill = m_config->option<ConfigOptionPercent>("fill_density")->value > 0;
+	vec_enable.resize(0);
+	vec_enable = {	"fill_pattern", "infill_every_layers", "infill_only_where_needed", 
+					"solid_infill_every_layers", "solid_infill_below_area", "infill_extruder"};
+	// infill_extruder uses the same logic as in Print::extruders()
+	for (auto el : vec_enable)
+		get_field(el)->toggle(have_infill);
+
+	bool have_solid_infill = m_config->opt_int("top_solid_layers") > 0 || m_config->opt_int("bottom_solid_layers") > 0;
+	vec_enable.resize(0);
+	vec_enable = { "external_fill_pattern", "infill_first", "solid_infill_extruder",
+		"solid_infill_extrusion_width", "solid_infill_speed" };
+	// solid_infill_extruder uses the same logic as in Print::extruders()
+	for (auto el : vec_enable)
+		get_field(el)->toggle(have_solid_infill);
+
+	vec_enable.resize(0);
+	vec_enable = { "fill_angle", "bridge_angle", "infill_extrusion_width", 
+					"infill_speed", "bridge_speed" };
+	for (auto el : vec_enable)
+		get_field(el)->toggle(have_infill || have_solid_infill);
+
+	get_field("gap_fill_speed")->toggle(have_perimeters && have_infill);
+
+	bool have_top_solid_infill = m_config->opt_int("top_solid_layers") > 0;
+	vec_enable.resize(0);
+	vec_enable = { "top_infill_extrusion_width", "top_solid_infill_speed" };
+	for (auto el : vec_enable)
+		get_field(el)->toggle(have_top_solid_infill);
+
+	bool have_default_acceleration = m_config->opt_float("default_acceleration") > 0;
+	vec_enable.resize(0);
+	vec_enable = {	"perimeter_acceleration", "infill_acceleration", 
+					"bridge_acceleration", "first_layer_acceleration"};
+	for (auto el : vec_enable)
+		get_field(el)->toggle(have_default_acceleration);
+
+	bool have_skirt = m_config->opt_int("skirts") > 0 || m_config->opt_float("min_skirt_length") > 0;
+	vec_enable.resize(0);
+	vec_enable = {	"skirt_distance", "skirt_height"};
+	for (auto el : vec_enable)
+		get_field(el)->toggle(have_skirt);
+
+	bool have_brim = m_config->opt_float("brim_width") > 0;
+	// perimeter_extruder uses the same logic as in Print::extruders()
+	get_field("perimeter_extruder")->toggle(have_perimeters || have_brim);
+
+	bool have_raft = m_config->opt_int("raft_layers") > 0;
+	bool have_support_material = m_config->opt_bool("support_material") || have_raft;
+	bool have_support_interface = m_config->opt_int("support_material_interface_layers") > 0;
+	bool have_support_soluble = have_support_material && m_config->opt_float("support_material_contact_distance") == 0;
+	vec_enable.resize(0);
+	vec_enable = {	"support_material_threshold", "support_material_pattern", "support_material_with_sheath",
+					"support_material_spacing", "support_material_angle", "support_material_interface_layers", 
+					"dont_support_bridges", "support_material_extrusion_width", "support_material_contact_distance", 
+					"support_material_xy_spacing"};
+	for (auto el : vec_enable)
+		get_field(el)->toggle(have_support_material);
+
+	vec_enable.resize(0);
+	vec_enable = {	"support_material_interface_spacing", "support_material_interface_extruder", 
+					"support_material_interface_speed", "support_material_interface_contact_loops"};
+	for (auto el : vec_enable)
+		get_field(el)->toggle(have_support_material && have_support_interface);
+	get_field("support_material_synchronize_layers")->toggle(have_support_soluble);
+
+	get_field("perimeter_extrusion_width")->toggle(have_perimeters || have_skirt || have_brim);
+	get_field("support_material_extruder")->toggle(have_support_material || have_skirt);
+	get_field("support_material_speed")->toggle(have_support_material || have_brim || have_skirt);
+
+	bool have_sequential_printing = m_config->opt_bool("complete_objects");
+	vec_enable.resize(0);
+	vec_enable = {	"extruder_clearance_radius", "extruder_clearance_height"};
+	for (auto el : vec_enable)
+		get_field(el)->toggle(have_sequential_printing);
+
+	bool have_ooze_prevention = m_config->opt_bool("ooze_prevention");
+	get_field("standby_temperature_delta")->toggle(have_ooze_prevention);
+
+	bool have_wipe_tower = m_config->opt_bool("wipe_tower");
+	vec_enable.resize(0);
+	vec_enable = {	"wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_per_color_wipe"};
+	for (auto el : vec_enable)
+		get_field(el)->toggle(have_wipe_tower);
+
+	m_recommended_thin_wall_thickness_description_line->SetText(
+		PresetHints::recommended_thin_wall_thickness(*m_preset_bundle));
+
+	Thaw();
+}
+
+void TabPrint::OnActivate()
+{
+	m_recommended_thin_wall_thickness_description_line->SetText(PresetHints::recommended_thin_wall_thickness(*m_preset_bundle));
+}
+
+void TabFilament::build()
+{
+	m_presets = &m_preset_bundle->filaments;
+	m_config = &m_preset_bundle->filaments.get_edited_preset().config;
+
+	auto page = add_options_page(_L("Filament"), "spool.png");
+		auto optgroup = page->new_optgroup(_L("Filament"));
+		optgroup->append_single_option_line("filament_colour");
+		optgroup->append_single_option_line("filament_diameter");
+		optgroup->append_single_option_line("extrusion_multiplier");
+		optgroup->append_single_option_line("filament_density");
+		optgroup->append_single_option_line("filament_cost");
+
+		optgroup = page->new_optgroup(_L("Temperature") +" (\u00B0C)"); // degree sign
+		Line line = { _L("Extruder"), "" };
+		line.append_option(optgroup->get_option("first_layer_temperature"));
+		line.append_option(optgroup->get_option("temperature"));
+		optgroup->append_line(line);
+
+		line = { _L("Bed"), "" };
+		line.append_option(optgroup->get_option("first_layer_bed_temperature"));
+		line.append_option(optgroup->get_option("bed_temperature"));
+		optgroup->append_line(line);
+
+	page = add_options_page(_L("Cooling"), "hourglass.png");
+		optgroup = page->new_optgroup(_L("Enable"));
+		optgroup->append_single_option_line("fan_always_on");
+		optgroup->append_single_option_line("cooling");
+
+		line = { "", "" }; 
+		line.full_width = 1;
+		line.widget = [this](wxWindow* parent) {
+			return description_line_widget(parent, &m_cooling_description_line);
+		};
+		optgroup->append_line(line);
+
+		optgroup = page->new_optgroup(_L("Fan settings"));
+		line = {_L("Fan speed"),""};
+		line.append_option(optgroup->get_option("min_fan_speed"));
+		line.append_option(optgroup->get_option("max_fan_speed"));
+		optgroup->append_line(line);
+
+		optgroup->append_single_option_line("bridge_fan_speed");
+		optgroup->append_single_option_line("disable_fan_first_layers");
+
+		optgroup = page->new_optgroup(_L("Cooling thresholds"), 250);
+		optgroup->append_single_option_line("fan_below_layer_time");
+		optgroup->append_single_option_line("slowdown_below_layer_time");
+		optgroup->append_single_option_line("min_print_speed");
+
+	page = add_options_page(_L("Advanced"), "wrench.png");
+		optgroup = page->new_optgroup(_L("Filament properties"));
+		optgroup->append_single_option_line("filament_type");
+		optgroup->append_single_option_line("filament_soluble");
+
+		optgroup = page->new_optgroup(_L("Print speed override"));
+		optgroup->append_single_option_line("filament_max_volumetric_speed");
+
+		line = {"",""};
+		line.full_width = 1;
+		line.widget = [this](wxWindow* parent) {
+			return description_line_widget(parent, &m_volumetric_speed_description_line);
+		};
+		optgroup->append_line(line);
+
+	page = add_options_page(_L("Custom G-code"), "cog.png");
+		optgroup = page->new_optgroup(_L("Start G-code"), 0);
+		Option option = optgroup->get_option("start_filament_gcode");
+		option.opt.full_width = true;
+		option.opt.height = 150;
+		optgroup->append_single_option_line(option);
+
+		optgroup = page->new_optgroup(_L("End G-code"), 0);
+		option = optgroup->get_option("end_filament_gcode");
+		option.opt.full_width = true;
+		option.opt.height = 150;
+		optgroup->append_single_option_line(option);
+
+	page = add_options_page(_L("Notes"), "note.png");
+		optgroup = page->new_optgroup(_L("Notes"), 0);
+		optgroup->label_width = 0;
+		option = optgroup->get_option("filament_notes");
+		option.opt.full_width = true;
+		option.opt.height = 250;
+		optgroup->append_single_option_line(option);
+
+	page = add_options_page(_L("Dependencies"), "wrench.png");
+		optgroup = page->new_optgroup(_L("Profile dependencies"));
+		line = {_L("Compatible printers"), ""};
+		line.widget = [this](wxWindow* parent){
+			return compatible_printers_widget(parent, &m_compatible_printers_checkbox, &m_compatible_printers_btn);
+		};
+		optgroup->append_line(line);
+
+		option = optgroup->get_option("compatible_printers_condition");
+		option.opt.full_width = true;
+		optgroup->append_single_option_line(option);
+}
+
+// Reload current config (aka presets->edited_preset->config) into the UI fields.
+void TabFilament::reload_config(){
+	reload_compatible_printers_widget();
+	Tab::reload_config();
+}
+
+void TabFilament::update()
+{
+	wxString text = wxString::FromUTF8(PresetHints::cooling_description(m_presets->get_edited_preset()).c_str());
+	m_cooling_description_line->SetText(text);
+	text = wxString::FromUTF8(PresetHints::maximum_volumetric_flow_description(*m_preset_bundle).c_str());
+	m_volumetric_speed_description_line->SetText(text);
+
+	bool cooling = m_config->opt_bool("cooling", 0);
+	bool fan_always_on = cooling || m_config->opt_bool("fan_always_on", 0);
+
+	std::vector<std::string> vec_enable = { "max_fan_speed", "fan_below_layer_time", "slowdown_below_layer_time", "min_print_speed" };
+	for (auto el : vec_enable)
+		get_field(el)->toggle(cooling);
+
+	vec_enable.resize(0);
+	vec_enable = { "min_fan_speed", "disable_fan_first_layers" };
+	for (auto el : vec_enable)
+		get_field(el)->toggle(fan_always_on);
+}
+
+void TabFilament::OnActivate()
+{
+	m_volumetric_speed_description_line->SetText(PresetHints::maximum_volumetric_flow_description(*m_preset_bundle));
+}
+
+wxSizer* Tab::description_line_widget(wxWindow* parent, ogStaticText* *StaticText)
+{
+	*StaticText = new ogStaticText(parent, "");
+
+	auto font = (new wxSystemSettings)->GetFont(wxSYS_DEFAULT_GUI_FONT);
+	(*StaticText)->SetFont(font);
+
+	auto sizer = new wxBoxSizer(wxHORIZONTAL);
+	sizer->Add(*StaticText);
+	return sizer;
+}
+
+bool Tab::current_preset_is_dirty()
+{
+	return m_presets->current_is_dirty();
+}
+
+void TabPrinter::build()
+{
+	m_presets = &m_preset_bundle->printers;
+	m_config = &m_preset_bundle->printers.get_edited_preset().config;
+	auto default_config = m_preset_bundle->full_config();
+
+	auto   *nozzle_diameter = dynamic_cast<const ConfigOptionFloats*>(m_config->option("nozzle_diameter"));
+	m_extruders_count = nozzle_diameter->values.size();
+
+	auto page = add_options_page(_L("General"), "printer_empty.png");
+		auto optgroup = page->new_optgroup(_L("Size and coordinates"));
+
+		Line line{ _L("Bed shape"), "" };
+		line.widget = [this](wxWindow* parent){
+			auto btn = new wxButton(parent, wxID_ANY, _L("Set")+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
+//			btn->SetFont(Slic3r::GUI::small_font);
+			btn->SetBitmap(wxBitmap(wxString::FromUTF8(Slic3r::var("printer_empty.png").c_str()), wxBITMAP_TYPE_PNG));
+
+			auto sizer = new wxBoxSizer(wxHORIZONTAL);
+			sizer->Add(btn);
+
+			btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e)
+			{
+				auto dlg = new BedShapeDialog(this);
+				dlg->build_dialog(m_config->option<ConfigOptionPoints>("bed_shape"));
+				if (dlg->ShowModal() == wxID_OK)
+					load_key_value("bed_shape", dlg->GetValue());
+			}));
+
+			return sizer;
+		};
+		optgroup->append_line(line);
+		optgroup->append_single_option_line("z_offset");
+
+		optgroup = page->new_optgroup(_L("Capabilities"));
+		ConfigOptionDef def;
+			def.type =  coInt,
+			def.default_value = new ConfigOptionInt(1); 
+			def.label = _LU8("Extruders");
+			def.tooltip = _LU8("Number of extruders of the printer.");
+			def.min = 1;
+		Option option(def, "extruders_count");
+		optgroup->append_single_option_line(option);
+		optgroup->append_single_option_line("single_extruder_multi_material");
+
+		optgroup->m_on_change = [this, optgroup](t_config_option_key opt_key, boost::any value){
+			size_t extruders_count = boost::any_cast<int>(optgroup->get_value("extruders_count"));
+			wxTheApp->CallAfter([this, opt_key, value, extruders_count](){
+				if (opt_key.compare("extruders_count")==0) {
+					extruders_count_changed(extruders_count);
+					update_dirty();
+				}
+				else {
+					update_dirty();
+					on_value_change(opt_key, value);
+				}
+			});
+		};
+
+		if (!m_no_controller)
+		{
+		optgroup = page->new_optgroup(_L("USB/Serial connection"));
+			line = {_L("Serial port"), ""};
+			Option serial_port = optgroup->get_option("serial_port");
+			serial_port.side_widget = ([this](wxWindow* parent){
+				auto btn = new wxBitmapButton(parent, wxID_ANY, wxBitmap(wxString::FromUTF8(Slic3r::var("arrow_rotate_clockwise.png").c_str()), wxBITMAP_TYPE_PNG),
+					wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
+				btn->SetToolTip(_L("Rescan serial ports"));
+				auto sizer = new wxBoxSizer(wxHORIZONTAL);
+				sizer->Add(btn);
+
+				btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent e) {update_serial_ports(); });
+				return sizer;
+			});
+			auto serial_test = [this](wxWindow* parent){
+				auto btn = m_serial_test_btn = new wxButton(parent, wxID_ANY,
+					_L("Test"), wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
+//				btn->SetFont($Slic3r::GUI::small_font);
+				btn->SetBitmap(wxBitmap(wxString::FromUTF8(Slic3r::var("wrench.png").c_str()), wxBITMAP_TYPE_PNG));
+				auto sizer = new wxBoxSizer(wxHORIZONTAL);
+				sizer->Add(btn);
+
+				btn->Bind(wxEVT_BUTTON, [this, parent](wxCommandEvent e){
+					auto sender = new GCodeSender();					
+					auto res = sender->connect(
+						m_config->opt_string("serial_port"), 
+						m_config->opt_int("serial_speed")
+						);
+					if (res && sender->wait_connected()) {
+						show_info(parent, _L("Connection to printer works correctly."), _L("Success!"));
+					}
+					else {
+						show_error(parent, _L("Connection failed."));
+					}
+				});
+				return sizer;
+			};
+
+			line.append_option(serial_port);
+			line.append_option(optgroup->get_option("serial_speed"));
+			line.append_widget(serial_test);
+			optgroup->append_line(line);
+		}
+
+		optgroup = page->new_optgroup(_L("OctoPrint upload"));
+		// # append two buttons to the Host line
+		auto octoprint_host_browse = [this] (wxWindow* parent) {
+			auto btn = new wxButton(parent, wxID_ANY, _L("Browse")+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
+//			btn->SetFont($Slic3r::GUI::small_font);
+			btn->SetBitmap(wxBitmap(wxString::FromUTF8(Slic3r::var("zoom.png").c_str()), wxBITMAP_TYPE_PNG));
+			auto sizer = new wxBoxSizer(wxHORIZONTAL);
+			sizer->Add(btn);
+
+			if (m_is_disabled_button_browse) 
+				btn->Disable();
+
+			btn->Bind(wxEVT_BUTTON, [this, parent](wxCommandEvent e){
+				if (m_event_button_browse > 0){
+					wxCommandEvent event(m_event_button_browse);
+					event.SetString(_L("Button BROWSE was clicked!"));
+					g_wxMainFrame->ProcessWindowEvent(event);
+				}
+// 				// # look for devices
+// 				auto entries;
+// 				{
+// 					my $res = Net::Bonjour->new('http');
+// 					$res->discover;
+// 					$entries = [$res->entries];
+// 				}
+// 				if (@{$entries}) {
+// 					my $dlg = Slic3r::GUI::BonjourBrowser->new($self, $entries);
+// 					$self->_load_key_value('octoprint_host', $dlg->GetValue . ":".$dlg->GetPort)
+// 						if $dlg->ShowModal == wxID_OK;
+// 				}
+// 				else {
+// 					auto msg_window = new wxMessageDialog(parent, "No Bonjour device found", "Device Browser", wxOK | wxICON_INFORMATION);
+// 					msg_window->ShowModal();
+// 				}
+			});
+
+			return sizer;
+		};
+
+		auto octoprint_host_test = [this](wxWindow* parent) {
+			auto btn = m_octoprint_host_test_btn = new wxButton(parent, wxID_ANY, _L("Test"), 
+				wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
+//			btn->SetFont($Slic3r::GUI::small_font);
+			btn->SetBitmap(wxBitmap(wxString::FromUTF8(Slic3r::var("wrench.png").c_str()), wxBITMAP_TYPE_PNG));
+			auto sizer = new wxBoxSizer(wxHORIZONTAL);
+			sizer->Add(btn);
+
+			btn->Bind(wxEVT_BUTTON, [this, parent](wxCommandEvent e) {
+				if (m_event_button_test > 0){
+					wxCommandEvent event(m_event_button_test);
+					event.SetString(_L("Button TEST was clicked!"));
+					g_wxMainFrame->ProcessWindowEvent(event);
+				}
+// 				my $ua = LWP::UserAgent->new;
+// 				$ua->timeout(10);
+// 
+// 				my $res = $ua->get(
+// 					"http://".$self->{config}->octoprint_host . "/api/version",
+// 					'X-Api-Key' = > $self->{config}->octoprint_apikey,
+// 					);
+// 				if ($res->is_success) {
+// 					show_info(parent, "Connection to OctoPrint works correctly.", "Success!");
+// 				}
+// 				else {
+// 					show_error(parent, 
+// 						"I wasn't able to connect to OctoPrint (".$res->status_line . "). "
+// 						. "Check hostname and OctoPrint version (at least 1.1.0 is required).");
+// 				}
+ 			});
+			return sizer;
+		};
+
+		Line host_line = optgroup->create_single_option_line("octoprint_host");
+		host_line.append_widget(octoprint_host_browse);
+		host_line.append_widget(octoprint_host_test);
+		optgroup->append_line(host_line);
+		optgroup->append_single_option_line("octoprint_apikey");
+
+		optgroup = page->new_optgroup(_L("Firmware"));
+		optgroup->append_single_option_line("gcode_flavor");
+
+		optgroup = page->new_optgroup(_L("Advanced"));
+		optgroup->append_single_option_line("use_relative_e_distances");
+		optgroup->append_single_option_line("use_firmware_retraction");
+		optgroup->append_single_option_line("use_volumetric_e");
+		optgroup->append_single_option_line("variable_layer_height");
+
+	page = add_options_page(_L("Custom G-code"), "cog.png");
+		optgroup = page->new_optgroup(_L("Start G-code"), 0);
+		option = optgroup->get_option("start_gcode");
+		option.opt.full_width = true;
+		option.opt.height = 150;
+		optgroup->append_single_option_line(option);
+
+		optgroup = page->new_optgroup(_L("End G-code"), 0);
+		option = optgroup->get_option("end_gcode");
+		option.opt.full_width = true;
+		option.opt.height = 150;
+		optgroup->append_single_option_line(option);
+
+		optgroup = page->new_optgroup(_L("Before layer change G-code"), 0);
+		option = optgroup->get_option("before_layer_gcode");
+		option.opt.full_width = true;
+		option.opt.height = 150;
+		optgroup->append_single_option_line(option);
+
+		optgroup = page->new_optgroup(_L("After layer change G-code"), 0);
+		option = optgroup->get_option("layer_gcode");
+		option.opt.full_width = true;
+		option.opt.height = 150;
+		optgroup->append_single_option_line(option);
+
+		optgroup = page->new_optgroup(_L("Tool change G-code"), 0);
+		option = optgroup->get_option("toolchange_gcode");
+		option.opt.full_width = true;
+		option.opt.height = 150;
+		optgroup->append_single_option_line(option);
+
+		optgroup = page->new_optgroup(_L("Between objects G-code (for sequential printing)"), 0);
+		option = optgroup->get_option("between_objects_gcode");
+		option.opt.full_width = true;
+		option.opt.height = 150;
+		optgroup->append_single_option_line(option);
+	
+	page = add_options_page(_L("Notes"), "note.png");
+		optgroup = page->new_optgroup(_L("Notes"), 0);
+		option = optgroup->get_option("printer_notes");
+		option.opt.full_width = true;
+		option.opt.height = 250;
+		optgroup->append_single_option_line(option);
+
+	build_extruder_pages();
+
+	if (!m_no_controller)
+		update_serial_ports();
+}
+
+void TabPrinter::update_serial_ports(){
+	Field *field = get_field("serial_port");
+	Choice *choice = static_cast<Choice *>(field);
+	choice->set_values(scan_serial_ports());
+}
+
+void TabPrinter::extruders_count_changed(size_t extruders_count){
+	m_extruders_count = extruders_count;
+	m_preset_bundle->printers.get_edited_preset().set_num_extruders(extruders_count);
+	m_preset_bundle->update_multi_material_filament_presets();
+	build_extruder_pages();
+	on_value_change("extruders_count", extruders_count);
+}
+
+void TabPrinter::build_extruder_pages(){
+	for (auto extruder_idx = m_extruder_pages.size(); extruder_idx < m_extruders_count; ++extruder_idx){
+		//# build page
+		auto page = add_options_page(_L("Extruder ") + wxString::Format(_T("%i"), extruder_idx + 1), "funnel.png", true);
+		m_extruder_pages.push_back(page);
+			
+			auto optgroup = page->new_optgroup(_L("Size"));
+			optgroup->append_single_option_line("nozzle_diameter", extruder_idx);
+		
+			optgroup = page->new_optgroup(_L("Layer height limits"));
+			optgroup->append_single_option_line("min_layer_height", extruder_idx);
+			optgroup->append_single_option_line("max_layer_height", extruder_idx);
+				
+		
+			optgroup = page->new_optgroup(_L("Position (for multi-extruder printers)"));
+			optgroup->append_single_option_line("extruder_offset", extruder_idx);
+		
+			optgroup = page->new_optgroup(_L("Retraction"));
+			optgroup->append_single_option_line("retract_length", extruder_idx);
+			optgroup->append_single_option_line("retract_lift", extruder_idx);
+				Line line = { _L("Only lift Z"), "" };
+				line.append_option(optgroup->get_option("retract_lift_above", extruder_idx));
+				line.append_option(optgroup->get_option("retract_lift_below", extruder_idx));
+				optgroup->append_line(line);
+			
+			optgroup->append_single_option_line("retract_speed", extruder_idx);
+			optgroup->append_single_option_line("deretract_speed", extruder_idx);
+			optgroup->append_single_option_line("retract_restart_extra", extruder_idx);
+			optgroup->append_single_option_line("retract_before_travel", extruder_idx);
+			optgroup->append_single_option_line("retract_layer_change", extruder_idx);
+			optgroup->append_single_option_line("wipe", extruder_idx);
+			optgroup->append_single_option_line("retract_before_wipe", extruder_idx);
+	
+			optgroup = page->new_optgroup(_L("Retraction when tool is disabled (advanced settings for multi-extruder setups)"));
+			optgroup->append_single_option_line("retract_length_toolchange", extruder_idx);
+			optgroup->append_single_option_line("retract_restart_extra_toolchange", extruder_idx);
+
+			optgroup = page->new_optgroup(_L("Preview"));
+			optgroup->append_single_option_line("extruder_colour", extruder_idx);
+	}
+ 
+	// # remove extra pages
+	if (m_extruders_count <= m_extruder_pages.size()) {
+		m_extruder_pages.resize(m_extruders_count);
+	}
+
+	// # rebuild page list
+	PageShp page_note = m_pages.back();
+	m_pages.pop_back();
+	while (m_pages.back()->title().find(_L("Extruder")) != std::string::npos)
+		m_pages.pop_back();
+	for (auto page_extruder : m_extruder_pages)
+		m_pages.push_back(page_extruder);
+	m_pages.push_back(page_note);
+	rebuild_page_tree();
+}
+
+// this gets executed after preset is loaded and before GUI fields are updated
+void TabPrinter::on_preset_loaded()
+{
+	// update the extruders count field
+	auto   *nozzle_diameter = dynamic_cast<const ConfigOptionFloats*>(m_config->option("nozzle_diameter"));
+	int extruders_count = nozzle_diameter->values.size();
+	set_value("extruders_count", extruders_count);
+	// update the GUI field according to the number of nozzle diameters supplied
+	extruders_count_changed(extruders_count);
+}
+
+void TabPrinter::update(){
+	Freeze();
+
+	bool en;
+	auto serial_speed = get_field("serial_speed");
+	if (serial_speed != nullptr) {
+		en = !m_config->opt_string("serial_port").empty();
+		get_field("serial_speed")->toggle(en);
+		if (m_config->opt_int("serial_speed") != 0 && en)
+			m_serial_test_btn->Enable();
+		else 
+			m_serial_test_btn->Disable();
+	}
+
+	en = !m_config->opt_string("octoprint_host").empty();
+	if ( en && m_is_user_agent)
+		m_octoprint_host_test_btn->Enable();
+	else 
+		m_octoprint_host_test_btn->Disable(); 
+	get_field("octoprint_apikey")->toggle(en);
+
+	bool have_multiple_extruders = m_extruders_count > 1;
+	get_field("toolchange_gcode")->toggle(have_multiple_extruders);
+	get_field("single_extruder_multi_material")->toggle(have_multiple_extruders);
+
+	for (size_t i = 0; i < m_extruders_count; ++i) {
+		bool have_retract_length = m_config->opt_float("retract_length", i) > 0;
+
+		// when using firmware retraction, firmware decides retraction length
+		bool use_firmware_retraction = m_config->opt_bool("use_firmware_retraction");
+		get_field("retract_length", i)->toggle(!use_firmware_retraction);
+
+		// user can customize travel length if we have retraction length or we"re using
+		// firmware retraction
+		get_field("retract_before_travel", i)->toggle(have_retract_length || use_firmware_retraction);
+
+		// user can customize other retraction options if retraction is enabled
+		bool retraction = (have_retract_length || use_firmware_retraction);
+		std::vector<std::string> vec = { "retract_lift", "retract_layer_change" };
+		for (auto el : vec)
+			get_field(el, i)->toggle(retraction);
+
+		// retract lift above / below only applies if using retract lift
+		vec.resize(0);
+		vec = { "retract_lift_above", "retract_lift_below" };
+		for (auto el : vec)
+			get_field(el, i)->toggle(retraction && m_config->opt_float("retract_lift", i) > 0);
+
+		// some options only apply when not using firmware retraction
+		vec.resize(0);
+		vec = { "retract_speed", "deretract_speed", "retract_before_wipe", "retract_restart_extra", "wipe" };
+		for (auto el : vec)
+			get_field(el, i)->toggle(retraction && !use_firmware_retraction);
+
+		bool wipe = m_config->opt_bool("wipe", i);
+		get_field("retract_before_wipe", i)->toggle(wipe);
+
+		if (use_firmware_retraction && wipe) {
+			auto dialog = new wxMessageDialog(parent(),
+				_L("The Wipe option is not available when using the Firmware Retraction mode.\n"
+				"\nShall I disable it in order to enable Firmware Retraction?"),
+				_L("Firmware Retraction"), wxICON_WARNING | wxYES | wxNO);
+
+			DynamicPrintConfig new_conf = *m_config;
+			if (dialog->ShowModal() == wxID_YES) {
+				auto wipe = static_cast<ConfigOptionBools*>(m_config->option("wipe"));
+				wipe->values[i] = 0;
+				new_conf.set_key_value("wipe", wipe);
+			}
+			else {
+				new_conf.set_key_value("use_firmware_retraction", new ConfigOptionBool(false));
+			}
+			load_config(new_conf);
+		}
+
+		get_field("retract_length_toolchange", i)->toggle(have_multiple_extruders);
+
+		bool toolchange_retraction = m_config->opt_float("retract_length_toolchange", i) > 0;
+		get_field("retract_restart_extra_toolchange", i)->toggle
+			(have_multiple_extruders && toolchange_retraction);
+	}
+
+	Thaw();
+}
+
+// Initialize the UI from the current preset
+void Tab::load_current_preset()
+{
+	auto preset = m_presets->get_edited_preset();
+//	try{
+//		local $SIG{ __WARN__ } = Slic3r::GUI::warning_catcher($self);
+		preset.is_default ? m_btn_delete_preset->Disable() : m_btn_delete_preset->Enable(true);
+		update();
+		// For the printer profile, generate the extruder pages.
+		on_preset_loaded();
+		// Reload preset pages with the new configuration values.
+		reload_config();
+//	};
+	// use CallAfter because some field triggers schedule on_change calls using CallAfter,
+	// and we don't want them to be called after this update_dirty() as they would mark the 
+	// preset dirty again
+	// (not sure this is true anymore now that update_dirty is idempotent)
+	wxTheApp->CallAfter([this]{
+		// checking out if this Tab exists till this moment
+		if (!checked_tab(this))
+			return;
+		update_tab_ui();
+		on_presets_changed();
+	});
+}
+
+//Regerenerate content of the page tree.
+void Tab::rebuild_page_tree()
+{
+	Freeze();
+	// get label of the currently selected item
+	auto selected = m_treectrl->GetItemText(m_treectrl->GetSelection());
+	auto rootItem = m_treectrl->GetRootItem();
+	m_treectrl->DeleteChildren(rootItem);
+	auto have_selection = 0;
+	for (auto p : m_pages)
+	{
+		auto itemId = m_treectrl->AppendItem(rootItem, p->title(), p->iconID());
+		if (p->title() == selected) {
+			m_disable_tree_sel_changed_event = 1;
+			m_treectrl->SelectItem(itemId);
+			m_disable_tree_sel_changed_event = 0;
+			have_selection = 1;
+		}
+	}
+	
+	if (!have_selection) {
+		// this is triggered on first load, so we don't disable the sel change event
+		m_treectrl->SelectItem(m_treectrl->GetFirstVisibleItem());//! (treectrl->GetFirstChild(rootItem));
+	}
+	Thaw();
+}
+
+// Called by the UI combo box when the user switches profiles.
+// Select a preset by a name.If !defined(name), then the default preset is selected.
+// If the current profile is modified, user is asked to save the changes.
+void Tab::select_preset(std::string preset_name /*= ""*/)
+{
+	std::string name = preset_name;
+	auto force = false;
+	auto presets = m_presets;
+	// If no name is provided, select the "-- default --" preset.
+	if (name.empty())
+		name= presets->default_preset().name;
+	auto current_dirty = presets->current_is_dirty();
+	auto canceled = false;
+	auto printer_tab = presets->name().compare("printer")==0;
+	m_reload_dependent_tabs = {};
+	if (!force && current_dirty && !may_discard_current_dirty_preset()) {
+		canceled = true;
+	} else if(printer_tab) {
+		// Before switching the printer to a new one, verify, whether the currently active print and filament
+		// are compatible with the new printer.
+		// If they are not compatible and the current print or filament are dirty, let user decide
+		// whether to discard the changes or keep the current printer selection.
+		auto new_printer_preset = presets->find_preset(name, true);
+		auto print_presets = &m_preset_bundle->prints;
+		bool print_preset_dirty = print_presets->current_is_dirty();
+		bool print_preset_compatible = print_presets->get_edited_preset().is_compatible_with_printer(*new_printer_preset);
+		canceled = !force && print_preset_dirty && !print_preset_compatible &&
+			!may_discard_current_dirty_preset(print_presets, name);
+		auto filament_presets = &m_preset_bundle->filaments;
+		bool filament_preset_dirty = filament_presets->current_is_dirty();
+		bool filament_preset_compatible = filament_presets->get_edited_preset().is_compatible_with_printer(*new_printer_preset);
+		if (!canceled && !force) {
+			canceled = filament_preset_dirty && !filament_preset_compatible &&
+				!may_discard_current_dirty_preset(filament_presets, name);
+		}
+		if (!canceled) {
+			if (!print_preset_compatible) {
+				// The preset will be switched to a different, compatible preset, or the '-- default --'.
+				m_reload_dependent_tabs.push_back("print");
+				if (print_preset_dirty) print_presets->discard_current_changes();
+			}
+			if (!filament_preset_compatible) {
+				// The preset will be switched to a different, compatible preset, or the '-- default --'.
+				m_reload_dependent_tabs.push_back("filament");
+				if (filament_preset_dirty) filament_presets->discard_current_changes();
+			}
+		}
+	}
+	if (canceled) {
+		update_tab_ui();
+		// Trigger the on_presets_changed event so that we also restore the previous value in the plater selector,
+		// if this action was initiated from the platter.
+		on_presets_changed();
+	}
+	else {
+		if (current_dirty) presets->discard_current_changes() ;
+		presets->select_preset_by_name(name, force);
+		// Mark the print & filament enabled if they are compatible with the currently selected preset.
+		// The following method should not discard changes of current print or filament presets on change of a printer profile,
+		// if they are compatible with the current printer.
+		if (current_dirty || printer_tab)
+			m_preset_bundle->update_compatible_with_printer(true);
+		// Initialize the UI from the current preset.
+		load_current_preset();
+	}
+
+}
+
+// If the current preset is dirty, the user is asked whether the changes may be discarded.
+// if the current preset was not dirty, or the user agreed to discard the changes, 1 is returned.
+bool Tab::may_discard_current_dirty_preset(PresetCollection* presets /*= nullptr*/, std::string new_printer_name /*= ""*/)
+{
+	if (presets == nullptr) presets = m_presets;
+	// Display a dialog showing the dirty options in a human readable form.
+	auto old_preset = presets->get_edited_preset();
+	auto type_name = presets->name();
+	auto tab = "          ";
+	auto name = old_preset.is_default ?
+		_L("Default ") + type_name + _L(" preset") :
+		(type_name + _L(" preset\n") + tab + old_preset.name);
+	// Collect descriptions of the dirty options.
+	std::vector<std::string> option_names;
+	for(auto opt_key: presets->current_dirty_options()) {
+		auto opt = m_config->def()->options.at(opt_key);
+		std::string name = "";
+		if (!opt.category.empty())
+			name += opt.category + " > ";
+		name += !opt.full_label.empty() ?
+				opt.full_label : 
+				opt.label;
+		option_names.push_back(name);
+	}
+	// Show a confirmation dialog with the list of dirty options.
+	std::string changes = "";
+	for (auto changed_name : option_names)
+		changes += tab + changed_name + "\n";
+	auto message = (!new_printer_name.empty()) ?
+		name + _L("\n\nis not compatible with printer\n") +tab + new_printer_name+ _L("\n\nand it has the following unsaved changes:") :
+		name + _L("\n\nhas the following unsaved changes:");
+	auto confirm = new wxMessageDialog(parent(),
+		message + "\n" +changes +_L("\n\nDiscard changes and continue anyway?"),
+		_L("Unsaved Changes"), wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION);
+	return confirm->ShowModal() == wxID_YES;
+}
+
+void Tab::OnTreeSelChange(wxTreeEvent& event)
+{
+	if (m_disable_tree_sel_changed_event) return;
+	Page* page = nullptr;
+	auto selection = m_treectrl->GetItemText(m_treectrl->GetSelection());
+	for (auto p : m_pages)
+		if (p->title() == selection)
+		{
+			page = p.get();
+			break;
+		}
+	if (page == nullptr) return;
+
+	for (auto& el : m_pages)
+		el.get()->Hide();
+	page->Show();
+	m_hsizer->Layout();
+	Refresh();
+}
+
+void Tab::OnKeyDown(wxKeyEvent& event)
+{
+	if (event.GetKeyCode() == WXK_TAB)
+		m_treectrl->Navigate(event.ShiftDown() ? wxNavigationKeyEvent::IsBackward : wxNavigationKeyEvent::IsForward);
+	else
+		event.Skip();
+}
+
+// Save the current preset into file.
+// This removes the "dirty" flag of the preset, possibly creates a new preset under a new name,
+// and activates the new preset.
+// Wizard calls save_preset with a name "My Settings", otherwise no name is provided and this method
+// opens a Slic3r::GUI::SavePresetWindow dialog.
+void Tab::save_preset(std::string name /*= ""*/)
+{
+	// since buttons(and choices too) don't get focus on Mac, we set focus manually
+	// to the treectrl so that the EVT_* events are fired for the input field having
+	// focus currently.is there anything better than this ?
+//!	m_treectrl->OnSetFocus();
+
+	if (name.empty()) {
+		auto preset = m_presets->get_selected_preset();
+		auto default_name = preset.is_default ? "Untitled" : preset.name;
+ 		bool have_extention = boost::iends_with(default_name, ".ini");
+		if (have_extention)
+		{
+			size_t len = default_name.length()-4;
+			default_name.resize(len);
+		}
+		//[map $_->name, grep !$_->default && !$_->external, @{$self->{presets}}],
+		std::vector<std::string> values;
+		for (size_t i = 0; i < m_presets->size(); ++i) {
+			const Preset &preset = m_presets->preset(i);
+			if (preset.is_default || preset.is_external)
+				continue;
+			values.push_back(preset.name);
+		}
+
+		auto dlg = new SavePresetWindow(parent());
+		dlg->build(title(), default_name, values);	
+		if (dlg->ShowModal() != wxID_OK)
+			return;
+		name = dlg->get_name();
+		if (name == ""){
+			show_error(this, _L("The supplied name is empty. It can't be saved."));
+			return;
+		}
+	}
+	try
+	{
+		// Save the preset into Slic3r::data_dir / presets / section_name / preset_name.ini
+		m_presets->save_current_preset(name);
+	}
+	catch (const std::exception &e)
+	{
+		show_error(this, _L("Something is wrong. It can't be saved."));
+		return;
+	}
+
+	// Mark the print & filament enabled if they are compatible with the currently selected preset.
+	m_preset_bundle->update_compatible_with_printer(false);
+	// Add the new item into the UI component, remove dirty flags and activate the saved item.
+	update_tab_ui();
+	// Update the selection boxes at the platter.
+	on_presets_changed();
+}
+
+// Called for a currently selected preset.
+void Tab::delete_preset()
+{
+	auto current_preset = m_presets->get_selected_preset();
+	// Don't let the user delete the ' - default - ' configuration.
+	wxString action = current_preset.is_external ? _L("remove") : _L("delete");
+	wxString msg = _L("Are you sure you want to ") + action + _L(" the selected preset?");
+	action = current_preset.is_external ? _L("Remove") : _L("Delete");
+	wxString title = action + _L(" Preset");
+	if (current_preset.is_default ||
+		wxID_YES != wxMessageDialog(parent(), msg, title, wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION).ShowModal())
+		return;
+	// Delete the file and select some other reasonable preset.
+	// The 'external' presets will only be removed from the preset list, their files will not be deleted.
+	try{ m_presets->delete_current_preset(); }
+	catch (const std::exception &e)
+	{
+		return;
+	}
+	// Load the newly selected preset into the UI, update selection combo boxes with their dirty flags.
+	load_current_preset();
+}
+
+void Tab::toggle_show_hide_incompatible()
+{
+	m_show_incompatible_presets = !m_show_incompatible_presets;
+	update_show_hide_incompatible_button();
+	update_tab_ui();
+}
+
+void Tab::update_show_hide_incompatible_button()
+{
+	m_btn_hide_incompatible_presets->SetBitmap(m_show_incompatible_presets ?
+		*m_bmp_show_incompatible_presets : *m_bmp_hide_incompatible_presets);
+	m_btn_hide_incompatible_presets->SetToolTip(m_show_incompatible_presets ?
+		"Both compatible an incompatible presets are shown. Click to hide presets not compatible with the current printer." :
+		"Only compatible presets are shown. Click to show both the presets compatible and not compatible with the current printer.");
+}
+
+void Tab::update_ui_from_settings()
+{
+	// Show the 'show / hide presets' button only for the print and filament tabs, and only if enabled
+	// in application preferences.
+	bool show = m_show_btn_incompatible_presets && m_presets->name().compare("printer") != 0;
+	show ? m_btn_hide_incompatible_presets->Show() :  m_btn_hide_incompatible_presets->Hide();
+	// If the 'show / hide presets' button is hidden, hide the incompatible presets.
+	if (show) {
+		update_show_hide_incompatible_button();
+	}
+	else {
+		if (m_show_incompatible_presets) {
+			m_show_incompatible_presets = false;
+			update_tab_ui();
+		}
+	}
+}
+
+// Return a callback to create a Tab widget to mark the preferences as compatible / incompatible to the current printer.
+wxSizer* Tab::compatible_printers_widget(wxWindow* parent, wxCheckBox** checkbox, wxButton** btn)
+{
+	*checkbox = new wxCheckBox(parent, wxID_ANY, _L("All"));
+	*btn = new wxButton(parent, wxID_ANY, _L("Set")+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
+
+	(*btn)->SetBitmap(wxBitmap(wxString::FromUTF8(Slic3r::var("printer_empty.png").c_str()), wxBITMAP_TYPE_PNG));
+
+	auto sizer = new wxBoxSizer(wxHORIZONTAL);
+	sizer->Add((*checkbox), 0, wxALIGN_CENTER_VERTICAL);
+	sizer->Add((*btn), 0, wxALIGN_CENTER_VERTICAL);
+
+	(*checkbox)->Bind(wxEVT_CHECKBOX, ([=](wxCommandEvent e)
+	{
+		(*btn)->Enable(!(*checkbox)->GetValue());
+		// All printers have been made compatible with this preset.
+		if ((*checkbox)->GetValue())
+			load_key_value("compatible_printers", std::vector<std::string> {});
+		get_field("compatible_printers_condition")->toggle((*checkbox)->GetValue());
+	}) );
+
+	(*btn)->Bind(wxEVT_BUTTON, ([this, parent, checkbox, btn](wxCommandEvent e)
+	{
+		// # Collect names of non-default non-external printer profiles.
+		PresetCollection *printers = &m_preset_bundle->printers;
+		wxArrayString presets;
+		for (size_t idx = 0; idx < printers->size(); ++idx)
+		{
+			Preset& preset = printers->preset(idx);
+			if (!preset.is_default && !preset.is_external)
+				presets.Add(preset.name);
+		}
+
+		auto dlg = new wxMultiChoiceDialog(parent,
+		_L("Select the printers this profile is compatible with."),
+		_L("Compatible printers"),  presets);
+		// # Collect and set indices of printers marked as compatible.
+		wxArrayInt selections;
+		auto *compatible_printers = dynamic_cast<const ConfigOptionStrings*>(m_config->option("compatible_printers"));
+		if (compatible_printers != nullptr || !compatible_printers->values.empty())
+			for (auto preset_name : compatible_printers->values)
+				for (size_t idx = 0; idx < presets.GetCount(); ++idx)
+					if (presets[idx].compare(preset_name) == 0)
+					{
+						selections.Add(idx);
+						break;
+					}
+		dlg->SetSelections(selections);
+		std::vector<std::string> value;
+		// Show the dialog.
+		if (dlg->ShowModal() == wxID_OK) {
+			selections.Clear();
+			selections = dlg->GetSelections();
+			for (auto idx : selections)
+				value.push_back(presets[idx].ToStdString());
+			if (value.empty()) {
+				(*checkbox)->SetValue(1);
+				(*btn)->Disable();
+			}
+			// All printers have been made compatible with this preset.
+			load_key_value("compatible_printers", value);
+		}
+	}));
+	return sizer; 
+}
+
+void Page::reload_config()
+{
+	for (auto group : m_optgroups)
+		group->reload_config();
+}
+
+Field* Page::get_field(t_config_option_key opt_key, int opt_index/* = -1*/) const
+{
+	Field* field = nullptr;
+	for (auto opt : m_optgroups){
+		field = opt->get_fieldc(opt_key, opt_index);
+		if (field != nullptr)
+			return field;
+	}
+	return field;
+}
+
+bool Page::set_value(t_config_option_key opt_key, boost::any value){
+	bool changed = false;
+	for(auto optgroup: m_optgroups) {
+		if (optgroup->set_value(opt_key, value))
+			changed = 1 ;
+	}
+	return changed;
+}
+
+// package Slic3r::GUI::Tab::Page;
+ConfigOptionsGroupShp Page::new_optgroup(wxString title, int noncommon_label_width /*= -1*/)
+{
+	//! config_ have to be "right"
+	ConfigOptionsGroupShp optgroup = std::make_shared<ConfigOptionsGroup>(this, title, m_config);
+	if (noncommon_label_width >= 0)
+		optgroup->label_width = noncommon_label_width;
+
+	optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value){
+		//! This function will be called from OptionGroup.
+		//! Using of CallAfter is redundant.
+		//! And in some cases it causes update() function to be recalled again
+//!        wxTheApp->CallAfter([this, opt_key, value]() {
+			static_cast<Tab*>(GetParent())->update_dirty();
+			static_cast<Tab*>(GetParent())->on_value_change(opt_key, value);
+//!        });
+	};
+
+	vsizer()->Add(optgroup->sizer, 0, wxEXPAND | wxALL, 10);
+	m_optgroups.push_back(optgroup);
+
+	return optgroup;
+}
+
+void SavePresetWindow::build(wxString title, std::string default_name, std::vector<std::string> &values)
+{
+	auto text = new wxStaticText(this, wxID_ANY, _L("Save ") + title + _L(" as:"), 
+									wxDefaultPosition, wxDefaultSize);
+	m_combo = new wxComboBox(this, wxID_ANY, wxString::FromUTF8(default_name.c_str()), 
+							wxDefaultPosition, wxDefaultSize, 0, 0, wxTE_PROCESS_ENTER);
+	for (auto value : values)
+		m_combo->Append(wxString::FromUTF8(value.c_str()));
+	auto buttons = CreateStdDialogButtonSizer(wxOK | wxCANCEL);
+
+	auto sizer = new wxBoxSizer(wxVERTICAL);
+	sizer->Add(text, 0, wxEXPAND | wxALL, 10);
+	sizer->Add(m_combo, 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
+	sizer->Add(buttons, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 10);
+
+	wxButton* btn = static_cast<wxButton*>(FindWindowById(wxID_OK, this));
+	btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { accept(); });
+	m_combo->Bind(wxEVT_TEXT_ENTER, [this](wxCommandEvent&) { accept(); });
+
+	SetSizer(sizer);
+	sizer->SetSizeHints(this);
+}
+
+void SavePresetWindow::accept()
+{
+	m_chosen_name = normalize_utf8_nfc(m_combo->GetValue().ToUTF8());
+	if (!m_chosen_name.empty()) {
+		const char* unusable_symbols = "<>:/\\|?*\"";
+		bool is_unusable_symbol = false;
+		for (size_t i = 0; i < std::strlen(unusable_symbols); i++){
+			if (m_chosen_name.find_first_of(unusable_symbols[i]) != std::string::npos){
+				is_unusable_symbol = true;
+				break;
+			}
+		}
+		if (is_unusable_symbol) {
+			show_error(this, _L("The supplied name is not valid; the following characters are not allowed:")+" <>:/\\|?*\"");
+		}
+		else if (m_chosen_name.compare("- default -") == 0) {
+			show_error(this, _L("The supplied name is not available."));
+		}
+		else {
+			EndModal(wxID_OK);
+		}
+	}
+}
+
+} // GUI
+} // Slic3r
diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp
new file mode 100644
index 000000000..4f3a15736
--- /dev/null
+++ b/xs/src/slic3r/GUI/Tab.hpp
@@ -0,0 +1,260 @@
+//	 The "Expert" tab at the right of the main tabbed window.
+//	
+//	 This file implements following packages:
+//	   Slic3r::GUI::Tab;
+//	       Slic3r::GUI::Tab::Print;
+//	       Slic3r::GUI::Tab::Filament;
+//	       Slic3r::GUI::Tab::Printer;
+//	   Slic3r::GUI::Tab::Page
+//	       - Option page: For example, the Slic3r::GUI::Tab::Print has option pages "Layers and perimeters", "Infill", "Skirt and brim" ...
+//	   Slic3r::GUI::SavePresetWindow
+//	       - Dialog to select a new preset name to store the configuration.
+//	   Slic3r::GUI::Tab::Preset;
+//	       - Single preset item: name, file is default or external.
+
+#include <wx/panel.h>
+#include <wx/notebook.h>
+#include <wx/scrolwin.h>
+#include <wx/sizer.h>
+#include <wx/bmpcbox.h>
+#include <wx/bmpbuttn.h>
+#include <wx/treectrl.h>
+#include <wx/imaglist.h>
+#include <wx/statbox.h>
+
+#include <map>
+#include <vector>
+#include <memory>
+
+#include "BedShapeDialog.hpp"
+
+//!enum { ID_TAB_TREE = wxID_HIGHEST + 1 };
+
+namespace Slic3r {
+namespace GUI {
+
+// Single Tab page containing a{ vsizer } of{ optgroups }
+// package Slic3r::GUI::Tab::Page;
+using ConfigOptionsGroupShp = std::shared_ptr<ConfigOptionsGroup>;
+class Page : public wxScrolledWindow
+{
+	wxWindow*		m_parent;
+	wxString		m_title;
+	size_t			m_iconID;
+	wxBoxSizer*		m_vsizer;
+public:
+	Page(wxWindow* parent, const wxString title, const int iconID) :
+			m_parent(parent),
+			m_title(title),
+			m_iconID(iconID)
+	{
+		Create(m_parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
+		m_vsizer = new wxBoxSizer(wxVERTICAL);
+		SetSizer(m_vsizer);
+	}
+	~Page(){}
+
+public:
+	std::vector <ConfigOptionsGroupShp> m_optgroups;
+	DynamicPrintConfig* m_config;
+
+	wxBoxSizer*	vsizer() const { return m_vsizer; }
+	wxWindow*	parent() const { return m_parent; }
+	wxString	title()	 const { return m_title; }
+	size_t		iconID() const { return m_iconID; }
+	void		set_config(DynamicPrintConfig* config_in) { m_config = config_in; }
+	void		reload_config();
+	Field*		get_field(t_config_option_key opt_key, int opt_index = -1) const;
+	bool		set_value(t_config_option_key opt_key, boost::any value);
+	ConfigOptionsGroupShp	new_optgroup(wxString title, int noncommon_label_width = -1);
+};
+
+// Slic3r::GUI::Tab;
+
+using PageShp = std::shared_ptr<Page>;
+class Tab: public wxPanel
+{
+	wxNotebook*			m_parent;
+protected:
+	std::string			m_name;
+	const wxString		m_title;
+	wxBitmapComboBox*	m_presets_choice;
+	wxBitmapButton*		m_btn_save_preset;
+	wxBitmapButton*		m_btn_delete_preset;
+	wxBitmap*			m_bmp_show_incompatible_presets;
+	wxBitmap*			m_bmp_hide_incompatible_presets;
+	wxBitmapButton*		m_btn_hide_incompatible_presets;
+	wxBoxSizer*			m_hsizer;
+	wxBoxSizer*			m_left_sizer;
+	wxTreeCtrl*			m_treectrl;
+	wxImageList*		m_icons;
+	wxCheckBox*			m_compatible_printers_checkbox;
+	wxButton*			m_compatible_printers_btn;
+
+	int					m_icon_count;
+	std::map<std::string, size_t>	m_icon_index;		// Map from an icon file name to its index in $self->{icons}.
+	std::vector<PageShp>			m_pages;	// $self->{pages} = [];
+	bool				m_disable_tree_sel_changed_event;
+	bool				m_show_incompatible_presets;
+	bool				m_no_controller;
+
+	std::vector<std::string>	m_reload_dependent_tabs = {};
+
+	// The two following two event IDs are generated at Plater.pm by calling Wx::NewEventType.
+	wxEventType			m_event_value_change = 0;
+	wxEventType 		m_event_presets_changed = 0;
+
+public:
+	PresetBundle*		m_preset_bundle;
+	bool				m_show_btn_incompatible_presets;
+	PresetCollection*	m_presets;
+	DynamicPrintConfig*	m_config;
+
+public:
+	Tab() {}
+	Tab(wxNotebook* parent, wxString title, const char* name, bool no_controller) : 
+		m_parent(parent), m_title(title), m_name(name), m_no_controller(no_controller) {
+		Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL);
+		get_tabs_list().push_back(this);
+	}
+	~Tab() { delete_tab_from_list(this); }
+
+	wxWindow*	parent() const { return m_parent; }
+	wxString	title()	 const { return m_title; }
+	std::string	name()	 const { return m_name; }
+
+	// Set the events to the callbacks posted to the main frame window (currently implemented in Perl).
+	void 		set_event_value_change(wxEventType evt) { m_event_value_change = evt; }
+	void 		set_event_presets_changed(wxEventType evt) { m_event_presets_changed = evt; }
+	
+	void		create_preset_tab(PresetBundle *preset_bundle);
+	void		load_current_preset();
+	void		rebuild_page_tree();
+	void		select_preset(std::string preset_name = "");
+	bool		may_discard_current_dirty_preset(PresetCollection* presets = nullptr, std::string new_printer_name = "");
+	wxSizer*	compatible_printers_widget(wxWindow* parent, wxCheckBox** checkbox, wxButton** btn);
+
+	void		load_key_value(std::string opt_key, boost::any value);
+	void		reload_compatible_printers_widget();
+
+	void		OnTreeSelChange(wxTreeEvent& event);
+	void		OnKeyDown(wxKeyEvent& event);
+
+	void		save_preset(std::string name = "");
+	void		delete_preset();
+	void		toggle_show_hide_incompatible();
+	void		update_show_hide_incompatible_button();
+	void		update_ui_from_settings();
+	
+	PageShp		add_options_page(wxString title, std::string icon, bool is_extruder_pages = false);
+
+	virtual void	OnActivate(){}
+	virtual void	on_preset_loaded(){}
+	virtual void	build() = 0;
+	virtual void	update() = 0;
+	void			update_dirty();
+	void			update_tab_ui();
+	void			load_config(DynamicPrintConfig config);
+	virtual void	reload_config();
+	Field*			get_field(t_config_option_key opt_key, int opt_index = -1) const;
+	bool			set_value(t_config_option_key opt_key, boost::any value);
+	wxSizer*		description_line_widget(wxWindow* parent, ogStaticText** StaticText);
+	bool			current_preset_is_dirty();
+	DynamicPrintConfig*	get_config() { return m_config; }
+	PresetCollection*	get_presets()
+	{
+		return m_presets;
+	}
+	std::vector<std::string>	get_dependent_tabs() { return m_reload_dependent_tabs; }
+
+	void			on_value_change(std::string opt_key, boost::any value);
+
+protected:
+	void			on_presets_changed();
+};
+
+//Slic3r::GUI::Tab::Print;
+class TabPrint : public Tab
+{
+public:
+	TabPrint() {}
+	TabPrint(wxNotebook* parent, bool no_controller) : 
+		Tab(parent, _L("Print Settings"), "print", no_controller) {}
+	~TabPrint(){}
+
+	ogStaticText*	m_recommended_thin_wall_thickness_description_line;
+	bool		m_support_material_overhangs_queried = false;
+
+	void		build() override;
+	void		reload_config() override;
+	void		update() override;
+	void		OnActivate() override;
+};
+
+//Slic3r::GUI::Tab::Filament;
+class TabFilament : public Tab
+{
+	ogStaticText*	m_volumetric_speed_description_line;
+	ogStaticText*	m_cooling_description_line;
+public:
+	TabFilament() {}
+	TabFilament(wxNotebook* parent, bool no_controller) : 
+		Tab(parent, _L("Filament Settings"), "filament", no_controller) {}
+	~TabFilament(){}
+
+	void		build() override;
+	void		reload_config() override;
+	void		update() override;
+	void		OnActivate() override;
+};
+
+//Slic3r::GUI::Tab::Printer;
+class TabPrinter : public Tab
+{
+	bool		m_is_disabled_button_browse;
+	bool		m_is_user_agent;
+	// similar event by clicking Buttons "Browse" & "Test"
+	wxEventType	m_event_button_browse = 0;
+	wxEventType m_event_button_test = 0;
+public:
+	wxButton*	m_serial_test_btn;
+	wxButton*	m_octoprint_host_test_btn;
+
+	size_t		m_extruders_count;
+	std::vector<PageShp>	m_extruder_pages;
+
+	TabPrinter() {}
+	TabPrinter(wxNotebook* parent, bool no_controller, bool is_disabled_btn_browse, bool is_user_agent) :
+		Tab(parent, _L("Printer Settings"), "printer", no_controller),
+		m_is_disabled_button_browse(is_disabled_btn_browse), 
+		m_is_user_agent(is_user_agent) {}
+	~TabPrinter(){}
+
+	void		build() override;
+	void		update() override;
+	void		update_serial_ports();
+	void		extruders_count_changed(size_t extruders_count);
+	void		build_extruder_pages();
+	void		on_preset_loaded() override;
+
+	// Set the events to the callbacks posted to the main frame window (currently implemented in Perl).
+	void		set_event_button_browse(wxEventType evt)	{ m_event_button_browse = evt; }
+	void		set_event_button_test(wxEventType evt)		{ m_event_button_test = evt; }
+};
+
+class SavePresetWindow :public wxDialog
+{
+public:
+	SavePresetWindow(wxWindow* parent) :wxDialog(parent, wxID_ANY, _L("Save preset")){}
+	~SavePresetWindow(){}
+
+	std::string		m_chosen_name;
+	wxComboBox*		m_combo;
+
+	void			build(wxString title, std::string default_name, std::vector<std::string> &values);
+	void			accept();
+	std::string		get_name() { return m_chosen_name; }
+};
+
+} // GUI
+} // Slic3r
diff --git a/xs/src/slic3r/GUI/TabIface.cpp b/xs/src/slic3r/GUI/TabIface.cpp
new file mode 100644
index 000000000..2f3adea3c
--- /dev/null
+++ b/xs/src/slic3r/GUI/TabIface.cpp
@@ -0,0 +1,19 @@
+#include "TabIface.hpp"
+#include "Tab.hpp"
+
+namespace Slic3r {
+
+void	TabIface::load_current_preset()		{ m_tab->load_current_preset(); }
+void	TabIface::update_tab_ui()			{ m_tab->update_tab_ui(); }
+void	TabIface::update_ui_from_settings()	{ m_tab->update_ui_from_settings();}
+void	TabIface::select_preset(char* name)	{ m_tab->select_preset(name);}
+void	TabIface::load_config(DynamicPrintConfig* config)	{ m_tab->load_config(*config);}
+void	TabIface::load_key_value(char* opt_key, char* value){ m_tab->load_key_value(opt_key, static_cast<std::string>(value)); }
+bool	TabIface::current_preset_is_dirty()					{ return m_tab->current_preset_is_dirty();}
+void	TabIface::OnActivate()								{ return m_tab->OnActivate();}
+std::string					TabIface::title()				{ return m_tab->title().ToStdString();}
+DynamicPrintConfig*			TabIface::get_config()			{ return m_tab->get_config(); }
+PresetCollection*			TabIface::get_presets()			{ return m_tab!=nullptr ? m_tab->get_presets() : nullptr; }
+std::vector<std::string>	TabIface::get_dependent_tabs()	{ return m_tab->get_dependent_tabs(); }
+
+}; // namespace Slic3r
diff --git a/xs/src/slic3r/GUI/TabIface.hpp b/xs/src/slic3r/GUI/TabIface.hpp
new file mode 100644
index 000000000..0325c855c
--- /dev/null
+++ b/xs/src/slic3r/GUI/TabIface.hpp
@@ -0,0 +1,35 @@
+#include <vector>
+#include <string>
+
+namespace Slic3r {
+	class DynamicPrintConfig;
+	class PresetCollection;
+
+namespace GUI {
+	class Tab;
+}
+
+class TabIface {
+public:
+	TabIface() : m_tab(nullptr) {}
+	TabIface(GUI::Tab *tab) : m_tab(tab) {}
+//	TabIface(const TabIface &rhs) : m_tab(rhs.m_tab) {}
+
+	void		load_current_preset();
+	void		update_tab_ui();
+	void		update_ui_from_settings();
+	void		select_preset(char* name);
+	std::string title();
+	void		load_config(DynamicPrintConfig* config);
+	void		load_key_value(char* opt_key, char* value);
+	bool		current_preset_is_dirty();
+	void		OnActivate();
+	DynamicPrintConfig*			get_config();
+	PresetCollection*			get_presets();
+	std::vector<std::string>	get_dependent_tabs();
+
+protected:
+	GUI::Tab   *m_tab;
+};
+
+}; // namespace Slic3r
diff --git a/xs/src/slic3r/GUI/Widget.hpp b/xs/src/slic3r/GUI/Widget.hpp
new file mode 100644
index 000000000..bcf772469
--- /dev/null
+++ b/xs/src/slic3r/GUI/Widget.hpp
@@ -0,0 +1,16 @@
+#ifndef WIDGET_HPP
+#define WIDGET_HPP
+#include <wx/wxprec.h>
+#ifndef WX_PRECOM
+#include <wx/wx.h>
+#endif
+
+class Widget {
+protected:
+    wxSizer* _sizer;
+public:
+    Widget(): _sizer(nullptr) { }
+    bool valid() const { return _sizer != nullptr; } 
+    wxSizer* sizer() const { return _sizer; } 
+};
+#endif
diff --git a/xs/src/slic3r/GUI/wxExtensions.cpp b/xs/src/slic3r/GUI/wxExtensions.cpp
new file mode 100644
index 000000000..b5f0595f8
--- /dev/null
+++ b/xs/src/slic3r/GUI/wxExtensions.cpp
@@ -0,0 +1,68 @@
+#include "wxExtensions.hpp"
+
+const unsigned int wxCheckListBoxComboPopup::Height = 210;
+
+bool wxCheckListBoxComboPopup::Create(wxWindow* parent)
+{
+    return wxCheckListBox::Create(parent, wxID_HIGHEST + 1, wxPoint(0, 0));
+}
+
+wxWindow* wxCheckListBoxComboPopup::GetControl()
+{
+    return this;
+}
+
+void wxCheckListBoxComboPopup::SetStringValue(const wxString& value)
+{
+    m_text = value;
+}
+
+wxString wxCheckListBoxComboPopup::GetStringValue() const
+{
+    return m_text;
+}
+
+wxSize wxCheckListBoxComboPopup::GetAdjustedSize(int minWidth, int prefHeight, int maxHeight)
+{
+    // matches owner wxComboCtrl's width
+
+    wxComboCtrl* cmb = GetComboCtrl();
+    if (cmb != nullptr)
+    {
+        wxSize size = GetComboCtrl()->GetSize();
+        size.SetHeight(Height);
+        return size;
+    }
+    else
+        return wxSize(200, Height);
+}
+
+void wxCheckListBoxComboPopup::OnCheckListBox(wxCommandEvent& evt)
+{
+    // forwards the checklistbox event to the owner wxComboCtrl
+
+    wxComboCtrl* cmb = GetComboCtrl();
+    if (cmb != nullptr)
+    {
+        wxCommandEvent event(wxEVT_CHECKLISTBOX, cmb->GetId());
+        event.SetEventObject(cmb);
+        cmb->ProcessWindowEvent(event);
+    }
+}
+
+void wxCheckListBoxComboPopup::OnListBoxSelection(wxCommandEvent& evt)
+{
+    // transforms list box item selection event into checklistbox item toggle event 
+
+    int selId = GetSelection();
+    if (selId != wxNOT_FOUND)
+    {
+        Check((unsigned int)selId, !IsChecked((unsigned int)selId));
+        SetSelection(wxNOT_FOUND);
+
+        wxCommandEvent event(wxEVT_CHECKLISTBOX, GetId());
+        event.SetInt(selId);
+        event.SetEventObject(this);
+        ProcessEvent(event);
+    }
+}
diff --git a/xs/src/slic3r/GUI/wxExtensions.hpp b/xs/src/slic3r/GUI/wxExtensions.hpp
new file mode 100644
index 000000000..8e62f766c
--- /dev/null
+++ b/xs/src/slic3r/GUI/wxExtensions.hpp
@@ -0,0 +1,24 @@
+#ifndef slic3r_GUI_wxExtensions_hpp_
+#define slic3r_GUI_wxExtensions_hpp_
+
+#include <wx/checklst.h>
+#include <wx/combo.h>
+
+class wxCheckListBoxComboPopup : public wxCheckListBox, public wxComboPopup
+{
+    static const unsigned int Height;
+
+    wxString m_text;
+
+public:
+    virtual bool Create(wxWindow* parent);
+    virtual wxWindow* GetControl();
+    virtual void SetStringValue(const wxString& value);
+    virtual wxString GetStringValue() const;
+    virtual wxSize GetAdjustedSize(int minWidth, int prefHeight, int maxHeight);
+
+    void OnCheckListBox(wxCommandEvent& evt);
+    void OnListBoxSelection(wxCommandEvent& evt);
+};
+
+#endif // slic3r_GUI_wxExtensions_hpp_
diff --git a/xs/src/slic3r/GUI/wxinit.h b/xs/src/slic3r/GUI/wxinit.h
new file mode 100644
index 000000000..b55681b92
--- /dev/null
+++ b/xs/src/slic3r/GUI/wxinit.h
@@ -0,0 +1,25 @@
+#ifndef slic3r_wxinit_hpp_
+#define slic3r_wxinit_hpp_
+
+#include <wx/wx.h>
+#include <wx/intl.h>
+#include <wx/html/htmlwin.h>
+
+// Perl redefines a _ macro, so we undef this one
+#undef _
+
+// We do want to use translation however, so define it as __ so we can do a find/replace
+// later when we no longer need to undef _
+#define __(s)                     wxGetTranslation((s))
+
+// legacy macros
+// https://wiki.wxwidgets.org/EventTypes_and_Event-Table_Macros
+#ifndef wxEVT_BUTTON
+#define wxEVT_BUTTON wxEVT_COMMAND_BUTTON_CLICKED
+#endif
+
+#ifndef wxEVT_HTML_LINK_CLICKED
+#define wxEVT_HTML_LINK_CLICKED wxEVT_COMMAND_HTML_LINK_CLICKED
+#endif
+
+#endif
diff --git a/xs/xsp/BoundingBox.xsp b/xs/xsp/BoundingBox.xsp
index a326c7501..df8e6baea 100644
--- a/xs/xsp/BoundingBox.xsp
+++ b/xs/xsp/BoundingBox.xsp
@@ -25,10 +25,10 @@
     double radius();
     Clone<Point> min_point() %code{% RETVAL = THIS->min; %};
     Clone<Point> max_point() %code{% RETVAL = THIS->max; %};
-    long x_min() %code{% RETVAL = THIS->min.x; %};
-    long x_max() %code{% RETVAL = THIS->max.x; %};
-    long y_min() %code{% RETVAL = THIS->min.y; %};
-    long y_max() %code{% RETVAL = THIS->max.y; %};
+    int x_min() %code{% RETVAL = THIS->min.x; %};
+    int x_max() %code{% RETVAL = THIS->max.x; %};
+    int y_min() %code{% RETVAL = THIS->min.y; %};
+    int y_max() %code{% RETVAL = THIS->max.y; %};
     std::string serialize() %code{% char buf[2048]; sprintf(buf, "%ld,%ld;%ld,%ld", THIS->min.x, THIS->min.y, THIS->max.x, THIS->max.y); RETVAL = buf; %};
     bool defined() %code{% RETVAL = THIS->defined; %};
 
diff --git a/xs/xsp/BridgeDetector.xsp b/xs/xsp/BridgeDetector.xsp
index c7ac409df..0039d3579 100644
--- a/xs/xsp/BridgeDetector.xsp
+++ b/xs/xsp/BridgeDetector.xsp
@@ -23,7 +23,7 @@ BridgeDetector*
 BridgeDetector::new(expolygon, lower_slices, extrusion_width)
     ExPolygon*              expolygon;
     ExPolygonCollection*    lower_slices;
-    long                    extrusion_width;
+    int                     extrusion_width;
     CODE:
         RETVAL = new BridgeDetector(*expolygon, *lower_slices, extrusion_width);
     OUTPUT:
@@ -33,7 +33,7 @@ BridgeDetector*
 BridgeDetector::new_expolygons(expolygons, lower_slices, extrusion_width)
     ExPolygonCollection*    expolygons;
     ExPolygonCollection*    lower_slices;
-    long                    extrusion_width;
+    int                     extrusion_width;
     CODE:
         RETVAL = new BridgeDetector(expolygons->expolygons, *lower_slices, extrusion_width);
     OUTPUT:
diff --git a/xs/xsp/Flow.xsp b/xs/xsp/Flow.xsp
index d9b7a45c0..b57df5e37 100644
--- a/xs/xsp/Flow.xsp
+++ b/xs/xsp/Flow.xsp
@@ -26,8 +26,8 @@
     float spacing();
     float spacing_to(Flow* other)
         %code{% RETVAL = THIS->spacing(*other); %};
-    long scaled_width();
-    long scaled_spacing();
+    int   scaled_width();
+    int   scaled_spacing();
     double mm3_per_mm();
 %{
 
diff --git a/xs/xsp/GCode.xsp b/xs/xsp/GCode.xsp
index 9e6df85dc..b4cb7c0e9 100644
--- a/xs/xsp/GCode.xsp
+++ b/xs/xsp/GCode.xsp
@@ -4,6 +4,7 @@
 #include <xsinit.h>
 #include "libslic3r/GCode.hpp"
 #include "libslic3r/GCode/CoolingBuffer.hpp"
+#include "libslic3r/GCode/PreviewData.hpp"
 %}
 
 %name{Slic3r::GCode::CoolingBuffer} class CoolingBuffer {
@@ -25,6 +26,14 @@
                 croak(e.what());
             }
         %};
+    void do_export_w_preview(Print *print, const char *path, GCodePreviewData *preview_data)
+        %code%{
+            try {
+                THIS->do_export(print, path, preview_data);
+            } catch (std::exception& e) {
+                croak(e.what());
+            }
+        %};
 
     Ref<Pointf> origin()
         %code{% RETVAL = &(THIS->origin()); %};
@@ -50,3 +59,27 @@
     Ref<StaticPrintConfig> config()
         %code{% RETVAL = const_cast<StaticPrintConfig*>(static_cast<const StaticPrintConfig*>(static_cast<const PrintObjectConfig*>(&THIS->config()))); %};
 };
+
+%name{Slic3r::GCode::PreviewData} class GCodePreviewData {
+    GCodePreviewData();
+    ~GCodePreviewData();
+    void reset();
+    bool empty() const;
+    void set_type(int type)
+        %code%{
+            if ((0 <= type) && (type < GCodePreviewData::Extrusion::Num_View_Types)) 
+                THIS->extrusion.view_type = (GCodePreviewData::Extrusion::EViewType)type;
+        %};
+    int type() %code%{ RETVAL = (int)THIS->extrusion.view_type; %};
+    void set_extrusion_flags(int flags)
+        %code%{ THIS->extrusion.role_flags = (unsigned int)flags; %};
+    void set_travel_visible(bool visible)
+        %code%{ THIS->travel.is_visible = visible; %};
+    void set_retractions_visible(bool visible)
+        %code%{ THIS->retraction.is_visible = visible; %};
+    void set_unretractions_visible(bool visible)
+        %code%{ THIS->unretraction.is_visible = visible; %};
+    void set_shells_visible(bool visible)
+        %code%{ THIS->shell.is_visible = visible; %};
+    void set_extrusion_paths_colors(std::vector<std::string> colors);
+};
diff --git a/xs/xsp/GUI.xsp b/xs/xsp/GUI.xsp
index d6b55dbf1..226d6a45c 100644
--- a/xs/xsp/GUI.xsp
+++ b/xs/xsp/GUI.xsp
@@ -31,9 +31,27 @@ void set_main_frame(SV *ui)
 
 void set_tab_panel(SV *ui)
     %code%{ Slic3r::GUI::set_tab_panel((wxNotebook*)wxPli_sv_2_object(aTHX_ ui, "Wx::Notebook")); %};
+    
+void add_debug_menu(SV *ui, int event_language_change)
+    %code%{ Slic3r::GUI::add_debug_menu((wxMenuBar*)wxPli_sv_2_object(aTHX_ ui, "Wx::MenuBar"), event_language_change); %};
 
-void add_debug_menu(SV *ui)
-    %code%{ Slic3r::GUI::add_debug_menu((wxMenuBar*)wxPli_sv_2_object(aTHX_ ui, "Wx::MenuBar")); %};
+void create_preset_tabs(PresetBundle *preset_bundle, AppConfig *app_config, 
+                        bool no_controller, bool is_disabled_button_browse, bool is_user_agent,
+                        int event_value_change, int event_presets_changed,
+                        int event_button_browse, int event_button_test)
+    %code%{ Slic3r::GUI::create_preset_tabs(preset_bundle, app_config, no_controller, 
+                                            is_disabled_button_browse, is_user_agent,
+                                            event_value_change, event_presets_changed, 
+                                            event_button_browse, event_button_test); %};
 
-void create_preset_tab(const char *name)
-    %code%{ Slic3r::GUI::create_preset_tab(name); %};
+Ref<TabIface> get_preset_tab(char *name)
+    %code%{ RETVAL=Slic3r::GUI::get_preset_tab_iface(name); %};
+
+bool load_language()
+    %code%{ RETVAL=Slic3r::GUI::load_language(); %};
+
+void create_combochecklist(SV *ui, std::string text, std::string items, bool initial_value)
+    %code%{ Slic3r::GUI::create_combochecklist((wxComboCtrl*)wxPli_sv_2_object(aTHX_ ui, "Wx::ComboCtrl"), text, items, initial_value); %};
+        
+int combochecklist_get_flags(SV *ui)
+    %code%{ RETVAL=Slic3r::GUI::combochecklist_get_flags((wxComboCtrl*)wxPli_sv_2_object(aTHX_ ui, "Wx::ComboCtrl")); %};
diff --git a/xs/xsp/GUI_3DScene.xsp b/xs/xsp/GUI_3DScene.xsp
index d19744f25..6ba2b6d33 100644
--- a/xs/xsp/GUI_3DScene.xsp
+++ b/xs/xsp/GUI_3DScene.xsp
@@ -42,6 +42,8 @@
         %code%{ RETVAL = THIS->hover; %};
     void                set_hover(int i)
         %code%{ THIS->hover = i; %};
+    int                 zoom_to_volumes()
+        %code%{ RETVAL = THIS->zoom_to_volumes; %};
 
     int                 object_idx() const;
     int                 volume_idx() const;
@@ -141,6 +143,39 @@ _glew_init()
     CODE:
         _3DScene::_glew_init();
 
+unsigned int
+finalize_legend_texture()
+    CODE:
+        RETVAL = _3DScene::finalize_legend_texture();
+    OUTPUT:
+        RETVAL
+
+unsigned int
+get_legend_texture_id()
+    CODE:
+        RETVAL = _3DScene::get_legend_texture_id();
+    OUTPUT:
+        RETVAL
+
+unsigned int
+get_legend_texture_width()
+    CODE:
+        RETVAL = _3DScene::get_legend_texture_width();
+    OUTPUT:
+        RETVAL
+
+unsigned int
+get_legend_texture_height()
+    CODE:
+        RETVAL = _3DScene::get_legend_texture_height();
+    OUTPUT:
+        RETVAL
+             
+void
+reset_legend_texture()
+    CODE:
+        _3DScene::reset_legend_texture();
+             
 void
 _load_print_toolpaths(print, volumes, tool_colors, use_VBOs)
         Print               *print;
@@ -168,4 +203,14 @@ _load_wipe_tower_toolpaths(print, volumes, tool_colors, use_VBOs)
     CODE:
         _3DScene::_load_wipe_tower_toolpaths(print, volumes, tool_colors, use_VBOs != 0);
 
+void 
+load_gcode_preview(print, preview_data, volumes, str_tool_colors, use_VBOs)
+        Print                    *print;
+        GCodePreviewData         *preview_data;
+        GLVolumeCollection       *volumes;
+        std::vector<std::string> str_tool_colors;
+        int                      use_VBOs;
+    CODE:
+        _3DScene::load_gcode_preview(print, preview_data, volumes, str_tool_colors, use_VBOs != 0);
+        
 %}
diff --git a/xs/xsp/GUI_Preset.xsp b/xs/xsp/GUI_Preset.xsp
index 0e6b1504b..0033ebd0e 100644
--- a/xs/xsp/GUI_Preset.xsp
+++ b/xs/xsp/GUI_Preset.xsp
@@ -18,8 +18,8 @@
     bool                        is_compatible_with_printer(Preset *active_printer)
         %code%{ RETVAL = THIS->is_compatible_with_printer(*active_printer); %};
 
-    const char*                 name()          %code%{ RETVAL = THIS->name.c_str(); %};
-    const char*                 file()          %code%{ RETVAL = THIS->file.c_str(); %};
+    std::string                 name()          %code%{ RETVAL = THIS->name; %};
+    std::string                 file()          %code%{ RETVAL = THIS->file; %};
 
     bool                        loaded()        %code%{ RETVAL = THIS->loaded;      %};
 
@@ -184,4 +184,6 @@ PresetCollection::arrayref()
         %code%{ RETVAL = PresetHints::cooling_description(*preset); %};
     static std::string maximum_volumetric_flow_description(PresetBundle *preset) 
         %code%{ RETVAL = PresetHints::maximum_volumetric_flow_description(*preset); %};
+    static std::string recommended_thin_wall_thickness(PresetBundle *preset)
+        %code%{ RETVAL = PresetHints::recommended_thin_wall_thickness(*preset); %};
 };
diff --git a/xs/xsp/GUI_Tab.xsp b/xs/xsp/GUI_Tab.xsp
new file mode 100644
index 000000000..9cacac74f
--- /dev/null
+++ b/xs/xsp/GUI_Tab.xsp
@@ -0,0 +1,23 @@
+%module{Slic3r::XS};
+
+%{
+#include <xsinit.h>
+#include "slic3r/GUI/TabIface.hpp"
+%}
+
+%name{Slic3r::GUI::Tab} class TabIface {
+    TabIface();
+    ~TabIface();
+    void		load_current_preset();
+    void		update_tab_ui();
+    void		update_ui_from_settings();
+    void		select_preset(char* name);
+	void		load_config(DynamicPrintConfig* config);
+	bool		current_preset_is_dirty();
+	void		load_key_value(char* opt_key, char* value);
+	void		OnActivate();
+	std::string	title();
+	Ref<DynamicPrintConfig>		get_config();
+	Ref<PresetCollection>		get_presets();
+	std::vector<std::string>	get_dependent_tabs();
+};
diff --git a/xs/xsp/Model.xsp b/xs/xsp/Model.xsp
index c96c56386..c0271ae75 100644
--- a/xs/xsp/Model.xsp
+++ b/xs/xsp/Model.xsp
@@ -3,12 +3,15 @@
 %{
 #include <xsinit.h>
 #include "libslic3r/Model.hpp"
+#include "libslic3r/Print.hpp"
 #include "libslic3r/PrintConfig.hpp"
 #include "libslic3r/Slicing.hpp"
 #include "libslic3r/Format/AMF.hpp"
+#include "libslic3r/Format/3mf.hpp"
 #include "libslic3r/Format/OBJ.hpp"
 #include "libslic3r/Format/PRUS.hpp"
 #include "libslic3r/Format/STL.hpp"
+#include "slic3r/GUI/PresetBundle.hpp"
 %}
 
 %name{Slic3r::Model} class Model {
@@ -24,6 +27,15 @@
             }
         %};
 
+    %name{read_from_archive} Model(std::string input_file, PresetBundle* bundle, bool add_default_instances = true)
+        %code%{
+            try {
+                RETVAL = new Model(Model::read_from_archive(input_file, bundle, add_default_instances));
+            } catch (std::exception& e) {
+                croak("Error while opening %s: %s\n", input_file.c_str(), e.what());
+            }
+        %};
+        
     Clone<Model> clone()
         %code%{ RETVAL = THIS; %};
     
@@ -89,8 +101,10 @@
 
     bool store_stl(char *path, bool binary)
         %code%{ TriangleMesh mesh = THIS->mesh(); RETVAL = Slic3r::store_stl(path, &mesh, binary); %};
-    bool store_amf(char *path)
-        %code%{ RETVAL = Slic3r::store_amf(path, THIS); %};
+    bool store_amf(char *path, Print* print)
+        %code%{ RETVAL = Slic3r::store_amf(path, THIS, print); %};
+    bool store_3mf(char *path, Print* print)
+        %code%{ RETVAL = Slic3r::store_3mf(path, THIS, print); %};
 
 %{
 
@@ -123,18 +137,33 @@ load_obj(CLASS, path, object_name)
         RETVAL
 
 Model*
-load_amf(CLASS, path)
+load_amf(CLASS, bundle, path)
     char*           CLASS;
+    PresetBundle*   bundle;
     char*           path;
     CODE:
         RETVAL = new Model();
-        if (! load_amf(path, RETVAL)) {
+        if (! load_amf(path, bundle, RETVAL)) {
             delete RETVAL;
             RETVAL = NULL;
         }
     OUTPUT:
         RETVAL
 
+Model*
+load_3mf(CLASS, bundle, path)
+    char*           CLASS;
+    PresetBundle*   bundle;
+    char*           path;
+    CODE:
+        RETVAL = new Model();
+        if (! load_3mf(path, bundle, RETVAL)) {
+            delete RETVAL;
+            RETVAL = NULL;
+        }
+    OUTPUT:
+        RETVAL
+        
 Model*
 load_prus(CLASS, path)
     char*           CLASS;
diff --git a/xs/xsp/Point.xsp b/xs/xsp/Point.xsp
index d0f9260c7..b7aded6a0 100644
--- a/xs/xsp/Point.xsp
+++ b/xs/xsp/Point.xsp
@@ -8,7 +8,7 @@
 %}
 
 %name{Slic3r::Point} class Point {
-    Point(long _x = 0, long _y = 0);
+    Point(int _x = 0, int _y = 0);
     ~Point();
     Clone<Point> clone()
         %code{% RETVAL=THIS; %}; 
@@ -18,13 +18,13 @@
         %code{% RETVAL = to_SV_pureperl(THIS); %};
     SV* pp()
         %code{% RETVAL = to_SV_pureperl(THIS); %};
-    long x()
+    int x()
         %code{% RETVAL = THIS->x; %};
-    long y()
+    int y()
         %code{% RETVAL = THIS->y; %};
-    void set_x(long val)
+    void set_x(int val)
         %code{% THIS->x = val; %};
-    void set_y(long val)
+    void set_y(int val)
         %code{% THIS->y = val; %};
     int nearest_point_index(Points points);
     Clone<Point> nearest_point(Points points)
@@ -77,15 +77,15 @@ Point::coincides_with(point_sv)
 };
 
 %name{Slic3r::Point3} class Point3 {
-    Point3(long _x = 0, long _y = 0, long _z = 0);
+    Point3(int _x = 0, int _y = 0, int _z = 0);
     ~Point3();
     Clone<Point3> clone()
         %code{% RETVAL = THIS; %};
-    long x()
+    int x()
         %code{% RETVAL = THIS->x; %};
-    long y()
+    int y()
         %code{% RETVAL = THIS->y; %};
-    long z()
+    int z()
         %code{% RETVAL = THIS->z; %};
     std::string serialize() %code{% char buf[2048]; sprintf(buf, "%ld,%ld,%ld", THIS->x, THIS->y, THIS->z); RETVAL = buf; %};
 };
diff --git a/xs/xsp/Print.xsp b/xs/xsp/Print.xsp
index 2e418253b..cbc04a804 100644
--- a/xs/xsp/Print.xsp
+++ b/xs/xsp/Print.xsp
@@ -152,6 +152,8 @@ _constant()
         %code%{ RETVAL = &THIS->skirt; %};
     Ref<ExtrusionEntityCollection> brim()
         %code%{ RETVAL = &THIS->brim; %};
+    std::string estimated_print_time()
+        %code%{ RETVAL = THIS->estimated_print_time; %};
 
     PrintObjectPtrs* objects()
         %code%{ RETVAL = &THIS->objects; %};
@@ -280,7 +282,6 @@ Print::total_cost(...)
         }
         RETVAL = THIS->total_cost;
     OUTPUT:
-        RETVAL
-
+        RETVAL        
 %}
 };
diff --git a/xs/xsp/XS.xsp b/xs/xsp/XS.xsp
index b2f772834..e900532aa 100644
--- a/xs/xsp/XS.xsp
+++ b/xs/xsp/XS.xsp
@@ -54,6 +54,12 @@ set_var_dir(dir)
     CODE:
         Slic3r::set_var_dir(dir);
 
+void
+set_local_dir(dir)
+    char  *dir;
+    CODE:
+        Slic3r::set_local_dir(dir);
+
 char*
 var_dir()
     CODE:
@@ -91,7 +97,7 @@ data_dir()
         RETVAL = const_cast<char*>(Slic3r::data_dir().c_str());
     OUTPUT: RETVAL
 
-std::string
+local_encoded_string
 encode_path(src)
     const char *src;
     CODE:
@@ -112,6 +118,41 @@ normalize_utf8_nfc(src)
         RETVAL = Slic3r::normalize_utf8_nfc(src);
     OUTPUT: RETVAL
 
+std::string
+path_to_filename(src)
+    const char *src;
+    CODE:
+        RETVAL = Slic3r::PerlUtils::path_to_filename(src);
+    OUTPUT: RETVAL
+
+local_encoded_string
+path_to_filename_raw(src)
+    const char *src;
+    CODE:
+        RETVAL = Slic3r::PerlUtils::path_to_filename(src);
+    OUTPUT: RETVAL
+
+std::string
+path_to_stem(src)
+    const char *src;
+    CODE:
+        RETVAL = Slic3r::PerlUtils::path_to_stem(src);
+    OUTPUT: RETVAL
+
+std::string
+path_to_extension(src)
+    const char *src;
+    CODE:
+        RETVAL = Slic3r::PerlUtils::path_to_extension(src);
+    OUTPUT: RETVAL
+
+std::string
+path_to_parent_path(src)
+    const char *src;
+    CODE:
+        RETVAL = Slic3r::PerlUtils::path_to_parent_path(src);
+    OUTPUT: RETVAL
+
 void
 xspp_test_croak_hangs_on_strawberry()
     CODE:
diff --git a/xs/xsp/my.map b/xs/xsp/my.map
index 7b59623d4..e54601632 100644
--- a/xs/xsp/my.map
+++ b/xs/xsp/my.map
@@ -1,6 +1,7 @@
 coordf_t T_NV
 
 std::string                     T_STD_STRING
+local_encoded_string     		T_STD_STRING_LOCAL_ENCODING
 t_config_option_key             T_STD_STRING
 t_model_material_id             T_STD_STRING
 
@@ -190,6 +191,10 @@ GCode*                      O_OBJECT_SLIC3R
 Ref<GCode>                  O_OBJECT_SLIC3R_T
 Clone<GCode>                O_OBJECT_SLIC3R_T
 
+GCodePreviewData*			O_OBJECT_SLIC3R
+Ref<GCodePreviewData>		O_OBJECT_SLIC3R_T
+Clone<GCodePreviewData>		O_OBJECT_SLIC3R_T
+
 MotionPlanner*             O_OBJECT_SLIC3R
 Ref<MotionPlanner>         O_OBJECT_SLIC3R_T
 Clone<MotionPlanner>       O_OBJECT_SLIC3R_T
@@ -228,6 +233,8 @@ PresetBundle*	    		O_OBJECT_SLIC3R
 Ref<PresetBundle>    		O_OBJECT_SLIC3R_T
 PresetHints*	    		O_OBJECT_SLIC3R
 Ref<PresetHints>    		O_OBJECT_SLIC3R_T
+TabIface*	   				O_OBJECT_SLIC3R
+Ref<TabIface> 				O_OBJECT_SLIC3R_T
 
 Axis                  T_UV
 ExtrusionLoopRole     T_UV
@@ -279,6 +286,14 @@ T_STD_STRING
       $var = std::string(c, len);
     }
 
+INPUT
+T_STD_STRING_LOCAL_ENCODING
+    {
+      size_t len;
+      const char * c = SvPV($arg, len);
+      $var = std::string(c, len);
+    }
+
 T_STD_VECTOR_STD_STRING
 	if (SvROK($arg) && SvTYPE(SvRV($arg))==SVt_PVAV) {
 	  AV* av = (AV*)SvRV($arg);
@@ -438,6 +453,9 @@ OUTPUT
 T_STD_STRING
     $arg = newSVpvn_utf8( $var.c_str(), $var.length(), true );
 
+T_STD_STRING_LOCAL_ENCODING
+    $arg = newSVpvn( $var.c_str(), $var.length() );
+
 T_STD_VECTOR_STD_STRING
 	AV* av = newAV();
 	$arg = newRV_noinc((SV*)av);
diff --git a/xs/xsp/typemap.xspt b/xs/xsp/typemap.xspt
index d6c74659c..0214a158d 100644
--- a/xs/xsp/typemap.xspt
+++ b/xs/xsp/typemap.xspt
@@ -155,6 +155,9 @@
 %typemap{Ref<GCode>}{simple};
 %typemap{Clone<GCode>}{simple};
 
+%typemap{GCodePreviewData*};
+%typemap{Ref<GCodePreviewData>}{simple};
+%typemap{Clone<GCodePreviewData>}{simple};
 
 %typemap{Points};
 %typemap{Pointfs};
@@ -207,6 +210,8 @@
 %typemap{Ref<PresetBundle>}{simple};
 %typemap{PresetHints*};
 %typemap{Ref<PresetHints>}{simple};
+%typemap{TabIface*};
+%typemap{Ref<TabIface>}{simple};
 
 %typemap{PrintRegionPtrs*};
 %typemap{PrintObjectPtrs*};