Pref writing

Beginning to implement pref reading and writing