preferences code cleanup