Major refactoring in the server, add underscore templating