Cleanup

I changed a LOT in this PR, but hopefully no functionality.

@agross could you please cross-check if your multi-package scenario still works (as good as before)?