Fix (part of) #76. Preferences are now only escaping in Smarty, so
double escaping should no longer occur there. Also using functions from
the skin and database classes when possible in preferences.