Also note that even the documentation for MouseXspeed/MouseYSpeed notes that you should call these commands twice in your loop. The second call should "zero" them out. Keep your current MouseXspeed/MouseYSpeed in where it is and try also putting:
mausxspeed = MouseXSpeed()
mausyspeed = MouseYSpeed()
again, right before the flip command and see if that helps out any.
And to continue off off what cyberseth said... the problem with your code above is that the variables mausxspeed & mausyspeed will always keep the last mouse movement difference even if you are not moving the mouse. So the positive or negative number will continuely move your rect cursor about the screen until it hits a screen border. The need for the second set of MouseXSpeed() and MouseYSpeed() is needed at the end of the loop, before flip, to zero the data MouseXSpeed()/MouseYSpeed() out. So when that second set is there and when you dont move the mouse, there shouldn't be any "crazy" movements involved.
Hope this helps...