Previous patch was incomplete and broke with deprecated APIs disabled. Signed-off-by: Rosen Penev <rosenp@gmail.com>