Debian fixes eight

The same fixes as in #1267, rebased for inclusion into eight branch.