fix bugs found from qa tests.