A method of producing hydrocarbons from a recycled or renewable organic material, wherein the recycled or renewable organic material comprises from 5 to 30 wt-% oxygen as organic oxygen compounds and from 1 to 1000 ppm phosphorous as phosphorous compounds, comprising the steps of (a) providing the recycled or renewable organic material; (b) heat treating the recycled or renewable organic material at a temperature of 200 to 300 °C, preferably 240 to 280 °C in a residence time of 5 to 90 min, preferably of 20 to 40 min, to form a heat treated recycled or renewable organic material, wherein at least part of silicon compounds present in the recycled or renewable organic material are converted to volatile silicon compounds; and (c) thermally cracking at a temperature from 300 to 450°C and at a pressure from 4 to 20 MPa the heat treated recycled or renewable organic material thereby reducing the oxygen and phosphorous content of the recycled or renewable organic material to obtain (i) a vapor fraction comprising the major part of volatiles, and (ii) a thermally cracked recycled or renewable organic material fraction comprising less oxygen and less phosphorous than the recycled or renewable organic material provided in step (a); (d) the volatiles created due to the thermal cracking and/or otherwise present in the recycled or renewable organic material are removed from the thermally cracked recycled or renewable organic material; (e) optionally removing solids and/or precipitates from the thermally cracked recycled or renewable organic material fraction; and (f) hydrotreating the thermally cracked recycled or renewable organic material fraction in a presence of a hydrotreating catalyst; to obtain hydrocarbons comprising less than 1 wt% oxygen and less phosphorous than the recycled or renewable organic material provided in step (a). (a) providing the recycled or renewable organic material; (b) heat treating the recycled or renewable organic material at a temperature of 200 to 300 °C, preferably 240 to 280 °C in a residence time of 5 to 90 min, preferably of 20 to 40 min, to form a heat treated recycled or renewable organic material, wherein at least part of silicon compounds present in the recycled or renewable organic material are converted to volatile silicon compounds; and (c) thermally cracking at a temperature from 300 to 450°C and at a pressure from 4 to 20 MPa the heat treated recycled or renewable organic material thereby reducing the oxygen and phosphorous content of the recycled or renewable organic material to obtain (i) a vapor fraction comprising the major part of volatiles, and (ii) a thermally cracked recycled or renewable organic material fraction comprising less oxygen and less phosphorous than the recycled or renewable organic material provided in step (a); (i) a vapor fraction comprising the major part of volatiles, and (ii) a thermally cracked recycled or renewable organic material fraction comprising less oxygen and less phosphorous than the recycled or renewable organic material provided in step (a); (d) the volatiles created due to the thermal cracking and/or otherwise present in the recycled or renewable organic material are removed from the thermally cracked recycled or renewable organic material; (e) optionally removing solids and/or precipitates from the thermally cracked recycled or renewable organic material fraction; and (f) hydrotreating the thermally cracked recycled or renewable organic material fraction in a presence of a hydrotreating catalyst; to obtain hydrocarbons comprising less than 1 wt% oxygen and less phosphorous than the recycled or renewable organic material provided in step (a).