fixed nasty bug (crash or memory leak)