fix for #1598

@FinalAngel: does this look OK for you?