Use locking for allocate

Make sure that the changes to the role object are properly done  under a lock. This should solve half of the allocate race. 

Not well tested yet.