Cleaned up server.js a bit.  Broke out controls logic into a helper file.