Forward-port patches from SUSE

Please do not merge yet. It still needs some more testing especially on Ubuntu.