Using newer ES lib, some refactorings