Solved register save/restore bug