Move layout functions to separate file