Fix for http://mantis.brewpi.com/view.php?id=5

Details of the changes are documented in http://mantis.brewpi.com/view.php?id=5