refactored to remove dependence on servlets for core functionality in order to allow for Play Framework compatibility.