Improve default template and layout function