First commit of preferences.js (completely working, but un-unit-tested).