Cleans up template