Fixed attaching of layers.