Fixes to support user agent and writing embedded resources