Added jumping and falling flags, and fixed velocity limiting