Remove ElasticSearch global, pass it as argument

I think it could be done more nicely.. But it seems to work.
Fix the indentation here... I'll stop saying it. Fix it everywhere :)