Clean up layout code