Cleaned up error handling and added some examples