Preliminary implementation. Refactoring.