Refactor of settings and small serailisation work.