When a foundation is out-of-level and out-of-square, you can shim the joists, notch the plates, and adjust their position on the foundation wall to fix it.