A reactor has two chambers, namely an oil feedstock chamber and a source chamber. An ion separator separates the oil feedstock chamber from the source chamber, wherein the ion separator allows alkali metal ions to pass from the source chamber, through the ion separator, and into the oil feedstock chamber. A cathode is at least partially housed within the oil feedstock chamber and an anode is at least partially housed within the source chamber. A quantity of an oil feedstock is within the oil feedstock chamber, the oil feedstock comprising at least one carbon atom and a heteroatom and/or one or more heavy metals, the oil feedstock further comprising naphthenic acid. When the alkali metal ion enters the oil feedstock chamber, the alkali metal reacts with the heteroatom, the heavy metals and/or the naphthenic acid, wherein the reaction with the alkali metal forms inorganic products.