slowly but surely rewriting template's php to meet drupal standards