preferences saving feature fix & code cleanup