Fix NaN issue (thanks Marcus for realizing what it was).