fixed several small bugs.