Fix bug caused by floating point representation of momentum