Fix server issue and move files into lib