Modularized server code a bit