Refining by treating with gases