Refactoring and build fix.