better handling of non-existent layers. Not greate, though.