Re-implement by re-using code merged upstream