Restructured, fixed server.js