Several fixes

see commits for details