clean up. Split APP ito several parts. Refactor mediator