Soe more fixes in layout code