Refactoring. Work in progress.