Add a lot of fixes from old core.