Layers not always defined. 

To fix #356.