repatriated some util functions from as-io