Refactor z order system for UI elements