Added error messages to be more specific on what is going on.