move default layout handling code in its own class