Clean up user agent handling and use indexer to prevent runtime error saying "use the appropriate property to set the header"