Refactor reading packages file.