cleans up cruft in template