Many compatibility and namespace fixes.