Fixed lp:1308146 - backported from trunk
Merge pull request #790 from dimitern/lp-1308146-1.20-backport

Fixed lp:1308146 - backported from trunk

See http://pad.lv/1308146 - this fixes the issue by backporting
the already landed fix from trunk (#786).