server code cleanup

validates fine with jslint and jshint