server module refactored (old code is still present and commented out)