Remove ElasticSearch global, pass it as argument

I think it could be done more nicely.. But it seems to work.