Added support for automatically returning XML, if requested