Cleaned up layout code