Actually your response made me think. I uploaded several versions of my file to the server (no extra g-code, only start g-code and so on) and found out that it is my end code that causes the layer calculation logic to fail. Which part of the code would it be?
<p style="box-sizing: border-box; margin: 0px; color: rgb(85, 85, 85); font-size: 16px; line-height: normal; font-family: 'Helvetica Neue';">;</p><p style="box-sizing: border-box; margin: 0px; color: rgb(85, 85, 85); font-size: 16px; line-height: normal; font-family: 'Helvetica Neue';">; End G-code</p><p style="box-sizing: border-box; margin: 0px; color: rgb(85, 85, 85); font-size: 16px; line-height: normal; font-family: 'Helvetica Neue';">;</p><p style="box-sizing: border-box; margin: 0px; color: rgb(85, 85, 85); font-size: 16px; line-height: normal; font-family: 'Helvetica Neue';">M104 S0 ; turn off temperature</p><p style="box-sizing: border-box; margin: 0px; color: rgb(85, 85, 85); font-size: 16px; line-height: normal; font-family: 'Helvetica Neue';">M140 S0 ; Set bed temperature to 0</p><p style="box-sizing: border-box; margin: 0px; color: rgb(85, 85, 85); font-size: 16px; line-height: normal; font-family: 'Helvetica Neue';">G28 X0 ; home X axis</p><p style="box-sizing: border-box; margin: 0px; color: rgb(85, 85, 85); font-size: 16px; line-height: normal; font-family: 'Helvetica Neue';">G28 Z0 ; home Z axis</p><p style="box-sizing: border-box; margin: 0px; color: rgb(85, 85, 85); font-size: 16px; line-height: normal; font-family: 'Helvetica Neue';">G1 Y170 ; move table forward</p><p style="box-sizing: border-box; margin: 0px; color: rgb(85, 85, 85); font-size: 16px; line-height: normal; font-family: 'Helvetica Neue';">M84 ; disable motors</p><p style="box-sizing: border-box; margin: 0px; color: rgb(85, 85, 85); font-size: 16px; line-height: normal; font-family: 'Helvetica Neue';">M42 P9 S0</p>