Ported to Kepler (except targetdef)