Lots of compatibility fixes.