Added more comments. Changed server.js port from 8888 to 8000.
Flattened function structure somewhat.