Refactoring.
Fix some problems.