Fix dirty replacement to update and to correctly adjust cache size