Make layout more generic, fix error message rendering