Added pagination, optional routes, refactored server.js