Persistent settings

Solves #624 and #523