Bug fixes

Memory leak corrected.