Bug squashing

This merge attempts to squash the following Gentoo bugs:
    - X-Gentoo-Bug: 315359
    - X-Gentoo-Bug: 396031
    - X-Gentoo-Bug: 461540
    - X-Gentoo-Bug: 512316