Preventing memory leaks
Store template creation functions instead of templates