one of the bugs is due to mi beeing zero, that results in a infinite velocity and more, fix would be to make sure everything involved in mi is not affected negatively when its zero