Store name and visibility of layers

Fixes #764