Added error messages to help with debugging