Memory leak fix, *.osz creating bug fix