Fix an error in instance.py. Improve error messages