Improved template variable handling

PHP magic methods can be used to imitate getting/setting of public variables on objects. This gets rid of the ugly $internal property, which means `$template->internal` is no longer a reserved variable name, and the Template code is a lot clearer.