Templating (ejs-locals), server file style.

Made templating work, rearranged server file to keep difference between database stuff and server stuff.
Calling save without a callback before was causing race condition.