Refactored app code into hooks.