Improve selection of require packages. bnc#895070. bnc#896178. bnc#896185.

I think this comment is not longer needed as code is self explained :)