clean up spin lock for better performance and cleaned up some tests.