fix some bugs.
complete.