Added template for preferences

Now with support for a preferences template with a small amount of type
checking.