Move some layout code into self-contained headers for autogen