memory leak fix (I hope) otherwise: optimizing