fixed res.send to avoid deprecation warnings
clean up of debuggin code