fix several bugs.
19 files changed