Server class refactored to be more generic