Added lzma compression option. Fixed resource leaks.