refactored many elements of app architecture