add init/exit and fix memleaks