Make a few changes after review comments

Add comment on segment.io boilerplate code.
Make check for public site common code.
Wrap error handler code in try/catch.