When crude oil comes out of a well (especially an undersea well), the crude oil is often mixed with gases, water and sand. It forms an emulsion with the water that looks a bit like caramel.
The sand is suspended in the emulsion, adding to the caramel effect. The sand will settle out and the water is removed using de-emulsifying agents. They have to be separated from the crude oil before it can be processed ready for transportation by tanker or pipeline.
The dissolved gases have to be removed at the well. Otherwise, they might come out of solution and cause a build up of pressure in a pipe or a tanker.
The crude oil also contains sulphur. This has to be removed from any fractions that are going to be burnt because it forms sulphur dioxide which contributes to acid rain. So any fractions that go into fuels pass through hydrofiners to remove the sulphur..