All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad, sallallaahu`alayhi wa sallam, is His slave and Messenger.
These bad ideas are mere whispers, so you should not take them into account nor pay them any attention. As for restarting the prayer because of whispers, it is a result of the reprehensible giving in to those whispers. Describing these thoughts as bad thoughts indicates your hatred for them and your aversion to them, and it is a sign of the validity of your faith. So, give up those whispers and do not pay any attention to them.
Allah knows best.