Refactored, added ElasticSearch support