Fix for #1676

I don´t know if I covered everything, but it should fix #1676.