Should he focus on purifying his heart or on doing naafil acts?
Question

Which is more important – dealing with feelings and thoughts that Allah dislikes, such as destructive envy, hatred, arrogance, showing off, thinking highly of one's deeds, hard-heartedness, etc., which form the evil that resides in the heart, or focusing on doing outward naafil deeds such as prayer, fasting and other acts of worship and fulfilling vows even though those other things are present in the heart? Please advise us, may Allah reward you with good.
Praise be to Allah.Some of the acts mentioned are obligatory, and those which are obligatory should be given precedence, as Allah says according to the hadith qudsi narrated from His Messenger (peace and blessings of Allah be upon him): “My slave does not draw near to Me with anything more loved by Me than the religious duties I have enjoined on him.” Then He says: “And My slave continues to draw near to Me with supererogatory works so that I shall love him.” Outward physical acts are not valid and acceptable unless they are accompanied by appropriate actions of the heart, because the heart is like the king and the physical faculties are like his troops. If the king is evil his troops will also be evil. Hence the Prophet (peace and blessings of Allah be upon him) said: “In the body there is a piece of flesh: if it is sound the whole body will be sound and if it is corrupt then the whole body will be corrupt.”  Similarly the (hidden) actions of the heart inevitably affect the (visible) physical actions. So precedence must be given to that which is more obligatory, whether it is called inward or outward. Perhaps things that are called inward may be more obligatory, such as refraining from destructive envy and arrogance, for that is more essential than observing naafil fasts. Or acts that are described as outward or physical may be better, such as qiyaam al-layl (praying at night), which is better than simply giving up some thoughts that may cross one's mind such as (non-destructive) jealousy, etc. Inward and outward deeds support one another, and prayer keeps one from doing evil actions and generates fear of Allah, and has other important effects. It (prayer) is the best of good deeds and charity. And Allah knows best. 
Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him), Majmoo’ al-Fatawa, 6/381 
So there is no separation between correcting what is inward and correcting what is outward or physical. 
The outward acts of worship which a person performs with his physical faculties – if he does them for the sake of Allah – will undoubtedly have an effect on his inward nature. 
For example, the Prophet (peace and blessings of Allah be upon him) said: “Shall I not tell you of something that will take away the evil of the heart? Fasting three days of each month.” (Narrated by al-Nasaa’i, 2386; classed as saheeh by al-Albani in Saheeh al-Nasaa’i, 2249). The evil of the heart refers to rancour, hatred and destructive envy. 
One of the most important remedies for diseases of the heart is to study and ponder the texts which include warnings to the one who leaves these diseases to fester in his heart, such as the hadith in which the Prophet (peace and blessings of Allah be upon him) said: “No one will enter Paradise who has an atom’s-weight of arrogance in his heart.” (Narrated by Muslim, 91). 
And the hadith according to which Hell will say, “My share is the arrogant.” (Narrated by al-Bukhari, 4850; Muslim, 2846) 
And the hadith: “On the Day of Resurrection the arrogant will be gathered like ants in the form of men.” (Narrated by al-Tirmidhi, 2492; classed as hasan by al-Albani in Saheeh al-Tirmidhi, 2025). 
And the Prophet (peace and blessings of Allah be upon him) said: “The disease of the nations who came before you has started to spread among you: destructive envy and hatred. These are the shavers. I do not mean that they shave hair but they shave away religious commitment. By the One in Whose hand is my soul, you will not enter Paradise until you believe, and you will not believe until you love one another. Shall I not tell you of something which if you do it, you will love one another. Spread (the greeting of) salaam amongst yourselves.” (Narrated by al-Tirmidhi, 2510; classed as hasan by al-Albani in Saheeh al-Tirmidhi, 2038). 
Whoever ponders with true insight such warnings about the diseases of the heart will undoubtedly strive to cleanse his heart thereof, and will seek help in doing so by doing outward physical acts, praying to his Lord to cleanse his heart of hatred, destructive envy, rancour and so on, as Allah says, describing the prayer of the believers: 
“and put not in our hearts any hatred against those who have believed”
[al-Hashr 59:10 – interpretation of the meaning]
And Allah knows best. May Allah send blessings upon our Prophet Muhammad.