Based off http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=182069