setup mediator pattern and a bunch of other stuff