moved layer drawing functionality into layout.lua