preferences works. fixed some bugs
merge with head