fix a few bugs where input is read too fast.