more refactoring inspired by upstream docs / pkgfile