Refactored code to improved seperation of concerns with DE webapp.