Refactoring and initial analysis implementation