Move all server logic to /lib