Cleanup in the template classes