Master Content Type in package bug


I created a package with different document types. Some of the document types have a Master Content Type which are also included in the package. The problem is when installing the package some of the document types don’t have their master because it’s installed at a later time (in alphabetical sequence). In the images below is an example:
The document types on the site where the package is created:
The document types on the site where the package is installed:
As you can see only pagina_Standaard has it’s master because it’s later in alphabetical sequence. Now I can manually adjust the package.xml file in which the sequence is stored, but I don’t want to do this every time the package is updated.
This is not the only bug I’ve encountered. When I want to uninstall the package I get the following error: “Can't delete a Document Type used as a Master Content Type. Please remove all references first!” So if I want to uninstall the files I have the opposite problem. The Master Content Type is deleted first while it still has children.
In order to solve this bug the install and uninstall sequence should be different.
(copied from [workitem:24438] on Umbraco CMS project by codegecko)