Refactorings and improved debug view