Make return_type metafunction more robust