Draft of refactored & simplified implementation.