Sync with Driver's code, clean up later.