This commit refactors the PackageManager class and turns it into a proper factory class which also include type hints to facilitate it's use from an API POV. Related to #1498