Fix important but three-line bug that took me days to find.