Added handling of out of order states

graceful handling of cyclic dependencies