Prototype working. Refactoring in progress.