Shaikh Jalal ud Deen Thanesari (Allah have mercy on him d. 989 Hijri) said,
‘The (spiritual) ailments of heart (mind) are from three sources.
1. (Useless) Self talking (hadith e nafs). It is the thinking that is both with intention and volition.
2. The (potentially) threatening (khatra) thinking. These are the unintentional random thoughts. (If one actively gets involved in them.)
3. The focus of heart on things other-than-Allah (ghair)’
Irshad at Talibeen, page 14
The excessive mindful remembrance of Allah done as instructed by spiritual masters is to fix these issues.