Fixes #1058 first point

And a bug in the third point commit