changes to get manyfmts nearer to working and fixed memory leak