Use simpler basestring check and remove duplicated `Network()` casting.