diff --git a/README.markdown b/README.markdown
index 86adce256..1d565b484 100644
--- a/README.markdown
+++ b/README.markdown
@@ -116,6 +116,9 @@ The author is Alessandro Ranellucci (me).
         
       Accuracy options:
         --layer-height      Layer height in mm (default: 0.4)
+        --first-layer-height-ratio
+                            Multiplication factor for the height to slice and print the first
+                            layer with (> 0, default: 1)
         --infill-every-layers
                             Infill every N layers (default: 1)
       
diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm
index 061ab1ce6..da48c2ecd 100644
--- a/lib/Slic3r.pm
+++ b/lib/Slic3r.pm
@@ -53,6 +53,7 @@ our $bottom_layer_speed_ratio   = 0.3;
 # accuracy options
 our $resolution             = 0.00000001;
 our $layer_height           = 0.4;
+our $first_layer_height_ratio = 1;
 our $infill_every_layers    = 1;
 our $thickness_ratio        = 1;
 our $flow_width;
diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm
index 732df6ac6..46dc76263 100644
--- a/lib/Slic3r/Config.pm
+++ b/lib/Slic3r/Config.pm
@@ -68,6 +68,10 @@ our $Options = {
         label   => 'Layer height (mm)',
         type    => 'f',
     },
+    'first_layer_height_ratio' => {
+        label   => 'First layer height ratio',
+        type    => 'f',
+    },
     'infill_every_layers' => {
         label   => 'Infill every N layers',
         type    => 'i',
@@ -249,6 +253,10 @@ sub validate {
     die "--layer-height must be a multiple of print resolution\n"
         if $Slic3r::layer_height / $Slic3r::resolution % 1 != 0;
     
+    # --first-layer-height-ratio
+    die "Invalid value for --first-layer-height-ratio\n"
+        if $Slic3r::first_layer_height_ratio < 0;
+    
     # --filament-diameter
     die "Invalid value for --filament-diameter\n"
         if $Slic3r::filament_diameter < 1;
@@ -258,6 +266,8 @@ sub validate {
         if $Slic3r::nozzle_diameter < 0;
     die "--layer-height can't be greater than --nozzle-diameter\n"
         if $Slic3r::layer_height > $Slic3r::nozzle_diameter;
+    die "First layer height can't be greater than --nozzle-diameter\n"
+        if ($Slic3r::layer_height * $Slic3r::first_layer_height_ratio) > $Slic3r::nozzle_diameter;
     $Slic3r::flow_width = ($Slic3r::nozzle_diameter**2) 
         * $Slic3r::thickness_ratio * PI / (4 * $Slic3r::layer_height);
     
diff --git a/lib/Slic3r/Layer.pm b/lib/Slic3r/Layer.pm
index 9a5242924..52d79ce7b 100644
--- a/lib/Slic3r/Layer.pm
+++ b/lib/Slic3r/Layer.pm
@@ -75,13 +75,19 @@ has 'fills' => (
 # Z used for slicing
 sub slice_z {
     my $self = shift;
-    return ($self->id * $Slic3r::layer_height + $Slic3r::layer_height/2) / $Slic3r::resolution;
+    if ($self->id == 0) {
+        return ($Slic3r::layer_height * $Slic3r::first_layer_height_ratio) / 2 / $Slic3r::resolution;
+    }
+    return (($Slic3r::layer_height * $Slic3r::first_layer_height_ratio)
+        + (($self->id-1) * $Slic3r::layer_height)
+        + ($Slic3r::layer_height/2)) / $Slic3r::resolution;
 }
 
 # Z used for printing
 sub print_z {
     my $self = shift;
-    return ($self->id + 1) * $Slic3r::layer_height / $Slic3r::resolution;
+    return (($Slic3r::layer_height * $Slic3r::first_layer_height_ratio)
+        + ($self->id * $Slic3r::layer_height)) / $Slic3r::resolution;
 }
 
 sub add_surface {
diff --git a/lib/Slic3r/STL.pm b/lib/Slic3r/STL.pm
index 602c69d36..6fc7ff80c 100644
--- a/lib/Slic3r/STL.pm
+++ b/lib/Slic3r/STL.pm
@@ -87,6 +87,10 @@ sub parse_file {
         }
     }
     
+    # remove last layer if empty
+    # (we might have created it because of the $max_layer = ... + 1 code below)
+    pop @{$print->layers} if !@{$print->layers->[-1]->surfaces} && !@{$print->layers->[-1]->lines};
+    
     return $print;
 }
 
@@ -110,8 +114,11 @@ sub _facet {
     }
     
     # calculate the layer extents
-    my $min_layer = int($min_z * $Slic3r::resolution / $Slic3r::layer_height);
-    my $max_layer = int($max_z * $Slic3r::resolution / $Slic3r::layer_height);
+    # (the -1 and +1 here are used as a quick and dirty replacement for some
+    # complex calculation of the first layer height ratio logic)
+    my $min_layer = int($min_z * $Slic3r::resolution / $Slic3r::layer_height) - 1;
+    $min_layer = 0 if $min_layer < 0;
+    my $max_layer = int($max_z * $Slic3r::resolution / $Slic3r::layer_height) + 1;
     Slic3r::debugf "layers: min = %s, max = %s\n", $min_layer, $max_layer;
     
     # reorder vertices so that the first one is the one with lowest Z
@@ -131,7 +138,7 @@ sub _facet {
 sub intersect_facet {
     my $self = shift;
     my ($vertices, $z) = @_;
-    
+    printf "Slicing at $z\n";
     # build the three segments of the triangle facet
     my @edges = (
         [ $vertices->[0], $vertices->[1] ],
diff --git a/slic3r.pl b/slic3r.pl
index b81284d58..e60c85d4c 100755
--- a/slic3r.pl
+++ b/slic3r.pl
@@ -43,6 +43,7 @@ GetOptions(
     
     # accuracy options
     'layer-height=f'        => \$Slic3r::layer_height,
+    'first-layer-height-ratio=f' => \$Slic3r::first_layer_height_ratio,
     'infill-every-layers=i' => \$Slic3r::infill_every_layers,
     
     # print options
@@ -155,6 +156,9 @@ Usage: slic3r.pl [ OPTIONS ] file.stl
     
   Accuracy options:
     --layer-height      Layer height in mm (default: $Slic3r::layer_height)
+    --first-layer-height-ratio
+                        Multiplication factor for the height to slice and print the first
+                        layer with (> 0, default: $Slic3r::first_layer_height_ratio)
     --infill-every-layers
                         Infill every N layers (default: $Slic3r::infill_every_layers)