add spinlocks. todo: check for multi-cpu issues