fixing a few bugs.