Added better error messages for state creation.