Layout generation fixes