preferences code cleanup
Merge branch 'master' into tags-master