Allocator made threadsafe, spinlock implementation added.