Add preference dump function. Handle an error better.