Fixed handling of layer positions