Properly writes and loads from dictionary.