fixed error handling code, and added require statements to examples.