Bugfix for the spinlock. Scheduler refactoring + fix against deadlocks. Mutex test stub.