Reworked fix for #359