Extract server code to module