fix a few bugs.