Bugfix for #491. Thanks to Steffen for reporting and fixing