The valley was enclosed by the uplift of the Coast Ranges, with its original outlet into Monterey Bay. Faulting moved the Coast Ranges, and a new outlet developed near what is now San Francisco Bay. Over the millennia, the valley was filled by the sediments of these same ranges, as well as the rising Sierra Nevada to the east; that filling eventually created an extraordinary flatness just barely above sea level; before California's massive flood control and aqueduct system was built, the annual snow melt turned much of the valley into an inland sea.