Improved extract function, added xz support.