Improve the template inflation for pipelining