refactor server setup and get ready for mongo storage