Scheduler: adding deadlock warning and error handling