lots of updates for preferences and code cleanup