Another attempt at fixing the API deadlock

fixes #6617