Fix bug where Nans were appearing occasionally and throwing stuff off