Added reference counting and memory management for _smithform.c and smithform.c