Patches for building on Debian 7

From https://github.com/martinpaljak/ria-debian-build