Hard to tell without seeing what Raw_move does.

Have you tried disabling events whilst the function executes?