fixed a few bugs.