updated err handler to look for lost server, consolidated some day.js code