add max velocity and free memory