more diazo compatibility fixes

Can you also merge this? There were many more diazo related issues we came across and have hopefully now resolved.