Fixed exceptions when changing base layers.