Fix memory management (now Valgrind clean for init/terminate)