Added support for overriding hostname.