fix a few bugs