Move elasticsearch code into new module and clean-up names of things.