Moved file handling functions into zfile class