Fixed #790
Second attempt at fixing #790