Updated utils to report errors in a sensible way.
Should really move utils to utils.js in separate project