Refactored some things and added support for tgz.
Fixed some bugs and typo