Some refactoring, fixed core logical issue with deriving with compressed files