Fixed an exception when the returned object was not castable to String.