Refactoring and simplification.
Changed main app data structure.