Fix warning and bugs.