Fix foundation compatibility issues