Re-factored server API to use factory pattern.