Added error handlers and friendlier error messages.