Reorganized and refactored