Restructure and inclusion of server code from prototype