EPD-34: cleaned up and some refactoring.