Cleaned up mediator.js a bit.