Refactoring.
Fix type inference issues.