Fix for cast error, renamed vars r10/r12