Updated layer drawing logic.