clean up template codes.