Branch merge of preferences work branch. Includes fixes for several bugs. WARNING...