The final editing--and the addition of the P Text (Priestly Text) material--occurred during or soon after the Babylonian exile (597 and 587/586 BCE). At this time, the Judaic priests were probably desperate to retain their unique monotheistic beliefs in the face of overwhelming Babylonian influence, but they also faced the challenge of harmonizing their world view with that of the Babylonian tradition. Babylonian cosmology (like Egyptian cosmology) believed in a world-destroying flood and a transparent firmament in the sky. These ideas go back in the writings of the Babylonian conquerors to The Epic of Gilgamesh (c. 1800 BCE), long before classical Hebrew existed as a separate language from Proto-Canaanite.
At this point in their Babylonian captivity, the Hebrews incorporated a number of concepts into their later religious practice. Biblical scholars think these late religious practices probably included special treatment of the Sabbath day, elaborate food taboos regarding what is kosher, and taboos against writing down the name of God. Other features of the P text--such as the details of the Passover ritual, ordination ceremonies, and descriptions of the tabernacle--appear to have come from older (and now lost) manuscript traditions. These lost texts were updated and modified in the P tradition. The P text also gives much more prominence to priests such as Aaron (as opposed to the dominant role of Moses in the J and E texts), to the account of Moses' death in Deuteronomy, to the legal materials of Leviticus and Numbers, and to a series of genealogies showing some influence from older Mesopotamian sources.
At this time, the P editors also adapted elements of the Chaldean creation stories into the Genesis account. Some of the elements from the Chaldean creation stories include the flood motif, the idea of a firmament that holds up "the waters above" from "the waters below," and certain characters and genealogical names appearing in both Genesis and The Epic of Gilgamesh, a much older pagan text first written down in cuneiform tablets about 1800 BCE. Additionally, many Aramaic (aka "Chaldee") loanwords appear in the Hebrew text at this time and they are incorporated into the Hebrew Bible thereafter. This influence explains today why most biblical concordances and dictionaries (such as the 1979 version of Strong's Comprehensive Concordance of the Bible) refer to their Hebrew sections as a "Concordance of Hebrew and Chaldean," a "Hebrew and Chaldee Dictionary," or a "Hebrew and Aramaic Dictionary." Christ will still be using some Aramaic terms 400 years later in the New Testament gospels, which show how influential and long-lasting the linguistic effects of the exile were on the Hebrew vocabulary. Biblical scholars think that Genesis 1:1-2:3 and other sections such as Genesis 6 come from the P Text, and these are probably the latest additions to the Genesis account. The loanwords mean the Hebrew texts couldn't have been written before coming into contact with the Chaldeans--at least not in the form in which they come down to us today in surviving manuscripts.