Final version of the bugfix for 572

Fixes #572
Improves upon #573