Change implementation to use SpinLock instead of synchronize everywhere