Initialize layers to the actual layers in the map

The problem was coming from the fact that scope.layers was initially empty.

#1058