public HGLiveHandle atomRefresh(HGLiveHandle handle, Object atom, boolean replace) 
	{
	    if (handle.getRef() == atom)
	        return handle; // same atom, nothing to do
		if (closing)
		{
			if (handle instanceof WeakHandle)
				((WeakHandle)handle).clear();
			else
				((TempLiveHandle)handle).setRef(atom);
			return handle;
		}
	    WeakHandle newLive = null;
	    if (handle instanceof WeakManagedHandle)
	        newLive = new WeakManagedHandle(atom, 
	                                        handle.getPersistent(), 
	                                        handle.getFlags(), 
	                                        refQueue,
	                                        ((WeakManagedHandle)handle).getRetrievalCount(),
	                                        ((WeakManagedHandle)handle).getRetrievalCount());
	    else
	        newLive = new WeakHandle(atom, 
	                                 handle.getPersistent(),
	                                 handle.getFlags(),
	                                 refQueue);
	    
        graph.getTransactionManager().getContext().getCurrent().addAbortAction(new ClearHandleAction(newLive));
        
	    // We are updating two maps here. Because the atoms map is weak-ref-based, the
	    // correct order is to update it first for otherwise a previously kicked in
	    // garbage collection of the corresponding 'liveHandles' entry will create a 
	    // race condition
	    
	    Object curr = handle.getRef();
	    ((WeakHandle)handle).clear();
	    
	    // If we have some other Java instance as the atom, we need to force a replace
	    // even if strictly speaking we don't need to (e.g. this happens with type wrappers)
	    // because in case of a roll back the obligatory atoms.remove will be reversed.
        gcLock.readLock().lock();
        try
        {       
    	    if (replace || curr != null)
    	    {
    	        if (curr != null)
    	            atoms.remove(curr);
    	        atoms.put(atom, newLive);
    	        liveHandles.put(handle.getPersistent(), newLive);
    	    }		    
    	    else
    	    {
                atoms.load(atom, newLive);		        
    	        liveHandles.load(handle.getPersistent(), newLive);
    	    }
            coldAtoms.add(atom);
            return newLive;    	    
	    }
	    finally
	    {
	        gcLock.readLock().unlock();	        
	    }
	}