Improve configuration saving

See #321